From 991ea2009115564a93419d8b77093681369f914e Mon Sep 17 00:00:00 2001 From: Hafez Divandari Date: Tue, 13 Dec 2022 00:15:24 +0330 Subject: [PATCH 1/2] remove Doctrine DBAL from prerequisites of renaming/dropping column --- migrations.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/migrations.md b/migrations.md index 90000aa7ddd..6ac0a26effa 100644 --- a/migrations.md +++ b/migrations.md @@ -15,6 +15,7 @@ - [Available Column Types](#available-column-types) - [Column Modifiers](#column-modifiers) - [Modifying Columns](#modifying-columns) + - [Renaming Columns](#renaming-columns) - [Dropping Columns](#dropping-columns) - [Indexes](#indexes) - [Creating Indexes](#creating-indexes) @@ -1056,21 +1057,21 @@ We could also modify a column to be nullable: > The following column types can be modified: `bigInteger`, `binary`, `boolean`, `char`, `date`, `dateTime`, `dateTimeTz`, `decimal`, `double`, `integer`, `json`, `longText`, `mediumText`, `smallInteger`, `string`, `text`, `time`, `tinyText`, `unsignedBigInteger`, `unsignedInteger`, `unsignedSmallInteger`, and `uuid`. To modify a `timestamp` column type a [Doctrine type must be registered](#prerequisites). -#### Renaming Columns +### Renaming Columns -To rename a column, you may use the `renameColumn` method provided by the schema builder blueprint. Before renaming a column, ensure that you have installed the `doctrine/dbal` library via the Composer package manager: +To rename a column, you may use the `renameColumn` method provided by the schema builder blueprint: Schema::table('users', function (Blueprint $table) { $table->renameColumn('from', 'to'); }); > **Warning** -> Renaming an `enum` column is not currently supported. +> If you are running a version of MySQL older than the 8.0.3 release or MariaDB older than the 10.5.2 release or SQLite older than the 3.25.0 release, ensure that you have installed the `doctrine/dbal` library via the Composer package manager, before renaming a column. This package should be used with caution, renaming a column could potentially change its type definition. ### Dropping Columns -To drop a column, you may use the `dropColumn` method on the schema builder blueprint. If your application is utilizing an SQLite database, you must install the `doctrine/dbal` package via the Composer package manager before the `dropColumn` method may be used: +To drop a column, you may use the `dropColumn` method on the schema builder blueprint: Schema::table('users', function (Blueprint $table) { $table->dropColumn('votes'); @@ -1083,7 +1084,7 @@ You may drop multiple columns from a table by passing an array of column names t }); > **Warning** -> Dropping or modifying multiple columns within a single migration while using an SQLite database is not supported. +> If you are running a version of SQLite older than the 3.35.0 release, you must install the `doctrine/dbal` package via the Composer package manager before the `dropColumn` method may be used. Dropping or modifying multiple columns within a single migration while using this package is not supported. #### Available Command Aliases @@ -1167,6 +1168,10 @@ To rename an index, you may use the `renameIndex` method provided by the schema $table->renameIndex('from', 'to') + +> **Warning** +> If your application is utilizing an SQLite database, you must install the `doctrine/dbal` package via the Composer package manager before the `renameIndex` method may be used. + ### Dropping Indexes From 81566fffcb6a071cfb49b254e6a75bfb9083126f Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 15 Dec 2022 09:31:38 -0600 Subject: [PATCH 2/2] formatting --- migrations.md | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/migrations.md b/migrations.md index 6ac0a26effa..c2fe7d15a5d 100644 --- a/migrations.md +++ b/migrations.md @@ -1059,19 +1059,29 @@ We could also modify a column to be nullable: ### Renaming Columns -To rename a column, you may use the `renameColumn` method provided by the schema builder blueprint: +To rename a column, you may use the `renameColumn` method provided by the schema builder: Schema::table('users', function (Blueprint $table) { $table->renameColumn('from', 'to'); }); -> **Warning** -> If you are running a version of MySQL older than the 8.0.3 release or MariaDB older than the 10.5.2 release or SQLite older than the 3.25.0 release, ensure that you have installed the `doctrine/dbal` library via the Composer package manager, before renaming a column. This package should be used with caution, renaming a column could potentially change its type definition. + +#### Renaming Columns On Legacy Databases + +If you are running a database installation older than one of the following releases, you should ensure that you have installed the `doctrine/dbal` library via the Composer package manager before renaming a column: + +
+ +- MySQL < `8.0.3` +- MariaDB < `10.5.2` +- SQLite < `3.25.0` + +
### Dropping Columns -To drop a column, you may use the `dropColumn` method on the schema builder blueprint: +To drop a column, you may use the `dropColumn` method on the schema builder: Schema::table('users', function (Blueprint $table) { $table->dropColumn('votes'); @@ -1083,8 +1093,11 @@ You may drop multiple columns from a table by passing an array of column names t $table->dropColumn(['votes', 'avatar', 'location']); }); -> **Warning** -> If you are running a version of SQLite older than the 3.35.0 release, you must install the `doctrine/dbal` package via the Composer package manager before the `dropColumn` method may be used. Dropping or modifying multiple columns within a single migration while using this package is not supported. + + +#### Dropping Columns On Legacy Databases + +If you are running a version of SQLite prior to `3.35.0`, you must install the `doctrine/dbal` package via the Composer package manager before the `dropColumn` method may be used. Dropping or modifying multiple columns within a single migration while using this package is not supported. #### Available Command Aliases @@ -1168,7 +1181,6 @@ To rename an index, you may use the `renameIndex` method provided by the schema $table->renameIndex('from', 'to') - > **Warning** > If your application is utilizing an SQLite database, you must install the `doctrine/dbal` package via the Composer package manager before the `renameIndex` method may be used.