Recommend this page to a friend! |
Download .zip |
Info | Documentation | View files (51) | Download .zip | Reputation | Support forum | Blog (1) | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2022-09-15 (2 months ago) | Not yet rated by the users | Total: 18 This week: 1 | All time: 10,764 This week: 491 |
Version | License | PHP version | Categories | |||
yii2-migrik 1.0 | MIT/X Consortium ... | 5 | PHP 5, Databases, Utilities and Tools |
- 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
NOTE : Use 2.x versions for yii <=2.0.13
The preferred way to install this extension is through composer.
Either run
composer require --dev --prefer-dist insolita/yii2-migration-generator:~3.1
or add
"insolita/yii2-migration-generator": "~3.1"
to the require-dev section of your composer.json
file.
Just install, go to gii and use (By default composer bootstrap hook)
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
/
* @column (name) string|notNull|default('SomeValue')
*/
- As addition to @property or @var definition
/
* @var int $id @column pk()
*/
public $id;
/
* @var string $route @column string(100)|notNull()
*/
public $route;
/
* @property integer $id @column pk|comment("Id")
* @property string $username @column string(100)|unique|notNull|default("Vasya")
* @property string $email @column string(200)|unique()|defaultValue("123@mail.ru")
* @property string $password @column string(200)|notNull|expr(null)
* @property string $created_at @column string(200)|notNull|expr('CURRENT_TIMESTAMP')
*/
class TestModel extends ActiveRecord{
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
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', 'localhost', '::1'],
'generators' => [
'migrik' => [
'class' => \insolita\migrik\gii\StructureGenerator::class,
'templates' => [
'custom' => '@backend/gii/templates/migrator_schema',
],
],
'migrikdata' => [
'class' => \insolita\migrik\gii\DataGenerator::class,
'templates' => [
'custom' => '@backend/gii/templates/migrator_data',
],
],
],
];
- 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
- create new class, inherited from \insolita\migrik\resolver\TableResolver - in bootsrap your apps add injection
Files |
File | Role | Description | ||
---|---|---|---|---|
contracts (4 files) | ||||
gii (7 files, 3 directories) | ||||
resolver (8 files) | ||||
tests (5 files, 4 directories) | ||||
Bootstrap.php | Class | Class source | ||
CHANGELOG.md | Data | Auxiliary data | ||
codeception.yml | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files | / | contracts |
File | Role | Description |
---|---|---|
IMigrationColumnResolver.php | Class | Class source |
IMigrationTableResolver.php | Class | Class source |
IModelResolver.php | Class | Class source |
IPhpdocResolver.php | Class | Class source |
Files | / | gii |
File | Role | Description | ||
---|---|---|---|---|
default_bymodel (1 file) | ||||
default_data (2 files) | ||||
default_structure (3 files) | ||||
ByModelGenerator.php | Class | Class source | ||
DataGenerator.php | Class | Class source | ||
form_bymodel.php | Example | Example script | ||
form_data.php | Example | Example script | ||
form_structure.php | Example | Example script | ||
GeneratorTrait.php | Class | Class source | ||
StructureGenerator.php | Class | Class source |
Files | / | gii | / | default_data |
File | Role | Description |
---|---|---|
data_batch.php | Example | Example script |
data_model.php | Example | Example script |
Files | / | gii | / | default_structure |
File | Role | Description |
---|---|---|
mass.php | Example | Example script |
migration.php | Example | Example script |
relation.php | Example | Example script |
Files | / | resolver |
File | Role | Description |
---|---|---|
BaseColumnResolver.php | Class | Class source |
FluentColumnResolver.php | Class | Class source |
ModelResolver.php | Class | Class source |
PgFluentColumnResolver.php | Class | Class source |
PgRawColumnResolver.php | Class | Class source |
PhpDocResolver.php | Class | Class source |
RawColumnResolver.php | Class | Class source |
TableResolver.php | Class | Class source |
Files | / | tests |
File | Role | Description | ||
---|---|---|---|---|
data (2 files) | ||||
helpers (1 file, 1 directory) | ||||
migrations (1 file) | ||||
unit (11 files) | ||||
.env.dist | Data | Auxiliary data | ||
bootstrap.php | Example | Example script | ||
config.php | Class | Class source | ||
PrivateTestTrait.php | Class | Class source | ||
unit.suite.yml | Data | Auxiliary data |
Files | / | tests | / | data |
File | Role | Description |
---|---|---|
HistoryItem.php | Class | Class source |
TestModel.php | Class | Class source |
Files | / | tests | / | migrations |
File | Role | Description |
---|---|---|
m170428_223742_test_migration.php | Class | Class source |
Files | / | tests | / | unit |
File | Role | Description |
---|---|---|
bootstrap.php | Aux. | Auxiliary script |
ByModelGeneratorTest.php | Class | Class source |
FluentColumnResolverTest.php | Class | Class source |
GeneratorTraitTest.php | Class | Class source |
ModelResolverTest.php | Class | Class source |
PgFluentColumnResolverTest.php | Class | Class source |
PgRawColumnResolverTest.php | Class | Class source |
PhpdocResolverTest.php | Class | Class source |
RawColumnResolverTest.php | Class | Class source |
TableResolverMysqlTest.php | Class | Class source |
TableResolverPgTest.php | Class | Class source |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.