esempla/yii2tech-dump-migration

从现有数据库生成模式

安装: 208

依赖者: 1

建议者: 0

安全: 0

类型:yii2-extension

0.1.7 2019-02-26 11:42 UTC

This package is auto-updated.

Last update: 2024-09-18 00:01:24 UTC


README

从现有数据库生成数据迁移文件。此模块由Esempla基于 https://github.com/bizley/yii2-migration 重写。此模块为内部使用而设计,可自由使用,公司不对它提供任何保证。

对于原始包,请尝试

github: https://github.com/Hzhihua/yii2-dump
oschina: http://git.oschina.net/hzhihua/yii2-dump

演示

yii2-dump

测试环境

  • PHP >=7.1.0
  • PGSQL(<9.*)

安装

composer require --prefer-dist "esempla/yii2tech-dump-migration:0.1.0"

配置

在控制台/config/main.php 中添加以下内容

简单配置

return [
    'dump' => [
         'class' => 'esempla\\yii2tech_dump_migration\\DumpController',
         'db' => 'db1', // Connection
         'generateFilePath' =>'@app/migrations/test/data',
         'limit' => '0,1000', // select * from tableName limit 0,1000
     ],
];

默认限制

0,1000

默认过滤表

migration

简单用法

运行 dump 命令。

cd /path/to/your-project
./yii dump   -type=1 --db='db1' # default action: generate, it will gerate migration file

命令

生成所有表迁移文件,但只有一些数据在 0 和 10 之间

./yii dump -limit=10   -type=1 --db='db1' 

仅生成 table1,table2 迁移文件

./yii dump -table=table1,table2  -type=1 --db='db1'