🔄 cleanup: order with 3 key relations, and ckflow now upto speeded

This commit is contained in:
user
2025-10-20 22:27:06 +03:00
parent 2ed74c267d
commit 10bcbf982a
28 changed files with 190 additions and 1360 deletions

View File

@@ -120,18 +120,20 @@ CREATE TABLE IF NOT EXISTS "order" (
"status" varchar(24),
"product_id" integer,
"customer_info_id" integer,
"payment_details_id" integer,
"payment_info_id" integer,
"agent_id" text,
"created_at" timestamp DEFAULT now(),
"updated_at" timestamp DEFAULT now()
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "payment_details" (
CREATE TABLE IF NOT EXISTS "payment_info" (
"id" serial PRIMARY KEY NOT NULL,
"cardholder_name" varchar(128) NOT NULL,
"card_number" varchar(20) NOT NULL,
"expiry" varchar(5) NOT NULL,
"cvv" varchar(6) NOT NULL,
"order_id" integer,
"product_id" integer,
"created_at" timestamp DEFAULT now(),
"updated_at" timestamp DEFAULT now()
);
@@ -180,7 +182,7 @@ EXCEPTION
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "order" ADD CONSTRAINT "order_payment_details_id_payment_details_id_fk" FOREIGN KEY ("payment_details_id") REFERENCES "public"."payment_details"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "order" ADD CONSTRAINT "order_payment_info_id_payment_info_id_fk" FOREIGN KEY ("payment_info_id") REFERENCES "public"."payment_info"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;

View File

@@ -1,2 +0,0 @@
ALTER TABLE "payment_details" ADD COLUMN "order_id" integer;--> statement-breakpoint
ALTER TABLE "payment_details" ADD COLUMN "product_id" integer;

View File

@@ -1,5 +1,5 @@
{
"id": "77d95f59-9820-4cba-8a6a-cae76a8dff82",
"id": "e8de9102-c79e-46ff-a25f-80e1039b6091",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
@@ -779,8 +779,8 @@
"primaryKey": false,
"notNull": false
},
"payment_details_id": {
"name": "payment_details_id",
"payment_info_id": {
"name": "payment_info_id",
"type": "integer",
"primaryKey": false,
"notNull": false
@@ -834,12 +834,12 @@
"onDelete": "cascade",
"onUpdate": "no action"
},
"order_payment_details_id_payment_details_id_fk": {
"name": "order_payment_details_id_payment_details_id_fk",
"order_payment_info_id_payment_info_id_fk": {
"name": "order_payment_info_id_payment_info_id_fk",
"tableFrom": "order",
"tableTo": "payment_details",
"tableTo": "payment_info",
"columnsFrom": [
"payment_details_id"
"payment_info_id"
],
"columnsTo": [
"id"
@@ -867,8 +867,8 @@
"checkConstraints": {},
"isRLSEnabled": false
},
"public.payment_details": {
"name": "payment_details",
"public.payment_info": {
"name": "payment_info",
"schema": "",
"columns": {
"id": {
@@ -901,6 +901,18 @@
"primaryKey": false,
"notNull": true
},
"order_id": {
"name": "order_id",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"product_id": {
"name": "product_id",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",

File diff suppressed because it is too large Load Diff

View File

@@ -5,15 +5,8 @@
{
"idx": 0,
"version": "7",
"when": 1760987106438,
"tag": "0000_large_gertrude_yorkes",
"breakpoints": true
},
{
"idx": 1,
"version": "7",
"when": 1760987289226,
"tag": "0001_wonderful_nico_minoru",
"when": 1760987569532,
"tag": "0000_far_jack_power",
"breakpoints": true
}
]