migrations-generator icon indicating copy to clipboard operation
migrations-generator copied to clipboard

Export should account for the prefix

Open cjthomp opened this issue 10 years ago • 6 comments

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.

cjthomp avatar Jul 25 '14 05:07 cjthomp

I have seen this problem before. Its definitely something that can and should be fixed!

Xethron avatar Jul 27 '14 12:07 Xethron

+1

adrianthedev avatar Jan 29 '15 14:01 adrianthedev

When is this going to be resolved?

ghost avatar Jun 14 '15 11:06 ghost

The same question: When is this going to be resolved?

chrisiek avatar Dec 27 '15 21:12 chrisiek

Just submitted pull request for this.

Tucker-Eric avatar Mar 29 '16 19:03 Tucker-Eric

Couple gotchas with current implementation after Pull #69:

  1. 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.
  2. 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.

ccondrup avatar May 25 '16 15:05 ccondrup