mirror of
https://git.meshkee.com/Meshkee/backend.git
synced 2026-08-11 22:30:59 +04:30
NestJS backend with Prisma, Docker Compose for Postgres/Redis, and deploy docs for the production VM.
21 lines
940 B
SQL
21 lines
940 B
SQL
-- Product-level variation value selections (which category options apply to a product).
|
|
-- Store item variants are created later from these values.
|
|
|
|
CREATE TABLE product_variation_values (
|
|
product_id BIGINT NOT NULL,
|
|
variation_id BIGINT NOT NULL,
|
|
option_id BIGINT NOT NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
|
|
CONSTRAINT product_variation_values_pkey PRIMARY KEY (product_id, option_id),
|
|
CONSTRAINT product_variation_values_product_id_fkey
|
|
FOREIGN KEY (product_id) REFERENCES products (id) ON DELETE CASCADE,
|
|
CONSTRAINT product_variation_values_variation_id_fkey
|
|
FOREIGN KEY (variation_id) REFERENCES category_variations (id) ON DELETE RESTRICT,
|
|
CONSTRAINT product_variation_values_option_id_fkey
|
|
FOREIGN KEY (option_id) REFERENCES category_variation_options (id) ON DELETE RESTRICT
|
|
);
|
|
|
|
CREATE INDEX idx_product_variation_values_variation_id
|
|
ON product_variation_values (variation_id);
|