<?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()
    {
        //执行表语句
        DB::statement("ALTER TABLE `ufutx_agent_users` ADD INDEX(`user_id`);");
        DB::statement("ALTER TABLE `ufutx_s2_shop_order` ADD INDEX(`user_id`);");
        DB::statement("ALTER TABLE `ufutx_s2_shop_order` ADD INDEX(`status`);");
        DB::statement("ALTER TABLE `ufutx_s2_shop_express` ADD INDEX(`order_id`);");
        DB::statement("CREATE TABLE `ufutx_s2_real_object_category` (
  `id` int(10) UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT COMMENT '其他表应关联此id',
  `name` varchar(256) NOT NULL COMMENT '类型名称'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='实物类型表';");
        DB::statement("CREATE TABLE `ufutx_s2_food` (
  `id` bigint(20) UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,
  `real_id` bigint(10) UNSIGNED NOT NULL COMMENT '实物id',
  `area` varchar(32) CHARACTER SET utf8mb4 DEFAULT 'mainland' COMMENT '地区 大陆:mainland 港澳台:hmt',
  `weight` int(11) DEFAULT '0' COMMENT '重量',
  `unit` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '单位',
  `price` decimal(7,2) DEFAULT '0.00' COMMENT '价格',
  `quantity` int(11) NOT NULL DEFAULT '0' COMMENT '量',
  `stock` int(11) NOT NULL DEFAULT '0' COMMENT '库存',
  `config` text CHARACTER SET utf8mb4 COMMENT '营养素配置',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='食品数据表 - 需关联实物查询';");
        DB::statement("ALTER TABLE `ufutx_s2_real_object` ADD `category_ids` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '1' COMMENT '分类id,逗号分隔' AFTER `id`;");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
};
