Generating migration from existing database in Yii or Laravel

后端 未结 9 902
南方客
南方客 2021-01-31 05:39

I\'m working on a project that has a fairly complex database (150+ tables). In order to be able to maintain changes, I\'ve decided to add migrations, preferably using Yii or Lar

相关标签:
9条回答
  • 2021-01-31 06:35

    I use both Yii and Laravel and I could not find what you require for either of them. They both create empty files and you need to create the migration script yourself. For a table of 150 tables it will be challenge to create the migrations yourself, but it is not quite as hard as you imagine. Because you already have the information on the fields it should not take so long to create.

    0 讨论(0)
  • 2021-01-31 06:36

    After doing some research, here's what you're going to need for Laravel: https://github.com/XCMer/larry-four-generator

    (version 4 at least, who knows how long this will work, Laravel changes too fast and has too many breaking changes)

    You'll want to run php artisan larry:fromdb and it'll show you the tables...You can also exclude or only process certain tables (look at the readme).

    Again, super super useful if you like to build your schema in something like MySQL Workbench. I also saw mention of a package that would parse the workbench files...But the link was dead.

    You may also wish to use this larry package with: https://github.com/JeffreyWay/Laravel-4-Generators

    You can then create scaffolding a la CakePHP style.

    Alternatively, try this package: https://github.com/barryvdh/laravel-migration-generator

    0 讨论(0)
  • 2021-01-31 06:37

    There is one now for Yii:

    This allows a distributed team to easily update the db locally and then distribute it's updates with thee other developers automatically with the rest of the code via a versioning control system (I used git). It also performs a full initial db dump to xml and to a migration file.

    project home: https://code.google.com/p/yii-automatically-generated-migration-files/

    source code: https://code.google.com/p/yii-automatically-generated-migration-files/source/checkout

    I've created it from scratch as I was annoyed with the fact that I had to do this manually in order to distribute it to my team.

    Hope it helps!

    Feel free to share bugs, improvements and comments.

    0 讨论(0)
提交回复
热议问题