/yii-migrate

Simple package to add database migrations to project

Primary LanguagePHP

yii-migrate

Simple package to add database migrations to project

Installation

  • Add to composer.json:

    "require": {
    "grundik/yii-migrate": "*@dev"
    },
    "repositories": [{
    "type": "vcs",
    "url": "https://github.com/Grundik/yii-migrate.git"
    }, {
    "type": "vcs",
    "url": "https://github.com/yiisoft/yii.git"
    }]
    

  • Run composer:

    composer update

  • Create configuration file:

    cp vendor/grundik/yii-migrate/config/migrations.php-default config/migrations.php
  • Edit configuration file to fulfill your needs: set database credentials, migrations path

  • Run

    • vendor/bin/migrate - to perform migrate;
    • vendor/bin/migrate create - to create new migration.

See also: http://www.yiiframework.com/doc/guide/1.1/en/database.migration

Modules

To use multiple migration folders (e.g. for multiple project modules), define them in migrations.php as explained in example config.

Use parameter --module=<module_name> to perform action in explicit module:

vendor/bin/migrate create migration_name --module=module_name

Migrate without parameters will apply all new migrations from all modules.

Module migrations are applied in order of their creation, regardless of module.