How do I run migrations for a specific environment in laravel

后端 未结 4 1192
忘了有多久
忘了有多久 2021-02-05 04:57

I\'m setting up a new app with laravel (Laravel 4), and having some issues setting up the database via migrations.

I made a migration file with:

artisan          


        
4条回答
  •  不知归路
    2021-02-05 05:40

    If you modify a migration after running it, you first need to rollback the migration.

    php artisan migrate:rollback
    

    Keep running that until the migration you've changed is rolled back. Alternatively, you can reset your entire schema with

    php artisan migrate:reset
    

    But you will then need to call your migrations like normal to bring them up to date.

    php artisan migrate
    

    Finally you can reset and then migrate by calling

    php artisan rebuild
    

    Also note that it is generally bad practice to modify your migrations after they have been made, unless you literally just made it. Once it is deployed you should not modify it, and instead create a new migration file.

    Hope this helps.

    Edit: I somehow missed the Laravel 4 indicator. Most of these commands still work I believe, but you may need to adjust.

提交回复
热议问题