刷新特定表的 Laravel 迁移

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47170217/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:55:23  来源:igfitidea点击:

Refresh laravel migration for specific table

laravelmigrationmigratelaravel-5.5artisan-migrate

提问by CairoCoder

Can I run php artisan migrate:refreshfor specific table? Or can I refresh specific table migration in general?

我可以php artisan migrate:refresh为特定的表运行吗?或者我可以刷新特定的表迁移吗?

I tried this:

我试过这个:

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

But it's not working!

但它不起作用!

回答by Yoss

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

您应该将路径添加到迁移文件以仅刷新此表并运行

php artisan migrate:refresh --path=/database/migrations/my_migration.php

if you need rollback:

如果您需要回滚:

php artisan migrate:rollback  --path=/database/migrations/my_migration.php

回答by Magige Daniel

This works for me:

这对我有用:

The --tableand --createoptions may also be used to indicate the name of the table and whether the migration will be creating a new table. These options pre-fill the generated migration stub file with the specified table

--table--create选项也可用于指示表,以及是否迁移将创建一个新的表名。这些选项使用指定的表预先填充生成的迁移存根文件

php artisan make:migration create_users_table --create=users
php artisan make:migration add_votes_to_users_table --table=user

Source: https://laravel.com/docs/5.6/migrations

来源:https: //laravel.com/docs/5.6/migrations