Download the PHP package insolita/yii2-migration-generator without Composer
On this page you can find all versions of the php package insolita/yii2-migration-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-migration-generator
Migration Generator
- generate migration files (not dumps!) with indexes, and foreign keys, for one table, comma separated list of tables, by part of table name, for all tables by
- generate migrations based on table data - in two ways - as batchInsert Query or as insert via model
- generate migrations based on PHPDOC and model properties
CHANGELOG
Installation
NOTE : Use 2.x versions for yii <=2.0.13
The preferred way to install this extension is through composer.
Either run
or add
to the require-dev section of your composer.json
file.
Just install, go to gii and use (By default composer bootstrap hook)
ANNOTATION SYNTAX
In general the syntax of column definitions is based on style of yii-migration, only separated by "|" and provide a little more opportunities for reducing code
- as you see in examples - empty brackets not necessary
- also shortcut expr() will be replaced to defaultExpression() and default() to defaultValue
You can add annotations in your model(not necessary AR or yii\base\Model or Object or stdClass)
@db (db2)
- specify connection id required for migration 'db' - by default"
@table ({{%my_table}})
- specify table for migration"
Supported column annotations:
-
As separate annotation above class or above current variable
- As addition to @property or @var definition
Customizing
Use Own templates
Copy default templates from folders
vendor/insolita/yii2-migration-generator/gii/default_structure //schema migrations
vendor/insolita/yii2-migration-generator/gii/default_data //data migrations
to some project directory, for example
@backend/gii/templates/migrator_data;
@backend/gii/templates/migrator_schema;
Change gii configuration like this
Use own resolver for definition of columns
- create new class, inherited from \insolita\migrik\resolver*ColumnResolver
- override required methods, or create methods for exclusive columns based on database types - see insolita\migrik\resolver\BaseColumnResolver resolveColumn() phpdoc and realization
Use own resolver for definition of indexes or relations
- create new class, inherited from \insolita\migrik\resolver\TableResolver
- in bootsrap your apps add injection