mariadb 未创建Laravel 9迁移ForeginKey

7uhlpewt  于 2022-11-08  发布在  其他
关注(0)|答案(1)|浏览(114)

我在Laravel 9的迁移中遇到了一些问题。在我运行了“php artisan migrate”命令后,每个表都创建了索引。所以除了foregin键以外,一切都很好。我不知道为什么,也许有人知道是什么原因导致了这个问题,或者有一个解决方案。谢谢大家!
10.4.22-MariaDB
创新数据库
Apache/嵌入式软件开发(Win 64)PHP/8. 1. 2
php我的管理员:5.11.1
我的迁移:

Schema::create('supplier_orders', function (Blueprint $table) {
    $table->increments('Id');
    $table->unsignedBigInteger('Warehouse', false)->nullable(false);
    $table->unsignedBigInteger('Supplier', false)->nullable(false);
    $table->dateTime('StartedAt')->nullable(false)->useCurrent();
    $table->dateTime('CompletedAt')->default(null);
    $table->string('PrimeVoucherNumber', 100)->nullable(false);
    $table->index(['CompletedAt', 'Warehouse', 'Supplier'], 'CompletedWarehouseSupplier');
});

Schema::create('supplier_order_details', function (Blueprint $table) {
    $table->increments('Id');
    $table->unsignedInteger('SupplierOrder', false)->nullable(false);
    $table->unsignedBigInteger('Employee', false)->nullable(false);
    $table->unsignedBigInteger('Product', false)->nullable(false);
    $table->unsignedDecimal('Quantity', 18, 4)->nullable(false);
    $table->index(['SupplierOrder', 'Employee', 'Product'], 'OrderEmployeeProduct')->unique();
    $table->index(['Product', 'SupplierOrder', 'Quantity'], 'ProductOrder');
    });

Schema::table('supplier_order_details', function (Blueprint $table) {
    $table->foreign('SupplierOrder', 'FK_SupplierOrderDetail_SupplierOrder')->references('Id')->on('supplier_orders')->onDelete('CASCADE')->onUpdate('NO ACTION');
});
jqjz2hbq

jqjz2hbq1#

我找到了,没有错误的迁移,只有我。
我只是一头大驴子。
我在phpmyadmin的“表-〉结构-〉关系视图”下找到了它
我想我会在“表-〉结构-〉表结构-〉索引”下找到它
我不明白为什么它在那里,但最后我找到了它。
谢谢大家。

相关问题