Skip to content

Instantly share code, notes, and snippets.

@nabeeljaved
Created September 19, 2017 17:04
Show Gist options
  • Save nabeeljaved/0aa7b52fc0a3f365ea2a46d2d2c2defe to your computer and use it in GitHub Desktop.
Save nabeeljaved/0aa7b52fc0a3f365ea2a46d2d2c2defe to your computer and use it in GitHub Desktop.

Revisions

  1. nabeeljaved created this gist Sep 19, 2017.
    11 changes: 11 additions & 0 deletions Yii2 Initiate Migration
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@


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

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

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

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

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