Xethron / migrations-generator

Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.
MIT License
3.33k stars 586 forks source link

Export should account for the prefix #22

Open cjthomp opened 10 years ago

cjthomp commented 10 years ago

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.

Xethron commented 10 years ago

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

adrianthedev commented 9 years ago

+1

ghost commented 9 years ago

When is this going to be resolved?

chrisiek commented 8 years ago

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

Tucker-Eric commented 8 years ago

Just submitted pull request for this.

ccondrup commented 8 years ago

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.