Skip to content
Advertisement

Refactor database schema on migration

This is my initial migration

JavaScript

Now, the easy time ended and now I have to move name and phone to customer table. This is my create customer migration. I don’t know where to do this operation so I just throw all in the migration.

JavaScript

And alter order migration

JavaScript

Now I’m stuck with empty customer_id. I have no clue what to do next, except manually insert it by referring to two table, which can take too much time to update hundreds of rows.

Advertisement

Answer

Try use this statement on up function.

JavaScript

And you might want to drop those two column. Throw this too.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement