Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel/lumen 5.2 generate migration tables from existing database

Is possible to generate migration schema from existing database in lumen/laravel 5.2 ? is there any package?

I connect lumen to magento database, now I need to use eloquent. I dont have time to make migration model for every table.

like image 600
Adnan Avatar asked Apr 27 '16 10:04

Adnan


2 Answers

You can dump database first with mysqldump tool to the sql file and then in your migration you can do somethink like this:

public function up()
{
    $path = 'path_to_sql/dump.sql';
    DB::unprepared(file_get_contents($path));
}
like image 121
Filip Koblański Avatar answered Oct 14 '22 13:10

Filip Koblański


Some easy way I found:

  • Install the last version of Laravel and create a project named 'migratedb'
  • Set the env database to the one you want to migrate
  • Install the Xethron library to create migrations, https://github.com/Xethron/migrations-generator and follow the instructions
  • Install the Iseed library to create reverse migrations, https://github.com/orangehill/iseed and follow the intstructions
  • Copy the content from database/migrations and database/seeds from Laravel 'migratedb' to your Lumen project
like image 1
Jorge Solis Avatar answered Oct 14 '22 13:10

Jorge Solis