How to update database table when change the Migration ?

If I change the Migration Structure (such like CreatePasswordResetsTable)

How I to change the database table ?

php artisan migrate:refresh will Delete my original data....

  • 1 year ago

You don't change migrations. Every time you need to change the database you create a new migration, that's the point about them.

So for example:

  • You create your initial tables and run php artisan migrate
  • The next day you notice you forgot the field "status" in one of the tables. So you create a NEW migration called "add_status_to_table" (for example, the name is not important of course :)) and you add the field in the up() method and remove it in the down() method (that's important if you want to be able to roll back the migration). Now you run php artisan migrate again.
  • Two weeks later you notice that you need a new table (or field) for a functionality. Again you run php artisan make:migration to create a NEW migration, change the database and run php artisan migrate.

Cool~ Thank you !

There is no way to delete rows in the migrations table?

Hello @ftiersch What do you refer when you said: creat with up() method and remove with down() method? Are you talking about the:

php artisan up php artisan down ?