mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 13:09:19 +08:00
feat(ecom-dmb): 商品规格表添加(公司ID,规格编码)复合唯一约束,导入时自动清理重复规格数据
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
-- 同一公司下规格编码唯一(与导入并发建规格一致)
|
||||
SET @db := DATABASE();
|
||||
SET @exists := (
|
||||
SELECT COUNT(1) FROM information_schema.statistics
|
||||
WHERE table_schema = @db AND table_name = 'ec_product_spec' AND index_name = 'uk_company_spec_code'
|
||||
);
|
||||
SET @sql := IF(@exists = 0,
|
||||
'ALTER TABLE ec_product_spec ADD UNIQUE INDEX uk_company_spec_code (company_id, spec_code)',
|
||||
'SELECT 1');
|
||||
PREPARE s FROM @sql;
|
||||
EXECUTE s;
|
||||
DEALLOCATE PREPARE s;
|
||||
Reference in New Issue
Block a user