Laravel 5.5 Migration not found on migrate:refresh with --path 选项

Posted

技术标签:

【中文标题】Laravel 5.5 Migration not found on migrate:refresh with --path 选项【英文标题】:Laravel 5.5 Migration not found on migrate:refresh with --path option 【发布时间】:2018-09-12 21:13:32 【问题描述】:

使用 --path 选项运行 migrate:refresh 时,我收到 “未找到迁移”

似乎脚本试图回滚所有迁移,而不仅仅是指定的迁移。

php artisan migrate:refresh --path=packages/package/src/database/migrations

Migration not found: 2016_06_01_000005_create_oauth_personal_access_clients_table
Migration not found: 2016_06_01_000004_create_oauth_clients_table
Migration not found: 2016_06_01_000003_create_oauth_refresh_tokens_table
Migration not found: 2016_06_01_000002_create_oauth_access_tokens_table
Migration not found: 2016_06_01_000001_create_oauth_auth_codes_table
Migration not found: 2014_10_12_100000_create_password_resets_table
Migration not found: 2014_10_12_000000_create_users_table

最后的结果其实还不错。它会刷新指定的文件夹迁移。

【问题讨论】:

【参考方案1】:

migrate:refresh 命令将回滚所有迁移,然后执行 migrate 命令。此命令有效地重新创建整个数据库:

migrate:refresh 将遍历迁移表中的所有迁移以回滚它们。由于您指定了路径,因此它正在查找该路径中的所有迁移。

所以本质上它会抛出错误,因为它无法在您指定的路径中找到那些迁移,但它仍然会按您预期的方式工作,因为它正在回滚并重新运行它确实找到的迁移。

您通常不需要路径选项。通常,您要么发布包的迁移(将它们复制到您的数据库/迁移目录),要么包的服务提供商将定义可以找到迁移的位置。 Refresh 期望回滚所有迁移,而不是特定迁移,因此虽然它在本示例中可能有效,但它不是预期用途。

【讨论】:

以上是关于Laravel 5.5 Migration not found on migrate:refresh with --path 选项的主要内容,如果未能解决你的问题,请参考以下文章

Laravel的Migration 和 Seeder 使用

Uncaught ReferenceError: $ is not defined - Laravel 5.5 + Laravel Mix

Laravel 从 5.5 升级到 5.6 到 5.7:未捕获 ReferenceError: axios is not defined

如何在 laravel 5.5 迁移中将 DB::unprepared() 用于 mysql 函数和存储过程

laravel使用migration创建数据表

laravel在使用GuzzleHttpPsr7Request报错SymfonyBridgePsrHttpMessageFactoryHttpFoundationFactory not f