Skip to content

Commit

Permalink
feat: update schema for testimonies
Browse files Browse the repository at this point in the history
  • Loading branch information
fawwazabrials committed Jun 12, 2024
1 parent 65f8e05 commit 9f7e835
Show file tree
Hide file tree
Showing 5 changed files with 1,338 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
.env
google_credentials.json

# Ignore seed csv data
src/db/seed/database.csv
Expand Down
26 changes: 26 additions & 0 deletions drizzle/0003_mean_strong_guy.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
CREATE TABLE IF NOT EXISTS "testimonies" (
"id" text PRIMARY KEY NOT NULL,
"user_id" text,
"course_id" text NOT NULL,
"user_name" text,
"content" text NOT NULL,
"assignments" text NOT NULL,
"lecturer" text NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "courses" ADD COLUMN "type" text DEFAULT 'Elective' NOT NULL;--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "testimonies" ADD CONSTRAINT "testimonies_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "testimonies" ADD CONSTRAINT "testimonies_course_id_courses_id_fk" FOREIGN KEY ("course_id") REFERENCES "public"."courses"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "testimonies_user_id_index" ON "testimonies" ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "testimonies_course_id_index" ON "testimonies" ("course_id");
Loading

0 comments on commit 9f7e835

Please sign in to comment.