且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从 Yii 或 Laravel 中的现有数据库生成迁移

更新时间:2023-12-01 09:04:28

在 Yii 中完成此操作的说明:

Instructions for accomplishing this in Yii:

  1. 将您的数据库连接设置添加到 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.