db-migration
db-migration copied to clipboard
SQLite does not support addForeignKey()
SQLite does not support addForeignKey() but supports foreign key constraints inside columns definitions of CREATE TABLE query.
https://www.sqlite.org/foreignkeys.html
CREATE TABLE track(
trackid INTEGER,
trackname TEXT,
trackartist INTEGER,
FOREIGN KEY(trackartist) REFERENCES artist(artistid)
);
The follow command throws an Exception in SQLite
./yii migrate:create post --command=table --fields='department_id:integer:notNull:foreignKey(department)'
Due to column foreign key is initialized separately
https://github.com/yiisoft/db-migration/blob/940d9885aa17c273d7e3980f9730d220b6830658/resources/views/_createTable.php#L14-L26