CREATE TABLE IF NOT EXISTS biz_query_asin (
    id BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '主键',
    group_id BIGINT NOT NULL COMMENT '分组ID',
    shop_name VARCHAR(128) NOT NULL COMMENT '店铺名',
    asin_de VARCHAR(64) NOT NULL DEFAULT '' COMMENT '德国 ASIN',
    asin_uk VARCHAR(64) NOT NULL DEFAULT '' COMMENT '英国 ASIN',
    asin_fr VARCHAR(64) NOT NULL DEFAULT '' COMMENT '法国 ASIN',
    asin_it VARCHAR(64) NOT NULL DEFAULT '' COMMENT '意大利 ASIN',
    asin_es VARCHAR(64) NOT NULL DEFAULT '' COMMENT '西班牙 ASIN',
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    KEY idx_group_shop_name (group_id, shop_name),
    KEY idx_shop_name (shop_name),
    KEY idx_created_at (created_at)
) COMMENT='查询 ASIN';

INSERT INTO `columns` (`name`, `column_key`, `menu_type`, `route_path`, `sort_order`)
SELECT '查询ASIN', 'admin_query_asin', 'admin', 'query-asin', 65
WHERE NOT EXISTS (
    SELECT 1 FROM `columns` WHERE `column_key` = 'admin_query_asin'
);

UPDATE `columns`
SET `name` = '查询ASIN',
    `menu_type` = 'admin',
    `route_path` = 'query-asin',
    `sort_order` = 65
WHERE `column_key` = 'admin_query_asin';
