Database: Migrations. Renaming Tables With Foreign Keys

Database: Migrations. Renaming Tables With Foreign Keys

Modifying Columns

Prerequisites

Before changing a line, make sure to include the doctrine/dbal dependency to your composer.json file. The Doctrine DBAL collection is employed to look for the state that is current of line and produce the SQL queries needed seriously to result in the needed alterations:

Upgrading Column Characteristics

The alteration technique enables you to change type and attributes of existing columns. For instance, you may want to raise the size of a sequence line. To understand modification technique for action, why don’t we boost the size associated with title line from 25 to 50:

We’re able to additionally change a line become nullable:

Renaming Columns

To rename a line, you may make use of the renameColumn technique regarding the schema builder. Before renaming a line, make sure to include the doctrine/dbal dependency to your composer.json file:

Renaming an enum column just isn’t presently supported.

Dropping Columns

To drop a line, utilize the dropColumn technique regarding the schema builder. Before dropping columns from A sqlite database, you need to include the doctrine/dbal dependency to your composer.json file and run the composer upgrade demand in your terminal to set up the collection:

You could drop columns that are multiple a dining table by moving a myriad of line names to your dropColumn technique:

Dropping or changing multiple columns in just a solitary migration while utilizing a SQLite database is certainly not supported. Devamını Oku