Home>
Current state
id Migration file up down
1 create_foo_table.php Create tablefoo Delete tablefoo
2 create_bar_table.php Create tablebar Delete tablebar
To delete all data

If I want to delete only the tablefoofrom the current state, the procedure is

  1. All rollback
  2. Deletecreate_foo_table.php
  3. Execute migration
Is it correct with

?

If I want to keep the table data you do n’t want to delete

To delete the tablefoofrom the current state and keep the data of the tablebar

  1. Migration filedrop_foo_table.phpthat reversesupanddownprocessing ofcreate_foo_table.phpCreate
  2. Execute migration
id Migration file up down
1 create_foo_table.php Create tablefoo Delete tablefoo
2 create_bar_table.php Create tablebar Delete tablebar
3 drop_foo_table.php Delete tablefoo Create tablefoo
Is it correct with

?


  • I would like to know if there are any inconveniences caused by these procedures, or more general and better procedures.
  • I'll post it because I couldn't find a sentence about this even if I googled it lightly.
  • Answer # 1

    Both are procedurally good, but if you do the "roll all" formula,all rollback "in all environments using the same source codeMust be run.

    There are practically no cases where you can erase all the data in other tables, and there are many cases that incorporate settings such as "Migrate also when updating". "Migrating to delete" is overwhelmingly more.

  • Answer # 2

    The way of thinking depends on people and the environment they belong to, so there is no right answer, but personally

    Click here if it was before release

      

    When deleting all data

    Click here after release

      

    If you want to keep the data of the table that will not be deleted