A migration means a set of persistent changes to the application environment
that is shared among different developers. For example, in an application
backed by a database, a migration may refer to a set of changes to
the database, such as creating a new table, adding a new table column.
This command provides support for tracking the migration history, upgrading
or downloading with migrations, and creating new migration skeletons.
The migration history is stored in a database table named
as [[migrationTable]]. The table will be automatically created the first time
this command is executed, if it does not exist. You may also manually
create it as follows:
~~~
CREATE TABLE migration (
version varchar(180) PRIMARY KEY,
apply_time integer
)
~~~
Below are some common usages of this command:
~~~
# creates a new migration named 'create_user_table'
yii migrate/create create_user_table
# applies ALL new migrations
yii migrate
# reverts the last applied migration
yii migrate/down
~~~
addMigrationHistory()
защищенный Метод
createMigrationHistoryTable()
защищенный Метод
Creates the migration history table.
getMigrationHistory()
защищенный Метод
removeMigrationHistory()
защищенный Метод
$fields публичное свойство
column definition strings used for creating migration code.
The format of each definition is COLUMN_NAME:COLUMN_TYPE:COLUMN_DECORATOR. Delimiter is ,.
For example, --fields="name:string(12):notNull:unique"
produces a string column of size 12 which is not null and unique values.
Note: primary key is added automatically and is named id by default.
If you want to use another name you may specify it explicitly like
--fields="id_key:primaryKey,name:string(12):notNull:unique"