Skip to content

Commit

Permalink
[9.x] Remove Doctrine DBAL from prerequisites of renaming/dropping co…
Browse files Browse the repository at this point in the history
…lumn (#8396)

* remove Doctrine DBAL from prerequisites of renaming/dropping column

* formatting

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
hafezdivandari and taylorotwell committed Dec 15, 2022
1 parent 21b95cd commit eb58fb2
Showing 1 changed file with 24 additions and 7 deletions.
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

0 comments on commit eb58fb2

Please sign in to comment.