fix(edit): 类目问题修改

This commit is contained in:
R524809
2026-09-11 10:36:25 +08:00
parent 05a00d46b9
commit 2c4e94ab3d
11 changed files with 869 additions and 79 deletions
@@ -0,0 +1,37 @@
SET search_path TO atlas, public;
-- A platform listing owns the final, ordered image set. Keeping product_id,
-- profile_id and variant_id here makes the tenant and aggregate boundaries
-- enforceable even when a UUID is supplied by a client.
ALTER TABLE product_variant_platform_listings
ADD CONSTRAINT uq_variant_listing_aggregate
UNIQUE (workspace_id, id, product_id, profile_id, product_variant_id);
CREATE TABLE product_variant_listing_media (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
workspace_id UUID NOT NULL,
product_id UUID NOT NULL,
profile_id UUID NOT NULL,
listing_id UUID NOT NULL,
product_variant_id UUID NOT NULL,
asset_id UUID NOT NULL,
sort_order INTEGER NOT NULL CHECK (sort_order >= 0 AND sort_order < 15),
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
FOREIGN KEY (workspace_id, listing_id, product_id, profile_id, product_variant_id)
REFERENCES product_variant_platform_listings(workspace_id, id, product_id, profile_id, product_variant_id)
ON DELETE CASCADE,
FOREIGN KEY (workspace_id, asset_id)
REFERENCES media_assets(workspace_id, id) ON DELETE RESTRICT,
UNIQUE (workspace_id, id),
UNIQUE (workspace_id, listing_id, sort_order),
UNIQUE (workspace_id, listing_id, asset_id)
);
CREATE INDEX ix_product_variant_listing_media_profile
ON product_variant_listing_media (workspace_id, profile_id, product_variant_id, sort_order);
ALTER TABLE product_variant_listing_media ENABLE ROW LEVEL SECURITY;
ALTER TABLE product_variant_listing_media FORCE ROW LEVEL SECURITY;
CREATE POLICY workspace_isolation ON product_variant_listing_media
USING (workspace_id = app_current_workspace_id())
WITH CHECK (workspace_id = app_current_workspace_id());