Laravel 5.4 Specific Table Migration

前端 未结 21 1380
梦如初夏
梦如初夏 2020-12-07 10:38

Hi read all the included documentation here in https://laravel.com/docs/5.4/migrations.

Is there a way on how to migrate a certain migration file (1 migration only),

相关标签:
21条回答
  • 2020-12-07 10:45

    You can only rollback:

    php artisan migrate:rollback
    

    https://laravel.com/docs/5.4/migrations#rolling-back-migrations

    You can specify how many migrations to roll back to using the 'step' option:

    php artisan migrate:rollback --step=1
    

    Some tricks are available here:

    Rollback one specific migration in Laravel

    0 讨论(0)
  • 2020-12-07 10:45

    First you should to make the following commands:

    Step 1:

    php artisan migrate:rollback
    

    Step 2:

    php artisan migrate
    

    Your table will be back in database .

    0 讨论(0)
  • 2020-12-07 10:46

    Delete the table and remove its record from migration table.

    After that you just run migration again:

    php artisan migrate
    
    0 讨论(0)
  • 2020-12-07 10:46

    You can use this.

    -> https://packagist.org/packages/sayeed/custom-migrate

    -> https://github.com/nilpahar/custom-migration/

    this is very easy to use

    0 讨论(0)
  • 2020-12-07 10:47

    if you use tab for autocomplete

    php artisan migrate --path='./database/migrations/2019_12_31_115457_create_coworking_personal_memberships_table.php'
    
    0 讨论(0)
  • 2020-12-07 10:49

    Just wanted to post another solution, which i think is worth mentioning.

    1. Find row with your migration name in migrations table and DELETE it. It should look like this: 2016_06_01_000001_create_oauth_auth_codes_table
    2. Remove your table from database e.g. DROP TABLE oauth_auth_codes
    3. Run php artisan migrate

    It will migrate only the table you need, and won't touch anything else

    0 讨论(0)
提交回复
热议问题