修改产品套餐
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
-- prc_price_set_product: package-side product master (snapshot like product)
|
||||
-- + prc_price_set_detail.psp_id FK (run once on existing DB)
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `prc_price_set_product` (
|
||||
`psp_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '套餐产品主表id',
|
||||
`price_set_id` bigint(20) NOT NULL COMMENT '价格套餐id',
|
||||
`psv_id` bigint(20) NOT NULL COMMENT '套餐版本id',
|
||||
`product_code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '产品对接代码',
|
||||
`product_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '产品名称',
|
||||
`service_level` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '时效等级',
|
||||
`cargo_attr` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '走货属性',
|
||||
`dest_region` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '目的区域',
|
||||
`update_note` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新说明',
|
||||
`tax_mode` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'TAX_INCLUDED' COMMENT 'TAX_INCLUDED包税 TAX_EXCLUDED不包税',
|
||||
`source_product_id` bigint(20) DEFAULT NULL COMMENT '来源产品库 product.product_id',
|
||||
`source_sheet` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '来源Excel sheet',
|
||||
`create_time` datetime DEFAULT NULL,
|
||||
`update_time` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`psp_id`),
|
||||
UNIQUE KEY `uk_psp_psv_code` (`psv_id`,`product_code`),
|
||||
KEY `idx_psp_set` (`price_set_id`),
|
||||
KEY `idx_psp_psv` (`psv_id`),
|
||||
KEY `idx_psp_code` (`product_code`),
|
||||
CONSTRAINT `fk_psp_psv` FOREIGN KEY (`psv_id`) REFERENCES `prc_price_set_version` (`psv_id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_psp_set` FOREIGN KEY (`price_set_id`) REFERENCES `prc_price_set` (`price_set_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='价格套餐产品主表-与产品库快照独立';
|
||||
|
||||
SET @col_exists := (
|
||||
SELECT COUNT(1) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'prc_price_set_detail' AND COLUMN_NAME = 'psp_id'
|
||||
);
|
||||
SET @sql := IF(@col_exists = 0,
|
||||
CONCAT(
|
||||
'ALTER TABLE `prc_price_set_detail` ',
|
||||
'ADD COLUMN `psp_id` bigint(20) DEFAULT NULL COMMENT ''套餐产品主表id prc_price_set_product.psp_id'' AFTER `psv_id`, ',
|
||||
'ADD KEY `idx_psd_psp` (`psp_id`)'
|
||||
),
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
Reference in New Issue
Block a user