Snapshot with dependencies
I'm getting into a bit of trouble with the order in which things are being deposited into the migration file.
For example, a snapshot I just produced created the constraints array BEFORE the tables array because a table that was processed was not new and only had a column change. This causes an 'alter' section to be created, not a table section. Then constraints were processed on the table, creating the 'table' section. Then finally the tables were processed creating the 'tables' section.
When we run the migrate replay, everything is done in the order in which it exists in the file. This is on purpose so that the order can be defined specifically. However, because the snapshot messed things up, constraints were attempted to be created on tables that did not yet exist.
This will be fixed in stages.
Stage 1
Define a specific order in the $changes
array. So do 'drop' first, which removed things such as constraints and tables. Then 'alter' next. Then 'create' using the order of 'tables', 'constraints', 'indexes'.
Stage 2
We will need some form of intelligent dependency management. That way we can generate a migration file that will replay things in the correct order. So if we are creating a constraint, we can be assured that the table it is referencing has been created.