Download the PHP package crudschool/yii2-migration-generator without Composer
On this page you can find all versions of the php package crudschool/yii2-migration-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download crudschool/yii2-migration-generator
More information about crudschool/yii2-migration-generator
Files in crudschool/yii2-migration-generator
Package yii2-migration-generator
Short Description Set of gii tools for generating files for migration by schema of table , phpdoc or table data
License MIT
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
Installation
The preferred way to install this extension is through composer.
Either run
or
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/crudschool/yii2-migration-generator/gii/default_structure //schema migrations
vendor/crudschool/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 \crudschool\migrik\resolver*ColumnResolver
- override required methods, or create methods for exclusive columns based on database types - see crudschool\migrik\resolver\BaseColumnResolver resolveColumn() phpdoc and realization
Use own resolver for definition of indexes or relations
- create new class, inherited from \crudschool\migrik\resolver\TableResolver
- in bootsrap your apps add injection