Skip to content

Commit

Permalink
fix: review, not found, cuid, migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
Narrr21 committed Nov 29, 2024
1 parent bd81f3c commit d6dd01b
Show file tree
Hide file tree
Showing 9 changed files with 2,678 additions and 106 deletions.
39 changes: 39 additions & 0 deletions drizzle/0021_salty_cammi.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
CREATE TABLE IF NOT EXISTS "co_working_space_reviews" (
"coWorkingSpace_id" text NOT NULL,
"user_id" text NOT NULL,
"rating" integer NOT NULL,
"review" text NOT NULL,
CONSTRAINT "co_working_space_reviews_coWorkingSpace_id_user_id_pk" PRIMARY KEY("coWorkingSpace_id","user_id")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "voucher_reviews" (
"user_id" text NOT NULL,
"voucher_id" text NOT NULL,
"rating" integer NOT NULL,
"review" text NOT NULL,
CONSTRAINT "voucher_reviews_voucher_id_user_id_pk" PRIMARY KEY("voucher_id","user_id")
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "co_working_space_reviews" ADD CONSTRAINT "co_working_space_reviews_coWorkingSpace_id_co_working_space_recommendations_id_fk" FOREIGN KEY ("coWorkingSpace_id") REFERENCES "public"."co_working_space_recommendations"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "co_working_space_reviews" ADD CONSTRAINT "co_working_space_reviews_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "voucher_reviews" ADD CONSTRAINT "voucher_reviews_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "voucher_reviews" ADD CONSTRAINT "voucher_reviews_voucher_id_voucher_recommendations_id_fk" FOREIGN KEY ("voucher_id") REFERENCES "public"."voucher_recommendations"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
Loading

0 comments on commit d6dd01b

Please sign in to comment.