来源仓库:jxc/ai-fresh-delivery 来源提交:f0b1a180e2deb7e4673b9d1c8542619f7bc0f73d 快照树: 09f679334ff38f0ff25e907961c94a8223bcaedd(与来源 HEAD 工作树逐字节一致,3801 个文件) 按约定本仓库不带任何历史提交:来源仓库的历史中含真实凭据 (生产 SSH 私钥 deploy/id_rsa_tencent、server/.env、.env.tencent/.env.production/.env.gitea、 deploy/小程序AppSecret.txt,其中 MP_APPSECRET / S3 AccessKey 经哈希比对与线上同值), 整包推送会把这些凭据永久带入本仓库,故只取「当前版本」的单提交快照。 供应商系统后续开发自本提交开始。
34 lines
1.3 KiB
SQL
34 lines
1.3 KiB
SQL
-- ============================================
|
|
-- 此文件由 Meoo Cloud 自动生成,请勿修改
|
|
-- This file is auto-generated by Meoo Cloud, DO NOT MODIFY
|
|
-- ============================================
|
|
|
|
|
|
-- 创建客户商品关联表(客户专属商品库)
|
|
CREATE TABLE IF NOT EXISTS customer_skus (
|
|
id SERIAL PRIMARY KEY,
|
|
customer_code VARCHAR(50) NOT NULL,
|
|
sku_code VARCHAR(50) NOT NULL,
|
|
customer_sku_name VARCHAR(200), -- 客户对商品的特殊命名
|
|
customer_unit VARCHAR(50), -- 客户使用的单位
|
|
price_preference DECIMAL(10,2), -- 客户历史价格偏好
|
|
is_favorite BOOLEAN DEFAULT false, -- 是否常用商品
|
|
usage_count INTEGER DEFAULT 0, -- 使用次数
|
|
last_order_at TIMESTAMPTZ,
|
|
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ DEFAULT NOW(),
|
|
UNIQUE(customer_code, sku_code)
|
|
);
|
|
|
|
-- 创建客户商品库索引
|
|
CREATE INDEX IF NOT EXISTS idx_customer_skus_customer ON customer_skus(customer_code);
|
|
CREATE INDEX IF NOT EXISTS idx_customer_skus_sku ON customer_skus(sku_code);
|
|
CREATE INDEX IF NOT EXISTS idx_customer_skus_favorite ON customer_skus(customer_code, is_favorite);
|
|
|
|
-- 启用RLS
|
|
ALTER TABLE customer_skus ENABLE ROW LEVEL SECURITY;
|
|
|
|
-- 匿名访问策略
|
|
CREATE POLICY anon_all_customer_skus ON customer_skus FOR ALL USING (true);
|
|
|