Laravel 9迁移未创建

发布于 2025-02-09 07:11:15 字数 1657 浏览 2 评论 0原文

我对Laravel 9迁移有一些问题。运行“ PHP Artisan迁移”命令后,每个用索引创建的表。因此,Everthings可以很好,除了Foregin键。我不知道为什么,也许有人知道是什么原因导致问题或有解决方案。谢谢大家!

10.4.22-mariadb
Innodb
Apache/2.4.52(Win64)OpenSSL/1.1.1M PHP/8.1.2
phpmyadmin: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');
});

I have some problem with the Laravel 9 migrations. After i run the "php artisan migrate" command every table created with the indexes. So everthings just fine except the foregin key. I don't have any idea why, maybe someone know what causes the problem or have a solotion. Thank you all!

10.4.22-MariaDB
InnoDB
Apache/2.4.52 (Win64) OpenSSL/1.1.1m PHP/8.1.2
phpMyAdmin: 5.11.1

My migrations:

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');
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

捎一片雪花 2025-02-16 07:11:15

我发现了,Migartions没有错误,只有我。
我只是一个大驴。
我在“ table-> structive-> reaceation视图”下找到了它。
我以为我会在“ table-> struction-> table structure- indexes”下找到它。
这对我没有意义,为什么在那里,但最后我找到了。
谢谢大家。

I found it, there is no error in the migartions, just me.
I am just a big donkey.
I found it in the phpmyadmin under "Table->Structure->Realation view"
I thought that i will found it under "Table->Structure->Table structure->Indexes"
Its make no sense to me why is it there, but finally i found it.
Thanks everyone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文