Laravel 5.4 Specific Table Migration

前端 未结 21 1381
梦如初夏
梦如初夏 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:52
    php artisan help migrate
    

    You will see the option:

    --path[=PATH] The path to the migrations files to be executed

    By the way, you can probably indicate the root folder of the file that you want to migrate:

    php artisan migrate --path=/database/migrations/sample.php
    

    Or, You can create a new folder in migrations, then migrate all the migration files you want inside it:

    php artisan migrate --path=/database/migrations/new_folder
    
    0 讨论(0)
  • 2020-12-07 10:53

    You could try to use the --path= option to define the specific sub-folder you're wanting to execute and place specific migrations in there.

    Alternatively you would need to remove reference and tables from the DB and migrations tables which isn't ideal :/

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

    install this package

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

    and run this command.

    php artisan migrate:custom -f migration_name
    
    0 讨论(0)
  • 2020-12-07 10:55

    you should add the path to your migration file to refresh just this table and run

    php artisan migrate:refresh --path=/database/migrations/fileName.php
    
    0 讨论(0)
  • 2020-12-07 10:57

    You can only run this command in your terminal

    php artisan migrate --path=database/migrations/2020_10_01_164611_create_asset_info_table.php
    

    After migrations you should put the particular file name. or if you have any folder inside migration then just add that folder name after the migration.

    Like this

    php artisan migrate --path=database/migrations/yourfolder/2020_10_01_164611_create_asset_info_table.php
    

    I hope this will help you a lil bit. Happy Coding.

    0 讨论(0)
  • 2020-12-07 11:00

    You need to put the file(s) into a new directory (ex:selected) and then apply

    php artisan migrate  --path=/database/migrations/selected
    

    if you need rollback:

    php artisan migrate:rollback  --path=/database/migrations/selected
    

    Note:

    php artisan migrate:refresh
    

    this will rollback and then migrate all the migrations files in the default directory (/database/migrations)

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