Table renamed but old table remains

Hi all. I renamed a table from automobiles to cars like this:
postgres do
table "cars" # Used to be automobiles
repo MyApp.Repo
end
postgres do
table "cars" # Used to be automobiles
repo MyApp.Repo
end
But now in the database I have both tables instead of one being renamed to the other. What would be the correct way to delete the postgres table without messing anything up?
Solution:
mix ecto.gen.migration gets you a one-off migration
Jump to solution
7 Replies
ZachDaniel
ZachDaniel3w ago
Delete the generated migration contents that creates a new table and replace its contents with a command to rename the table
Yahya Oxley
Yahya OxleyOP3w ago
I messed up and already pushed it to github and to my live server 🙁 obviously this is my bad.. Can I make a new migration to just drop that table?
ZachDaniel
ZachDaniel3w ago
Yep! But you probably want to get the data to the table right? So you could drop the new empty table and then rename the old one to the new one
Yahya Oxley
Yahya OxleyOP3w ago
I dont care about that data, this time 😄 How would I properly create this kind of "one of a kind" migration in Ash properly? I am worried about messing up generators in the future.
Solution
ZachDaniel
ZachDaniel3w ago
mix ecto.gen.migration gets you a one-off migration
Yahya Oxley
Yahya OxleyOP3w ago
thank you very much it wont mess up anything with Ash and the way it tracks things for codegen?
ZachDaniel
ZachDaniel3w ago
Nope

Did you find this page helpful?