I’ve just started using migrations for my new project. Everything seems to be great but the content of methods safeDown() or down() is confusing me.
In the guide you’ve written:
This is in general of course an important advice, but the example is misleading. Why should I even care to write a code for deleting a row from a table, when the table is about to be dropped anyway?
The same applies for removing indexes. If I create a migration from the command line, there is a code for removing indexes before dropping the table. Why? The index is of course removed, when the table is dropped.
I believe the same applies for the foreign keys as well – they don’t need to be removed manually, if I keep the right order of dropping tables - the last tables goes first.
Is it possible, that your statement is true only for Mysql? I’ve just tried to create a test table with fkey restricted for delete/update, insert a linked entry and then drop the table, and everything worked well in Postgre 9.x. I suppose, that I should use dropping the fkeys in case, a different db then PG is used.
[/size]
Is it really a good practise? The table is complete only with all indexes and foreign keys. I thought that one migration should solve one whole “entity”, which table without indexes and keys isn’t.
I don’t see here any advantage.
I do not. The migrations solves this for me. The later one runs first when doing reverting.