issue # nestjs 로 초기화
This commit is contained in:
79
drizzle/0000_parallel_rocket_racer.sql
Normal file
79
drizzle/0000_parallel_rocket_racer.sql
Normal file
@@ -0,0 +1,79 @@
|
||||
-- Current sql file was generated after introspecting the database
|
||||
-- If you want to run this migration please uncomment this code before executing migrations
|
||||
/*
|
||||
CREATE TABLE "comment" (
|
||||
"id" uuid PRIMARY KEY NOT NULL,
|
||||
"content" text,
|
||||
"created_at" date,
|
||||
"is_deleted" boolean DEFAULT false,
|
||||
"writer_id" uuid,
|
||||
"parent_id" uuid
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "schedule" (
|
||||
"id" uuid PRIMARY KEY NOT NULL,
|
||||
"name" varchar,
|
||||
"start_at" date,
|
||||
"end_at" date,
|
||||
"status" varchar,
|
||||
"content" text,
|
||||
"is_deleted" boolean DEFAULT false,
|
||||
"type" varchar,
|
||||
"created_at" date,
|
||||
"owner" uuid
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "account" (
|
||||
"name" varchar NOT NULL,
|
||||
"email" varchar NOT NULL,
|
||||
"password" varchar NOT NULL,
|
||||
"birthday" date,
|
||||
"account_id" varchar NOT NULL,
|
||||
"nickname" varchar NOT NULL,
|
||||
"status" varchar DEFAULT 'wait' NOT NULL,
|
||||
"is_deleted" boolean DEFAULT false NOT NULL,
|
||||
"created_at" date DEFAULT now() NOT NULL,
|
||||
"id" uuid PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "participant" (
|
||||
"participant_id" uuid NOT NULL,
|
||||
"schedule_id" uuid NOT NULL,
|
||||
"is_deleted" boolean DEFAULT false
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "favorite" (
|
||||
"is_deleted" boolean DEFAULT false,
|
||||
"created_at" date,
|
||||
"user_id" uuid NOT NULL,
|
||||
"schedule_id" uuid NOT NULL,
|
||||
CONSTRAINT "favorite_pk" PRIMARY KEY("user_id","schedule_id")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "follow" (
|
||||
"is_deleted" boolean DEFAULT false,
|
||||
"is_accepted" boolean DEFAULT false,
|
||||
"is_linked" boolean DEFAULT false,
|
||||
"created_at" date,
|
||||
"following" uuid NOT NULL,
|
||||
"follower" uuid NOT NULL,
|
||||
CONSTRAINT "follow_pk" PRIMARY KEY("following","follower")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "comment" ADD CONSTRAINT "writer_id" FOREIGN KEY ("writer_id") REFERENCES "public"."account"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "comment" ADD CONSTRAINT "parent_id" FOREIGN KEY ("parent_id") REFERENCES "public"."comment"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "schedule" ADD CONSTRAINT "schedule_user_fk" FOREIGN KEY ("owner") REFERENCES "public"."account"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "participant" ADD CONSTRAINT "schedule_id" FOREIGN KEY ("schedule_id") REFERENCES "public"."schedule"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "participant" ADD CONSTRAINT "participant_id" FOREIGN KEY ("participant_id") REFERENCES "public"."account"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "favorite" ADD CONSTRAINT "schedule_id" FOREIGN KEY ("schedule_id") REFERENCES "public"."schedule"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "favorite" ADD CONSTRAINT "user_id" FOREIGN KEY ("user_id") REFERENCES "public"."account"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "follow" ADD CONSTRAINT "follower_id" FOREIGN KEY ("follower") REFERENCES "public"."account"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "follow" ADD CONSTRAINT "following_id" FOREIGN KEY ("following") REFERENCES "public"."account"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "schedule_enddatetime_idx" ON "schedule" USING btree ("end_at" date_ops);--> statement-breakpoint
|
||||
CREATE INDEX "schedule_name_idx" ON "schedule" USING btree ("name" text_ops,"content" text_ops);--> statement-breakpoint
|
||||
CREATE INDEX "schedule_startdatetime_idx" ON "schedule" USING btree ("start_at" date_ops);--> statement-breakpoint
|
||||
CREATE INDEX "schedule_status_idx" ON "schedule" USING btree ("status" text_ops);--> statement-breakpoint
|
||||
CREATE INDEX "schedule_type_idx" ON "schedule" USING btree ("type" text_ops);--> statement-breakpoint
|
||||
CREATE INDEX "participant_participant_id_idx" ON "participant" USING btree ("participant_id" uuid_ops);--> statement-breakpoint
|
||||
CREATE INDEX "participant_schedule_id_idx" ON "participant" USING btree ("schedule_id" uuid_ops);
|
||||
*/
|
||||
613
drizzle/meta/0000_snapshot.json
Normal file
613
drizzle/meta/0000_snapshot.json
Normal file
@@ -0,0 +1,613 @@
|
||||
{
|
||||
"id": "00000000-0000-0000-0000-000000000000",
|
||||
"prevId": "",
|
||||
"version": "7",
|
||||
"dialect": "postgresql",
|
||||
"tables": {
|
||||
"public.comment": {
|
||||
"name": "comment",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"content": {
|
||||
"name": "content",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "date",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"is_deleted": {
|
||||
"name": "is_deleted",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": false
|
||||
},
|
||||
"writer_id": {
|
||||
"name": "writer_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"parent_id": {
|
||||
"name": "parent_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"writer_id": {
|
||||
"name": "writer_id",
|
||||
"tableFrom": "comment",
|
||||
"tableTo": "account",
|
||||
"schemaTo": "public",
|
||||
"columnsFrom": [
|
||||
"writer_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"parent_id": {
|
||||
"name": "parent_id",
|
||||
"tableFrom": "comment",
|
||||
"tableTo": "comment",
|
||||
"schemaTo": "public",
|
||||
"columnsFrom": [
|
||||
"parent_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {},
|
||||
"policies": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.schedule": {
|
||||
"name": "schedule",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "varchar",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"start_at": {
|
||||
"name": "start_at",
|
||||
"type": "date",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"end_at": {
|
||||
"name": "end_at",
|
||||
"type": "date",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"status": {
|
||||
"name": "status",
|
||||
"type": "varchar",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"content": {
|
||||
"name": "content",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"is_deleted": {
|
||||
"name": "is_deleted",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": false
|
||||
},
|
||||
"type": {
|
||||
"name": "type",
|
||||
"type": "varchar",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "date",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"owner": {
|
||||
"name": "owner",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"schedule_enddatetime_idx": {
|
||||
"name": "schedule_enddatetime_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "end_at",
|
||||
"asc": true,
|
||||
"nulls": "last",
|
||||
"opclass": "date_ops",
|
||||
"isExpression": false
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
},
|
||||
"schedule_name_idx": {
|
||||
"name": "schedule_name_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "name",
|
||||
"asc": true,
|
||||
"nulls": "last",
|
||||
"opclass": "text_ops",
|
||||
"isExpression": false
|
||||
},
|
||||
{
|
||||
"expression": "content",
|
||||
"asc": true,
|
||||
"nulls": "last",
|
||||
"opclass": "text_ops",
|
||||
"isExpression": false
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
},
|
||||
"schedule_startdatetime_idx": {
|
||||
"name": "schedule_startdatetime_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "start_at",
|
||||
"asc": true,
|
||||
"nulls": "last",
|
||||
"opclass": "date_ops",
|
||||
"isExpression": false
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
},
|
||||
"schedule_status_idx": {
|
||||
"name": "schedule_status_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "status",
|
||||
"asc": true,
|
||||
"nulls": "last",
|
||||
"opclass": "text_ops",
|
||||
"isExpression": false
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
},
|
||||
"schedule_type_idx": {
|
||||
"name": "schedule_type_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "type",
|
||||
"asc": true,
|
||||
"nulls": "last",
|
||||
"opclass": "text_ops",
|
||||
"isExpression": false
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {
|
||||
"schedule_user_fk": {
|
||||
"name": "schedule_user_fk",
|
||||
"tableFrom": "schedule",
|
||||
"tableTo": "account",
|
||||
"schemaTo": "public",
|
||||
"columnsFrom": [
|
||||
"owner"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {},
|
||||
"policies": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.account": {
|
||||
"name": "account",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "varchar",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"email": {
|
||||
"name": "email",
|
||||
"type": "varchar",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"password": {
|
||||
"name": "password",
|
||||
"type": "varchar",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"birthday": {
|
||||
"name": "birthday",
|
||||
"type": "date",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"account_id": {
|
||||
"name": "account_id",
|
||||
"type": "varchar",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"nickname": {
|
||||
"name": "nickname",
|
||||
"type": "varchar",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"status": {
|
||||
"name": "status",
|
||||
"type": "varchar",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'wait'"
|
||||
},
|
||||
"is_deleted": {
|
||||
"name": "is_deleted",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "date",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
},
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "uuid_generate_v4()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {},
|
||||
"policies": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.participant": {
|
||||
"name": "participant",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"participant_id": {
|
||||
"name": "participant_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"schedule_id": {
|
||||
"name": "schedule_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"is_deleted": {
|
||||
"name": "is_deleted",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"participant_participant_id_idx": {
|
||||
"name": "participant_participant_id_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "participant_id",
|
||||
"asc": true,
|
||||
"nulls": "last",
|
||||
"opclass": "uuid_ops",
|
||||
"isExpression": false
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
},
|
||||
"participant_schedule_id_idx": {
|
||||
"name": "participant_schedule_id_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "schedule_id",
|
||||
"asc": true,
|
||||
"nulls": "last",
|
||||
"opclass": "uuid_ops",
|
||||
"isExpression": false
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {
|
||||
"schedule_id": {
|
||||
"name": "schedule_id",
|
||||
"tableFrom": "participant",
|
||||
"tableTo": "schedule",
|
||||
"schemaTo": "public",
|
||||
"columnsFrom": [
|
||||
"schedule_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"participant_id": {
|
||||
"name": "participant_id",
|
||||
"tableFrom": "participant",
|
||||
"tableTo": "account",
|
||||
"schemaTo": "public",
|
||||
"columnsFrom": [
|
||||
"participant_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {},
|
||||
"policies": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.favorite": {
|
||||
"name": "favorite",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"is_deleted": {
|
||||
"name": "is_deleted",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "date",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"schedule_id": {
|
||||
"name": "schedule_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"schedule_id": {
|
||||
"name": "schedule_id",
|
||||
"tableFrom": "favorite",
|
||||
"tableTo": "schedule",
|
||||
"schemaTo": "public",
|
||||
"columnsFrom": [
|
||||
"schedule_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"tableFrom": "favorite",
|
||||
"tableTo": "account",
|
||||
"schemaTo": "public",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {
|
||||
"favorite_pk": {
|
||||
"name": "favorite_pk",
|
||||
"columns": [
|
||||
"user_id",
|
||||
"schedule_id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {},
|
||||
"policies": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.follow": {
|
||||
"name": "follow",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"is_deleted": {
|
||||
"name": "is_deleted",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": false
|
||||
},
|
||||
"is_accepted": {
|
||||
"name": "is_accepted",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": false
|
||||
},
|
||||
"is_linked": {
|
||||
"name": "is_linked",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "date",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"following": {
|
||||
"name": "following",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"follower": {
|
||||
"name": "follower",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"follower_id": {
|
||||
"name": "follower_id",
|
||||
"tableFrom": "follow",
|
||||
"tableTo": "account",
|
||||
"schemaTo": "public",
|
||||
"columnsFrom": [
|
||||
"follower"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"following_id": {
|
||||
"name": "following_id",
|
||||
"tableFrom": "follow",
|
||||
"tableTo": "account",
|
||||
"schemaTo": "public",
|
||||
"columnsFrom": [
|
||||
"following"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {
|
||||
"follow_pk": {
|
||||
"name": "follow_pk",
|
||||
"columns": [
|
||||
"following",
|
||||
"follower"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {},
|
||||
"policies": {},
|
||||
"isRLSEnabled": false
|
||||
}
|
||||
},
|
||||
"enums": {},
|
||||
"schemas": {},
|
||||
"sequences": {},
|
||||
"roles": {},
|
||||
"policies": {},
|
||||
"views": {},
|
||||
"_meta": {
|
||||
"schemas": {},
|
||||
"tables": {},
|
||||
"columns": {}
|
||||
},
|
||||
"internal": {
|
||||
"tables": {}
|
||||
}
|
||||
}
|
||||
13
drizzle/meta/_journal.json
Normal file
13
drizzle/meta/_journal.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": "7",
|
||||
"dialect": "postgresql",
|
||||
"entries": [
|
||||
{
|
||||
"idx": 0,
|
||||
"version": "7",
|
||||
"when": 1763702111620,
|
||||
"tag": "0000_parallel_rocket_racer",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
74
drizzle/relations.ts
Normal file
74
drizzle/relations.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import { relations } from "drizzle-orm/relations";
|
||||
import { account, comment, schedule, participant, favorite, follow } from "./schema";
|
||||
|
||||
export const commentRelations = relations(comment, ({one, many}) => ({
|
||||
account: one(account, {
|
||||
fields: [comment.writerId],
|
||||
references: [account.id]
|
||||
}),
|
||||
comment: one(comment, {
|
||||
fields: [comment.parentId],
|
||||
references: [comment.id],
|
||||
relationName: "comment_parentId_comment_id"
|
||||
}),
|
||||
comments: many(comment, {
|
||||
relationName: "comment_parentId_comment_id"
|
||||
}),
|
||||
}));
|
||||
|
||||
export const accountRelations = relations(account, ({many}) => ({
|
||||
comments: many(comment),
|
||||
schedules: many(schedule),
|
||||
participants: many(participant),
|
||||
favorites: many(favorite),
|
||||
follows_follower: many(follow, {
|
||||
relationName: "follow_follower_account_id"
|
||||
}),
|
||||
follows_following: many(follow, {
|
||||
relationName: "follow_following_account_id"
|
||||
}),
|
||||
}));
|
||||
|
||||
export const scheduleRelations = relations(schedule, ({one, many}) => ({
|
||||
account: one(account, {
|
||||
fields: [schedule.owner],
|
||||
references: [account.id]
|
||||
}),
|
||||
participants: many(participant),
|
||||
favorites: many(favorite),
|
||||
}));
|
||||
|
||||
export const participantRelations = relations(participant, ({one}) => ({
|
||||
schedule: one(schedule, {
|
||||
fields: [participant.scheduleId],
|
||||
references: [schedule.id]
|
||||
}),
|
||||
account: one(account, {
|
||||
fields: [participant.participantId],
|
||||
references: [account.id]
|
||||
}),
|
||||
}));
|
||||
|
||||
export const favoriteRelations = relations(favorite, ({one}) => ({
|
||||
schedule: one(schedule, {
|
||||
fields: [favorite.scheduleId],
|
||||
references: [schedule.id]
|
||||
}),
|
||||
account: one(account, {
|
||||
fields: [favorite.userId],
|
||||
references: [account.id]
|
||||
}),
|
||||
}));
|
||||
|
||||
export const followRelations = relations(follow, ({one}) => ({
|
||||
account_follower: one(account, {
|
||||
fields: [follow.follower],
|
||||
references: [account.id],
|
||||
relationName: "follow_follower_account_id"
|
||||
}),
|
||||
account_following: one(account, {
|
||||
fields: [follow.following],
|
||||
references: [account.id],
|
||||
relationName: "follow_following_account_id"
|
||||
}),
|
||||
}));
|
||||
120
drizzle/schema.ts
Normal file
120
drizzle/schema.ts
Normal file
@@ -0,0 +1,120 @@
|
||||
import { pgTable, foreignKey, uuid, text, date, boolean, index, varchar, primaryKey } from "drizzle-orm/pg-core"
|
||||
import { sql } from "drizzle-orm"
|
||||
|
||||
|
||||
|
||||
export const comment = pgTable("comment", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
content: text(),
|
||||
createdAt: date("created_at"),
|
||||
isDeleted: boolean("is_deleted").default(false),
|
||||
writerId: uuid("writer_id"),
|
||||
parentId: uuid("parent_id"),
|
||||
}, (table) => [
|
||||
foreignKey({
|
||||
columns: [table.writerId],
|
||||
foreignColumns: [account.id],
|
||||
name: "writer_id"
|
||||
}),
|
||||
foreignKey({
|
||||
columns: [table.parentId],
|
||||
foreignColumns: [table.id],
|
||||
name: "parent_id"
|
||||
}),
|
||||
]);
|
||||
|
||||
export const schedule = pgTable("schedule", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
name: varchar(),
|
||||
startAt: date("start_at"),
|
||||
endAt: date("end_at"),
|
||||
status: varchar(),
|
||||
content: text(),
|
||||
isDeleted: boolean("is_deleted").default(false),
|
||||
type: varchar(),
|
||||
createdAt: date("created_at"),
|
||||
owner: uuid(),
|
||||
}, (table) => [
|
||||
index("schedule_enddatetime_idx").using("btree", table.endAt.asc().nullsLast().op("date_ops")),
|
||||
index("schedule_name_idx").using("btree", table.name.asc().nullsLast().op("text_ops"), table.content.asc().nullsLast().op("text_ops")),
|
||||
index("schedule_startdatetime_idx").using("btree", table.startAt.asc().nullsLast().op("date_ops")),
|
||||
index("schedule_status_idx").using("btree", table.status.asc().nullsLast().op("text_ops")),
|
||||
index("schedule_type_idx").using("btree", table.type.asc().nullsLast().op("text_ops")),
|
||||
foreignKey({
|
||||
columns: [table.owner],
|
||||
foreignColumns: [account.id],
|
||||
name: "schedule_user_fk"
|
||||
}),
|
||||
]);
|
||||
|
||||
export const account = pgTable("account", {
|
||||
name: varchar().notNull(),
|
||||
email: varchar().notNull(),
|
||||
password: varchar().notNull(),
|
||||
birthday: date(),
|
||||
accountId: varchar("account_id").notNull(),
|
||||
nickname: varchar().notNull(),
|
||||
status: varchar().default('wait').notNull(),
|
||||
isDeleted: boolean("is_deleted").default(false).notNull(),
|
||||
createdAt: date("created_at").defaultNow().notNull(),
|
||||
id: uuid().default(sql`uuid_generate_v4()`).primaryKey().notNull(),
|
||||
});
|
||||
|
||||
export const participant = pgTable("participant", {
|
||||
participantId: uuid("participant_id").notNull(),
|
||||
scheduleId: uuid("schedule_id").notNull(),
|
||||
isDeleted: boolean("is_deleted").default(false),
|
||||
}, (table) => [
|
||||
index("participant_participant_id_idx").using("btree", table.participantId.asc().nullsLast().op("uuid_ops")),
|
||||
index("participant_schedule_id_idx").using("btree", table.scheduleId.asc().nullsLast().op("uuid_ops")),
|
||||
foreignKey({
|
||||
columns: [table.scheduleId],
|
||||
foreignColumns: [schedule.id],
|
||||
name: "schedule_id"
|
||||
}),
|
||||
foreignKey({
|
||||
columns: [table.participantId],
|
||||
foreignColumns: [account.id],
|
||||
name: "participant_id"
|
||||
}),
|
||||
]);
|
||||
|
||||
export const favorite = pgTable("favorite", {
|
||||
isDeleted: boolean("is_deleted").default(false),
|
||||
createdAt: date("created_at"),
|
||||
userId: uuid("user_id").notNull(),
|
||||
scheduleId: uuid("schedule_id").notNull(),
|
||||
}, (table) => [
|
||||
foreignKey({
|
||||
columns: [table.scheduleId],
|
||||
foreignColumns: [schedule.id],
|
||||
name: "schedule_id"
|
||||
}),
|
||||
foreignKey({
|
||||
columns: [table.userId],
|
||||
foreignColumns: [account.id],
|
||||
name: "user_id"
|
||||
}),
|
||||
primaryKey({ columns: [table.userId, table.scheduleId], name: "favorite_pk"}),
|
||||
]);
|
||||
|
||||
export const follow = pgTable("follow", {
|
||||
isDeleted: boolean("is_deleted").default(false),
|
||||
isAccepted: boolean("is_accepted").default(false),
|
||||
isLinked: boolean("is_linked").default(false),
|
||||
createdAt: date("created_at"),
|
||||
following: uuid().notNull(),
|
||||
follower: uuid().notNull(),
|
||||
}, (table) => [
|
||||
foreignKey({
|
||||
columns: [table.follower],
|
||||
foreignColumns: [account.id],
|
||||
name: "follower_id"
|
||||
}),
|
||||
foreignKey({
|
||||
columns: [table.following],
|
||||
foreignColumns: [account.id],
|
||||
name: "following_id"
|
||||
}),
|
||||
primaryKey({ columns: [table.following, table.follower], name: "follow_pk"}),
|
||||
]);
|
||||
Reference in New Issue
Block a user