Codeigniter Migrations + Multiple Tables + One Migration File Per Table Codeigniter Migrations + Multiple Tables + One Migration File Per Table codeigniter codeigniter

Codeigniter Migrations + Multiple Tables + One Migration File Per Table


Yes, you can only have one migration file per version. A migration is not table-specific, but more like "what schema changes are needed to go from version x to version x+1 of my app?"

Combine all of your existing migration files into 1, and name it something like 001_initial_schema.php. Then, when add a new feature, create a new schema file for that feature. If you have a deployment cycle (like weekly SCRUM sprints), it's nice to have one of these migration files per deployment.


According to http://www.codeigniter.com/user_guide/libraries/migration.html, the best way to "version" your migrations is using the YYYYMMDDHHMMSS format. This should effectively overcome versioning issues as expressed. It is also suggested that if the the filename was "201507071208_advertisements.php" that the contained migration class should be called "Migration_Advertisements".