Generating migration from existing database in Yii or Laravel

后端 未结 9 899
南方客
南方客 2021-01-31 05:39

I\'m working on a project that has a fairly complex database (150+ tables). In order to be able to maintain changes, I\'ve decided to add migrations, preferably using Yii or Lar

9条回答
  •  后悔当初
    2021-01-31 06:19

    Instructions for accomplishing this in Yii:

    1. Add your database connection settings to protected/config/console.php.

    2. Run yiic migrate create initial to create the stub code for the migration.

    3. Copy contents of this gist to protected/commands/InitialDbMigrationCommand.php.

    4. Run yiic initialdbmigration 'name_of_your_database' > initial_migration.php to generate up() and down() methods for initial database migration.

    5. Copy and paste up() and down() methods from initial_migration.php to the file created in the protected/migrations folder in step 2.

提交回复
热议问题