laravel - 错误的迁移称为
问题描述
我有 2 个迁移,第一个具有以下名称2019_11_06_171637_create_settings_table.php
和结构:
class CreateSettingsTable extends Migration
{
public function up()
{
Schema::create('settings', function (Blueprint $table) {
//code
});
}
//function down
}
第二个具有以下名称2020_07_08_246856_create_settings_table.php
和结构:
class CreateAnotherSettingsTable extends Migration
{
public function up()
{
Schema::create('another_settings', function (Blueprint $table) {
//code
});
}
//function down
}
当我运行php artisan migrate
所有迁移顺利时,直到Migrating: 2020_07_08_246856_create_settings_table
- 它试图运行 previos migration( 2019_11_06_171637_create_settings_table.php
) 并触发异常Table 'settings' already exists
。
这是否意味着迁移文件的名称在日期和数字之后必须是唯一的?
解决方案
我在某处读到 Laravel 使用迁移的文件名来调用迁移的正确类。我试图查找有关此的一些文档或参考,但我再也找不到了。您当前有两次相同的文件名(如果您忽略时间戳部分),这会导致 Laravel 两次调用同一个类。
如果您将第二个文件(具有 CreateAnotherSettingsTable 类的文件)重命名为2020_07_08_246856_create_another_settings_table.php
,您的问题将得到解决。
推荐阅读
- scala - scala - for 循环中的 if/else
- python - Python - 使用 iGraph 绘制节点层次结构
- ssas - 如何仅为新事实或更新维度安排 SSAS 多维数据集刷新?
- sql - SQL 以单行为轴来为数据创建新的列名
- r - 如何使用 TraMineR 将噪声引入序列数据?
- python - 如何按顺序获取路径名、子目录名和文件列表?
- javascript - 在页面加载时获取选中复选框的 id
- r - 如何在与完整数据集相同的图表上绘制数据子集?
- angularjs - 如何在同一控制器中使用角度将 sq-lite 获取数据的一个函数返回到另一个函数以进行加载
- jboss7.x - EAP 7.1 与 Elytron - SAMLv2