Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create an initial CodeIgniter db migration from .sql?

I have a CodeIgniter application and I just learned about migrations. It sounds very useful and I would like to start using it. However I already have a rather complex database setup. Can someone suggest a reasonable way to create a reliable initial migration from my MYSQL .sql schema file?

It seems excessive to manually recreate the entire db with dbforge, but perhaps that's what I ought to do.

like image 981
Jordan Eldredge Avatar asked Mar 13 '13 06:03

Jordan Eldredge


People also ask

How do I create a SQL migration file?

To create a script file containing the DDL statements used to perform the migration, select the Generate SQL checkbox in the Run dialog box when you execute the migration. In the text-entry field next to the checkbox, type the name of the file to which you want the script written.

How do you run a migration in CI?

The database table migration tracks which migrations have already been run so all you have to do is update your application files and call $this->migration->current() to work out which migrations should be run. The current version is found in application/config/migration. php.


1 Answers

Bit late reply, but I hacked a quick library that should generate the base migration file for you from your current DB. Its still beta, but works on my systems 40 tables+

https://github.com/liaan/codeigniter_migration_base_generation

L:

like image 98
Karman De Lange Avatar answered Oct 29 '22 03:10

Karman De Lange