Change execution order of Laravel Migrations

I have some problems described in "General error: 1005 Can't create table" Using Laravel schema assembly and foreign keys

I understand why errors are happening - my current migration order does not create my parent tables in front of the children, so my foreign keys are all messed up because their tables don't exist. But it seems a bit hacky (and awkward) to reorder migrations by randomly changing the timestamps of each migration to force them to execute in the correct order.

2015_06_29_191903_create_child_table
2015_07_06_144544_create_parent_table

      

Is there a good Artisan tool for changing the order in which migrations are applied? I didn't find anything online, but people just put up fake timestamps in the order they want.

+3


source to share


1 answer


You can manually change the transfer date and therefore the transfer order, but it is NOT RECOMMENDED. This will mess up your migration table and get migration errors: rollback and so on. If this is not too much of a pain, and there is no data in the DB, discard it, change the order of changing migrations and transfer everything fresh.



+2


source







All Articles