微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。