更新时间:2023-12-01 09:04:28
在 Yii 中完成此操作的说明:
Instructions for accomplishing this in Yii:
将您的数据库连接设置添加到 protected/config/console.php
.
运行 yiic migrate create initial
为迁移创建存根代码.
Run yiic migrate create initial
to create the stub code for the migration.
将 this gist 的内容复制到 protected/commands/InitialDbMigrationCommand.php
.
Copy contents of this gist to protected/commands/InitialDbMigrationCommand.php
.
运行 yiic initialdbmigration 'name_of_your_database' >initial_migration.php
生成用于初始数据库迁移的 up()
和 down()
方法.
Run yiic initialdbmigration 'name_of_your_database' > initial_migration.php
to generate up()
and down()
methods for initial database migration.
将 initial_migration.php
中的 up()
和 down()
方法复制并粘贴到 中创建的文件中>protected/migrations
步骤 2 中的文件夹.
Copy and paste up()
and down()
methods from initial_migration.php
to the file created in the protected/migrations
folder in step 2.