Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Remove Doctrine DBAL from prerequisites of renaming/dropping column #8396

Merged
merged 2 commits into from
Dec 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 24 additions & 7 deletions migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -1056,21 +1057,31 @@ 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).

<a name="renaming-columns"></a>
#### 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:

Schema::table('users', function (Blueprint $table) {
$table->renameColumn('from', 'to');
});

> **Warning**
> Renaming an `enum` column is not currently supported.
<a name="renaming-columns-on-legacy-databases"></a>
#### 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:

<div class="content-list" markdown="1">

- MySQL < `8.0.3`
- MariaDB < `10.5.2`
- SQLite < `3.25.0`

</div>

<a name="dropping-columns"></a>
### 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:

Schema::table('users', function (Blueprint $table) {
$table->dropColumn('votes');
Expand All @@ -1082,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**
> Dropping or modifying multiple columns within a single migration while using an SQLite database is not supported.

<a name="dropping-columns-on-legacy-databases"></a>
#### 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.

<a name="available-command-aliases"></a>
#### Available Command Aliases
Expand Down Expand Up @@ -1167,6 +1181,9 @@ 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.

<a name="dropping-indexes"></a>
### Dropping Indexes

Expand Down