migrations-generator
migrations-generator copied to clipboard
Export should account for the prefix
The export process grabs the tables exactly as they are in the db. So, if you have a prefix set, when you run the migration again you'll have prefix__prefix__tablename
which breaks all kinds of stuff.
Since the prefix is set on the database configuration, it should be removed from the table names when exporting.
I have seen this problem before. Its definitely something that can and should be fixed!
+1
When is this going to be resolved?
The same question: When is this going to be resolved?
Just submitted pull request for this.
Couple gotchas with current implementation after Pull #69:
- I have set the prefix 'df_'. Currently that string length of 3 is also removed from other tables which do not have the prefix. I have a table named 'vip' which ended up with a blank name in the migration file. Of course not a best practice to have tables from different systems in the same DB, but it would be nice if this tool checked for the existence of the actual prefix before removing that amount of characters.
- The prefix is not removed from the ::drop() call in the down() method. Intended? The prefix also remains in the generated migration file name (and FK commands?)
Edit: I created Pull #75 as a possible fix for these issues, please review. I found it a bit confusing which branch to actually base this on.