Skip to content

Creates individual migration files from a MYSQL DB

Notifications You must be signed in to change notification settings

hzhihu/laravel5_migrated

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

laravel5_migrated

Creates individual migration files from a MYSQL DB

基于laravel5.1把mysql数据库表信息转换成laravel框架迁移文件。方便快速开发。

本脚本是从laravel5-migrate-mysql而来,并修复了如下问题:

  • 修复enum字段类型,无法识别问题。
  • 增加复合主键功能转换。
  • 增加索引和复合索引转换。
  • 增加字段注释文字转换。

###安装

  1. Copy Makesqltomigration.php 文件到 app\Console\Commands
  2. 增加 'App\Console\Commands\MakesqltoMigration' 到 app\Console\Kernel.php的$commands 数组里。
class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        'App\Console\Commands\MakesqltoMigration',
    ];

###如何使用?

** 转换整个库 **

php artisan make:sqltomigrations dbName

** 转换整个库,包括字段注释 **

php artisan make:sqltomigrations dbName -C

** 只转换指定的表 **

php artisan make:sqltomigrations dbName --only=table1,table2 -C

** 转换整个库,忽略指定的表 **

php artisan make:sqltomigrations dbName --ignore=table1,table2 -C

** 执行转换好的迁移 **

```php artisan migrate --path=database/migrations/`date +%Y-%m-%d````

###BUG反馈

email: [email protected]

About

Creates individual migration files from a MYSQL DB

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages