-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
284 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
/.pnp | ||
.pnp.js | ||
/db/password.txt | ||
/drizzle/* | ||
|
||
# testing | ||
/coverage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,284 @@ | ||
DO $$ BEGIN | ||
CREATE TYPE "notification_type" AS ENUM('JOIN_REQUEST', 'ACCEPT_REQUEST', 'REJECT_REQUEST'); | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
CREATE TYPE "project_type" AS ENUM('private', 'public', 'permission'); | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
CREATE TYPE "task_status_type" AS ENUM('New', 'In Progress', 'Ready to Test', 'Done'); | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "feature" ( | ||
"id" serial PRIMARY KEY NOT NULL, | ||
"project_id" integer NOT NULL, | ||
"feature_name" varchar(255) NOT NULL, | ||
"order" integer NOT NULL, | ||
"description" varchar(500), | ||
"include_feature" boolean DEFAULT false NOT NULL, | ||
"tags" text, | ||
"start_date" date, | ||
"end_date" date | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "notification" ( | ||
"id" serial PRIMARY KEY NOT NULL, | ||
"sender_id" text NOT NULL, | ||
"receiver_id" text NOT NULL, | ||
"notification_type" "notification_type" NOT NULL, | ||
"project_id" integer NOT NULL, | ||
CONSTRAINT "notification_project_id_receiver_id_sender_id_notification_type_unique" UNIQUE("project_id","receiver_id","sender_id","notification_type") | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "education" ( | ||
"id" serial PRIMARY KEY NOT NULL, | ||
"school" varchar(60) NOT NULL, | ||
"degree" varchar(60) NOT NULL, | ||
"start_date" date NOT NULL, | ||
"end_date" date, | ||
"description" text, | ||
"profile_id" integer NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "experience" ( | ||
"id" serial PRIMARY KEY NOT NULL, | ||
"company" varchar(60) NOT NULL, | ||
"role" varchar(60) NOT NULL, | ||
"start_date" date NOT NULL, | ||
"end_date" date, | ||
"description" text, | ||
"profile_id" integer NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "profile" ( | ||
"id" serial PRIMARY KEY NOT NULL, | ||
"full_name" varchar(60) NOT NULL, | ||
"job_title" varchar(60) NOT NULL, | ||
"background" varchar(400) NOT NULL, | ||
"phone_number" varchar(100) NOT NULL, | ||
"address" varchar(60) NOT NULL, | ||
"email" varchar(255) NOT NULL, | ||
"github" varchar(100), | ||
"linkedin" varchar(100), | ||
"skills" text | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "profile_star" ( | ||
"profile_id" integer NOT NULL, | ||
"user_id" text NOT NULL, | ||
CONSTRAINT "profile_star_user_id_profile_id_unique" UNIQUE("user_id","profile_id") | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "section" ( | ||
"id" serial PRIMARY KEY NOT NULL, | ||
"title" text NOT NULL, | ||
"description" text NOT NULL, | ||
"profile_id" integer NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "dev" ( | ||
"project_id" integer NOT NULL, | ||
"dev_id" text NOT NULL, | ||
"join_at" date NOT NULL, | ||
CONSTRAINT "dev_project_id_dev_id_unique" UNIQUE("project_id","dev_id") | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "project" ( | ||
"id" serial PRIMARY KEY NOT NULL, | ||
"owner_id" text NOT NULL, | ||
"name" varchar(60) NOT NULL, | ||
"project_type" "project_type" NOT NULL, | ||
"logo" text, | ||
"project_link" varchar(255) NOT NULL, | ||
"description" text NOT NULL, | ||
"project_goal" varchar(120) NOT NULL, | ||
"start_date" date NOT NULL, | ||
"end_date" date NOT NULL, | ||
"tech_used" text NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "star_project" ( | ||
"project_id" integer NOT NULL, | ||
"user_id" text NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "tasks" ( | ||
"id" serial PRIMARY KEY NOT NULL, | ||
"assigned_to" text, | ||
"feature_id" integer NOT NULL, | ||
"creator_id" text NOT NULL, | ||
"status" "task_status_type" NOT NULL, | ||
"feature_name" varchar(255) NOT NULL, | ||
"order" integer NOT NULL, | ||
"description" varchar(500), | ||
"start_date" date, | ||
"end_date" date | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "account" ( | ||
"userId" text NOT NULL, | ||
"type" text NOT NULL, | ||
"provider" text NOT NULL, | ||
"providerAccountId" text NOT NULL, | ||
"refresh_token" text, | ||
"access_token" text, | ||
"expires_at" integer, | ||
"token_type" text, | ||
"scope" text, | ||
"id_token" text, | ||
"session_state" text, | ||
CONSTRAINT "account_provider_providerAccountId_pk" PRIMARY KEY("provider","providerAccountId") | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "session" ( | ||
"sessionToken" text PRIMARY KEY NOT NULL, | ||
"userId" text NOT NULL, | ||
"expires" timestamp NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "user" ( | ||
"id" text PRIMARY KEY NOT NULL, | ||
"profile_id" integer, | ||
"name" text, | ||
"username" text, | ||
"email" text NOT NULL, | ||
"emailVerified" timestamp, | ||
"image" text, | ||
"hashedPassword" text, | ||
CONSTRAINT "user_username_unique" UNIQUE("username"), | ||
CONSTRAINT "user_email_unique" UNIQUE("email") | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "verificationToken" ( | ||
"identifier" text NOT NULL, | ||
"token" text NOT NULL, | ||
"expires" timestamp NOT NULL, | ||
CONSTRAINT "verificationToken_identifier_token_pk" PRIMARY KEY("identifier","token") | ||
); | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "feature" ADD CONSTRAINT "feature_project_id_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "project"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "notification" ADD CONSTRAINT "notification_sender_id_user_id_fk" FOREIGN KEY ("sender_id") REFERENCES "user"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "notification" ADD CONSTRAINT "notification_receiver_id_user_id_fk" FOREIGN KEY ("receiver_id") REFERENCES "user"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "notification" ADD CONSTRAINT "notification_project_id_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "project"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "education" ADD CONSTRAINT "education_profile_id_profile_id_fk" FOREIGN KEY ("profile_id") REFERENCES "profile"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "experience" ADD CONSTRAINT "experience_profile_id_profile_id_fk" FOREIGN KEY ("profile_id") REFERENCES "profile"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "profile_star" ADD CONSTRAINT "profile_star_profile_id_profile_id_fk" FOREIGN KEY ("profile_id") REFERENCES "profile"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "profile_star" ADD CONSTRAINT "profile_star_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "section" ADD CONSTRAINT "section_profile_id_profile_id_fk" FOREIGN KEY ("profile_id") REFERENCES "profile"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "dev" ADD CONSTRAINT "dev_project_id_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "project"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "dev" ADD CONSTRAINT "dev_dev_id_user_id_fk" FOREIGN KEY ("dev_id") REFERENCES "user"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "project" ADD CONSTRAINT "project_owner_id_user_id_fk" FOREIGN KEY ("owner_id") REFERENCES "user"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "star_project" ADD CONSTRAINT "star_project_project_id_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "project"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "star_project" ADD CONSTRAINT "star_project_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "tasks" ADD CONSTRAINT "tasks_assigned_to_user_id_fk" FOREIGN KEY ("assigned_to") REFERENCES "user"("id") ON DELETE set null ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "tasks" ADD CONSTRAINT "tasks_feature_id_feature_id_fk" FOREIGN KEY ("feature_id") REFERENCES "feature"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "tasks" ADD CONSTRAINT "tasks_creator_id_user_id_fk" FOREIGN KEY ("creator_id") REFERENCES "user"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "account" ADD CONSTRAINT "account_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "session" ADD CONSTRAINT "session_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "user" ADD CONSTRAINT "user_profile_id_profile_id_fk" FOREIGN KEY ("profile_id") REFERENCES "profile"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; |