From bc83d9d4ca965b04b2bd2aa002a14351a9e8c0ab Mon Sep 17 00:00:00 2001 From: Hafez Divandari Date: Mon, 4 Mar 2024 18:10:28 +0330 Subject: [PATCH 1/2] Update migrations.md --- migrations.md | 71 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/migrations.md b/migrations.md index 86de2036511..e6dedbd9aba 100644 --- a/migrations.md +++ b/migrations.md @@ -479,6 +479,11 @@ The `binary` method creates a `BLOB` equivalent column: $table->binary('photo'); +When utilizing MySQL, MariaDB, or SQL Server you may pass `length` and `fixed` to create `VARBINARY` or `BINARY` equivalent column: + + $table->binary('data', length: 16); // VARBINARY(16) + $table->binary('data', length: 16, fixed: true) // BINARY(16) + #### `boolean()` {.collection-method} @@ -491,21 +496,21 @@ The `boolean` method creates a `BOOLEAN` equivalent column: The `char` method creates a `CHAR` equivalent column with of a given length: - $table->char('name', 100); + $table->char('name', length: 100); #### `dateTimeTz()` {.collection-method} -The `dateTimeTz` method creates a `DATETIME` (with timezone) equivalent column with an optional precision (total digits): +The `dateTimeTz` method creates a `DATETIME` (with timezone) equivalent column with an optional fractional seconds precision: - $table->dateTimeTz('created_at', $precision = 0); + $table->dateTimeTz('created_at', precision: 0); #### `dateTime()` {.collection-method} -The `dateTime` method creates a `DATETIME` equivalent column with an optional precision (total digits): +The `dateTime` method creates a `DATETIME` equivalent column with an optional fractional seconds precision: - $table->dateTime('created_at', $precision = 0); + $table->dateTime('created_at', precision: 0); #### `date()` {.collection-method} @@ -519,7 +524,7 @@ The `date` method creates a `DATE` equivalent column: The `decimal` method creates a `DECIMAL` equivalent column with the given precision (total digits) and scale (decimal digits): - $table->decimal('amount', $precision = 8, $scale = 2); + $table->decimal('amount', total: 8, places: 2); #### `double()` {.collection-method} @@ -540,7 +545,7 @@ The `enum` method creates a `ENUM` equivalent column with the given valid values The `float` method creates a `FLOAT` equivalent column with the given precision: - $table->float('amount', $precision = 53); + $table->float('amount', precision: 53); #### `foreignId()` {.collection-method} @@ -641,6 +646,10 @@ The `longText` method creates a `LONGTEXT` equivalent column: $table->longText('description'); +When utilizing MySQL or MariaDB, you may append `charset('binary')` modifier to get `LONGBLOB` equivalent column: + + $table->longText('data')->charset('binary'); // LONGBLOB + #### `macAddress()` {.collection-method} @@ -669,6 +678,10 @@ The `mediumText` method creates a `MEDIUMTEXT` equivalent column: $table->mediumText('description'); +When utilizing MySQL or MariaDB, you may append `charset('binary')` modifier to get `MEDIUMBLOB` equivalent column: + + $table->mediumText('data')->charset('binary'); // MEDIUMBLOB + #### `morphs()` {.collection-method} @@ -683,7 +696,7 @@ This method is intended to be used when defining the columns necessary for a pol The `nullableTimestamps` method is an alias of the [timestamps](#column-method-timestamps) method: - $table->nullableTimestamps(0); + $table->nullableTimestamps(precision: 0); #### `nullableMorphs()` {.collection-method} @@ -737,23 +750,23 @@ The `smallInteger` method creates a `SMALLINT` equivalent column: #### `softDeletesTz()` {.collection-method} -The `softDeletesTz` method adds a nullable `deleted_at` `TIMESTAMP` (with timezone) equivalent column with an optional precision (total digits). This column is intended to store the `deleted_at` timestamp needed for Eloquent's "soft delete" functionality: +The `softDeletesTz` method adds a nullable `deleted_at` `TIMESTAMP` (with timezone) equivalent column with an optional fractional seconds precision. This column is intended to store the `deleted_at` timestamp needed for Eloquent's "soft delete" functionality: - $table->softDeletesTz($column = 'deleted_at', $precision = 0); + $table->softDeletesTz('deleted_at', precision: 0); #### `softDeletes()` {.collection-method} -The `softDeletes` method adds a nullable `deleted_at` `TIMESTAMP` equivalent column with an optional precision (total digits). This column is intended to store the `deleted_at` timestamp needed for Eloquent's "soft delete" functionality: +The `softDeletes` method adds a nullable `deleted_at` `TIMESTAMP` equivalent column with an optional fractional seconds precision. This column is intended to store the `deleted_at` timestamp needed for Eloquent's "soft delete" functionality: - $table->softDeletes($column = 'deleted_at', $precision = 0); + $table->softDeletes('deleted_at', precision: 0); #### `string()` {.collection-method} The `string` method creates a `VARCHAR` equivalent column of the given length: - $table->string('name', 100); + $table->string('name', length: 100); #### `text()` {.collection-method} @@ -762,47 +775,51 @@ The `text` method creates a `TEXT` equivalent column: $table->text('description'); +When utilizing MySQL or MariaDB, you may append `charset('binary')` modifier to get `BLOB` equivalent column: + + $table->text('data')->charset('binary'); // BLOB + #### `timeTz()` {.collection-method} -The `timeTz` method creates a `TIME` (with timezone) equivalent column with an optional precision (total digits): +The `timeTz` method creates a `TIME` (with timezone) equivalent column with an optional fractional seconds precision: - $table->timeTz('sunrise', $precision = 0); + $table->timeTz('sunrise', precision: 0); #### `time()` {.collection-method} -The `time` method creates a `TIME` equivalent column with an optional precision (total digits): +The `time` method creates a `TIME` equivalent column with an optional fractional seconds precision: - $table->time('sunrise', $precision = 0); + $table->time('sunrise', precision: 0); #### `timestampTz()` {.collection-method} -The `timestampTz` method creates a `TIMESTAMP` (with timezone) equivalent column with an optional precision (total digits): +The `timestampTz` method creates a `TIMESTAMP` (with timezone) equivalent column with an optional fractional seconds precision: - $table->timestampTz('added_at', $precision = 0); + $table->timestampTz('added_at', precision: 0); #### `timestamp()` {.collection-method} -The `timestamp` method creates a `TIMESTAMP` equivalent column with an optional precision (total digits): +The `timestamp` method creates a `TIMESTAMP` equivalent column with an optional fractional seconds precision: - $table->timestamp('added_at', $precision = 0); + $table->timestamp('added_at', precision: 0); #### `timestampsTz()` {.collection-method} -The `timestampsTz` method creates `created_at` and `updated_at` `TIMESTAMP` (with timezone) equivalent columns with an optional precision (total digits): +The `timestampsTz` method creates `created_at` and `updated_at` `TIMESTAMP` (with timezone) equivalent columns with an optional fractional seconds precision: - $table->timestampsTz($precision = 0); + $table->timestampsTz(precision: 0); #### `timestamps()` {.collection-method} -The `timestamps` method creates `created_at` and `updated_at` `TIMESTAMP` equivalent columns with an optional precision (total digits): +The `timestamps` method creates `created_at` and `updated_at` `TIMESTAMP` equivalent columns with an optional fractional seconds precision: - $table->timestamps($precision = 0); + $table->timestamps(precision: 0); #### `tinyIncrements()` {.collection-method} @@ -825,6 +842,10 @@ The `tinyText` method creates a `TINYTEXT` equivalent column: $table->tinyText('notes'); +When utilizing MySQL or MariaDB, you may append `charset('binary')` modifier to get `TINYBLOB` equivalent column: + + $table->tinyText('data')->charset('binary'); // TINYBLOB + #### `unsignedBigInteger()` {.collection-method} From abb069c34014aabb97525388fc871312933ccd9d Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 4 Mar 2024 08:55:41 -0600 Subject: [PATCH 2/2] formatting --- migrations.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/migrations.md b/migrations.md index e6dedbd9aba..9df9c3a4200 100644 --- a/migrations.md +++ b/migrations.md @@ -479,10 +479,11 @@ The `binary` method creates a `BLOB` equivalent column: $table->binary('photo'); -When utilizing MySQL, MariaDB, or SQL Server you may pass `length` and `fixed` to create `VARBINARY` or `BINARY` equivalent column: +When utilizing MySQL, MariaDB, or SQL Server, you may pass `length` and `fixed` arguments to create `VARBINARY` or `BINARY` equivalent column: - $table->binary('data', length: 16); // VARBINARY(16) - $table->binary('data', length: 16, fixed: true) // BINARY(16) + $table->binary('data', length: 16); // VARBINARY(16) + + $table->binary('data', length: 16, fixed: true); // BINARY(16) #### `boolean()` {.collection-method} @@ -646,7 +647,7 @@ The `longText` method creates a `LONGTEXT` equivalent column: $table->longText('description'); -When utilizing MySQL or MariaDB, you may append `charset('binary')` modifier to get `LONGBLOB` equivalent column: +When utilizing MySQL or MariaDB, you may apply a `binary` character set to the column in order to create a `LONGBLOB` equivalent column: $table->longText('data')->charset('binary'); // LONGBLOB @@ -678,7 +679,7 @@ The `mediumText` method creates a `MEDIUMTEXT` equivalent column: $table->mediumText('description'); -When utilizing MySQL or MariaDB, you may append `charset('binary')` modifier to get `MEDIUMBLOB` equivalent column: +When utilizing MySQL or MariaDB, you may apply a `binary` character set to the column in order to create a `MEDIUMBLOB` equivalent column: $table->mediumText('data')->charset('binary'); // MEDIUMBLOB @@ -775,7 +776,7 @@ The `text` method creates a `TEXT` equivalent column: $table->text('description'); -When utilizing MySQL or MariaDB, you may append `charset('binary')` modifier to get `BLOB` equivalent column: +When utilizing MySQL or MariaDB, you may apply a `binary` character set to the column in order to create a `BLOB` equivalent column: $table->text('data')->charset('binary'); // BLOB @@ -842,7 +843,7 @@ The `tinyText` method creates a `TINYTEXT` equivalent column: $table->tinyText('notes'); -When utilizing MySQL or MariaDB, you may append `charset('binary')` modifier to get `TINYBLOB` equivalent column: +When utilizing MySQL or MariaDB, you may apply a `binary` character set to the column in order to create a `TINYBLOB` equivalent column: $table->tinyText('data')->charset('binary'); // TINYBLOB