laravel - 尝试在不同文件夹中运行两个具有相同名称的迁移时出现问题 Laravel
问题描述
我的迁移中有两个文件夹:
database/migrations/simulator
database/migrations/tasks
在每一个里面我都有一个用户的迁移,比如:create_users_table
.
并且文件夹内的每个迁移都与不同的数据库有不同的连接,例如:
Schema::connection('mysql_simulator')
->create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->rememberToken();
$table->timestamps();
});
问题是: Laravel 不允许我正确运行这些迁移。
当我尝试运行此命令时:php artisan migrate --path="database/migrations/simulator"
该users
表正常迁移,但如果之后我尝试使用tasks
文件夹运行相同的操作:php artisan migrate --path="database/migrations/tasks"
我收到了这个错误:Nothing to migrate.
但是,如果我尝试从tasks
文件夹重置我的迁移:php artisan migrate:reset --path="database/migrations/tasks
它向我表明:
Migration not found: 2021_02_13_194359_create_textures_table
Migration not found: 2021_02_04_224957_create_image_simulation_table
Migration not found: 2021_02_03_192318_create_images_table
Migration not found: 2021_01_29_170555_create_simulations_table
Migration not found: 2021_01_29_170326_create_addresses_table
Migration not found: 2021_01_29_170138_create_phones_table
Migration not found: 2019_08_19_000000_create_failed_jobs_table
Migration not found: 2014_10_12_100000_create_password_resets_table
Migration not found: 2014_10_12_000000_create_users_table
Migration not found: 2021_03_10_213837_create_users_table
基本上,它向我显示了另一个文件夹中的所有表(不是我运行命令的那个)我运行了我的tasks
迁移,但它告诉我我所有的simulator
迁移都没有找到。
所以我不知道正在发生这种情况,似乎 Laravel 正在读取来自不同文件夹的所有迁移,我只需要在不同的文件夹中创建相同的迁移名称并运行它而不会发生冲突,在 Laravel 中是否可能?
解决方案
可能这些是您在成功迁移后从项目迁移目录中删除它们的迁移,当您运行php artisan migrate
Laravel 时,将成功记录在数据库的迁移表中,因此当您删除它们时,会出现此错误,请尝试从中删除它们迁移表也
推荐阅读
- c++ - 为什么 vtkClipPolyData 在 vtk 的表面渲染输出中渲染速度非常慢
- java - Maven Spring Boot 编译失败
- r - 如何找到一个值在 R 数据集中的不同列中出现的实例数?
- delphi - 如何在 fmx delphi 中为 utf8 语言(如波斯语)模拟键盘事件?
- javascript - 通过 html datalist 和 *ngFor 显示一个值并提交另一个值
- google-apps-script - 如何将 onEdit 限制为特定单元格中的更改?
- android - 如何使用 FilePcker.Builder 的相机选项隐藏我正在拍摄的画廊中的图像?
- kubernetes - glusterfs heketi 使用分区而不是原始设备以允许轻松扩展
- php - 发送多封电子邮件时出错,应该只发送一封
- rest - 如果休息端点正在使用外部休息端点,Swagger/其他 API 文档/工具能否提供信息