Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

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.
0

Cool~ Thank you !

0

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

0

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 ?

Thanks

0

@luis02lopez The up() method is called when you do the php artisan migrate command, and the down() method is called when you do the php artisan migrate:rollback command. Check out the docs: https://laravel.com/docs/5.4/migrations

Last updated 6 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

gclove gclove Joined 24 Nov 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.