-- ============================================
-- 此文件由 Meoo Cloud 自动生成，请勿修改
-- This file is auto-generated by Meoo Cloud, DO NOT MODIFY
-- ============================================


-- 创建产品纱线配比表
CREATE TABLE IF NOT EXISTS product_yarn_ratios (
 id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
 product_id UUID NOT NULL REFERENCES products(id) ON DELETE CASCADE,
 yarn_name TEXT NOT NULL,
 ratio DECIMAL(5,2) NOT NULL DEFAULT 0,
 created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- 启用RLS
ALTER TABLE product_yarn_ratios ENABLE ROW LEVEL SECURITY;

-- RLS策略
CREATE POLICY company_select_product_yarn_ratios ON product_yarn_ratios FOR SELECT USING (true);
CREATE POLICY company_insert_product_yarn_ratios ON product_yarn_ratios FOR INSERT WITH CHECK (true);
CREATE POLICY company_update_product_yarn_ratios ON product_yarn_ratios FOR UPDATE USING (true);
CREATE POLICY company_delete_product_yarn_ratios ON product_yarn_ratios FOR DELETE USING (true);

