NOTE: Phalcon migrations have been removed from DevTools and moved to a separate repository.
Package git repository
PHP >= 7.2
Phalcon >= 4.0.5
Installing via Composer
composer require --dev phalcon/migrations
What you need for quick start:
Configuration file in root of your project (you can also pass them as parameters inside CLI environment)
Create database tables structure
Execute command to generate migrations
After that you can execute that migrations (run) in another environment to create same DB structure.
Create configuration file
<?phpusePhalcon\Config;returnnewConfig(['database'=>['adapter'=>'mysql','host'=>'127.0.0.1','username'=>'root','password'=>'','dbname'=>'db-name','charset'=>'utf8',],'application'=>['logInDb'=>true,'migrationsDir'=>'db/migrations','migrationsTsBased'=>true,// true - Use TIMESTAMP as version name, false - use versions'exportDataFromTables'=>[// Tables names// Attention! It will export data every new migration],],]);
Wrap SET FOREIGN_KEY_CHECKS query before and after execution of a query (Running only)
Shows this help
Timestamp based migrations
Using this approach is useful when more than one developer is participating in the database structure management.
Use 'migrationsTsBased' => true in config file or --ts-based option in CLI environment.
Also, you need to specify suffix descr, which could be anything you want, for example: semantic version.
Migrations will be executed from oldest to newest.
NOTE: Whenever migrations are run, the application scans all available migrations and their status irrespective of their “age”. If one or more were not executed in a previous run, they will be executed in the next run.