Overview
I have an application that uses Doctrine migrations. The application is a software code base used to manage multiple businesses who all use the same code instance in their own unique environments. i.e. Each code base is identical other than configurations.
Mistakes we made
One of the mistakes the dev team made was to include core migrations in the customer folders. i.e. With each new application we have to drop in the migration files or run a migration:diff to get going which I feel is not efficient and can lead to a mess.
What I would prefer is to have core migrations as part of the core code since it rarely changes and custom migrations on the client app side.
What I want to do
- I want to move all core structure migrations to our code files
- I want to have a single custom migration to drop in customised data in the client migration folder.
The problem
The problem I face is pretty much how to reorganize the migrations without breaking databases on existing client applications.
I have thought of two solutions:
Solution 1:
- Add blank migrations as a placeholder for the new migrations I want.
- Commit these to the repo and deploy to our environments.
- They will be run, nothing will be changed, the migraitons table will store them as having been executed.
- Next, Update the blank migrations to the actual code I want, and empty all other migration files. Commit this to the environments.
- Finally - remove the unwanted migration files, remove the unwanted database migration records.
Solution 2
- Change the migration location in the db to a new location
- Remove all migration files and add blank migrations for the new ones I want
- Commit this to the repo, allow to run and record the migrations as being run in the new table.
- Add migration code.
Now all new applications will have the updated migration files and the old apps will have the new migration files...
Question:
Am I re-inventing the wheel? Is there a standard on how to do this as I am certain I am not the first to bump into this problem?