I have a table of Products and one of ProductGroups to categorize them. Now the ProductGroups will be removed and their data merged into the Products table.
I made a migration that loops through the existing ProductGroup records and adds them as Products. This so we don't have to re-enter hundreds of groups manually. Afterwards the product_groups table is dropped.
Then I removed the ProductGroup model, controllers and so on and committed the changes.
This all worked fine in development, but obviously if I now update the production application it will first apply the file system changes (removing the ProductGroup model etc.) and the migration will fail because the model no longer exists.
What is the best way to solve this? Should I not have put the data transfer in a migration? It feels like catch-22.