<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // 执行原生 SQL 语句
        DB::statement("CREATE TABLE `ufutx_s2_shop_sku` (
  `id` bigint(20) UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,
  `real_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '实物id',
  `payment_id` tinyint(3) UNSIGNED NOT NULL COMMENT '支付子商户id',
  `title` varchar(256) NOT NULL COMMENT 'sku名称',
  `description` text COMMENT '描述(预估仅内部使用)',
  `icon` varchar(256) DEFAULT NULL COMMENT '图标',
  `banner` text COMMENT '轮播图',
  `price` bigint(20) NOT NULL DEFAULT '0' COMMENT '默认展示价格,单位:分',
  `tpl_price_ids` varchar(256) NOT NULL COMMENT '价格计算模板,逗号分隔',
  `tpl_freight_ids` varchar(256) NOT NULL COMMENT '运费计算模板,逗号分隔',
  `type` tinyint(4) NOT NULL DEFAULT '1' COMMENT '1=单品,2=sku组合',
  `group_skuids` varchar(256) NOT NULL COMMENT 'skuid组合,逗号分割',
  `group_num` varchar(256) NOT NULL COMMENT 'sku组合数量限制,总量|sku1最大,sku2最大...',
  `ship` tinyint(3) UNSIGNED NOT NULL DEFAULT '3' COMMENT '1=仅自提,2=仅邮寄,3=皆可',
  `status` tinyint(3) UNSIGNED NOT NULL DEFAULT '1' COMMENT '1=正常,2=下架',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品sku表';");

        DB::statement("ALTER TABLE `ufutx_payments` ADD `alias` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '别名' AFTER `name`;");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('s2_shop_sku');
    }
};
