16 lines
No EOL
1.1 KiB
SQL
16 lines
No EOL
1.1 KiB
SQL
CREATE TABLE "mf"."product_group_info" (
|
|
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."product_group_info_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
|
|
"group_name" varchar(255) NOT NULL,
|
|
"description" varchar(500),
|
|
"created_at" timestamp DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "mf"."product_group_membership" (
|
|
"product_id" integer NOT NULL,
|
|
"group_id" integer NOT NULL,
|
|
"added_at" timestamp DEFAULT now() NOT NULL,
|
|
CONSTRAINT "product_group_membership_pk" UNIQUE("product_id","group_id")
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "mf"."product_group_membership" ADD CONSTRAINT "product_group_membership_product_id_product_info_id_fk" FOREIGN KEY ("product_id") REFERENCES "mf"."product_info"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "mf"."product_group_membership" ADD CONSTRAINT "product_group_membership_group_id_product_group_info_id_fk" FOREIGN KEY ("group_id") REFERENCES "mf"."product_group_info"("id") ON DELETE no action ON UPDATE no action; |