Laravel 迁移 - 此架构中是否有错误或写得不好?

问题描述

这是我的架构:

Schema::create('settings',function (Blueprint $table) {
            $table->id();
            $table->unsignedDecimal('custom_price',6,2)->nullable();
            $table->unsignedDecimal('custom_final_price',2)->nullable();
            $table->unsignedDecimal('custom_discount',2)->nullable();
            
            $table->enum('custom_discount_type',['flat','percentage'])->nullable()->after('custom_discount');
            $table->dateTime('custom_discount_start_datetime')->nullable()->after('custom_discount_type');
            
            $table->dateTime('custom_discount_end_datetime')->nullable()->after('custom_discount_start_datetime');
            $table->unsignedDecimal('tax',2)->nullable();
            $table->unsignedDecimal('discount',2)->nullable();
            $table->enum('discount_type','percentage'])->nullable()->after('discount');
            $table->dateTime('discount_start_datetime')->nullable()->after('discount_type');
            $table->dateTime('discount_end_datetime')->nullable()->after('discount_start_datetime');
            $table->unsignedDecimal('shipping_price',2)->nullable();
            $table->unsignedDecimal('shipping_price_add',2)->nullable();
            $table->timestamps();
        });

当我尝试 PHP:artisan 迁移时,会弹出这个错误

sqlSTATE[42000]: Syntax error or access violation: 1064 You have an error in your sql Syntax; 
check the manual that corresponds to your MariaDB server version for the right Syntax to use near 
'after `custom_discount`,`custom_discount_start_datetime` datetime null after...' at line 1
(sql: create table `settings` (`id` bigint unsigned not null auto_increment primary key,`custom_price` decimal(6,2) unsigned null,`custom_final_price` decimal(6,`custom_discount` decimal(6,`custom_discount_type` enum('flat','percentage') null after `custom_discount`,`custom_discount_start_datetime` datetime null after `custom_discount_type`,`custom_discount_end_datetime` datetime null after `custom_discount_start_datetime`,`tax` decimal(6,`discount` decimal(6,`discount_type` enum('flat','percentage') null after `discount`,`discount_start_datetime` datetime null after `discount_type`,`discount_end_datetime` datetime null after `discount_start_datetime`,`shipping_price` decimal(6,`shipping_price_add` decimal(6,`created_at` timestamp null,`updated_at` timestamp null) 
default character set utf8mb4 collate 'utf8mb4_unicode_ci')

我不明白错误,如果有人可以告诉我错误或不正确的语法来帮助我。谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)