这是我的架构:
Schema::create('settings', function (Blueprint $table) {
$table->id();
$table->unsignedDecimal('custom_price', 6, 2)->nullable();
$table->unsignedDecimal('custom_final_price', 6, 2)->nullable();
$table->unsignedDecimal('custom_discount', 6, 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', 6, 2)->nullable();
$table->unsignedDecimal('discount', 6, 2)->nullable();
$table->enum('discount_type', ['flat', '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', 6, 2)->nullable();
$table->unsignedDecimal('shipping_price_add', 6, 2)->nullable();
$table->timestamps();
});
当我尝试 php:artisan migrate 时,弹出此错误。
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, 2) unsigned null,
`custom_discount` decimal(6, 2) unsigned null,
`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, 2) unsigned null,
`discount` decimal(6, 2) unsigned null,
`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, 2) unsigned null,
`shipping_price_add` decimal(6, 2) unsigned null,
`created_at` timestamp null,
`updated_at` timestamp null)
default character set utf8mb4 collate 'utf8mb4_unicode_ci')
我不明白这个错误,如果有人可以通过告诉我错误或不正确的语法来帮助我。谢谢。