Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INV-53 참석 여부 응답 method 구현 #7

Merged
merged 3 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "invi",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "next dev",
"build": "next build",
Expand Down Expand Up @@ -39,6 +40,7 @@
"@tanstack/react-form": "^0.26.1",
"@tanstack/react-query": "^5.50.1",
"@tanstack/zod-form-adapter": "^0.25.3",
"@types/uuid": "^10.0.0",
"arctic": "^2.0.0-next.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
Expand All @@ -53,6 +55,7 @@
"sonner": "^1.5.0",
"tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7",
"uuid": "^10.0.0",
Copy link
Collaborator

@bepyan bepyan Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gibeom42

nanoid install이 안되서 DB 저장이 안될텐디..?
아래 커멘드 ㄱㄱ

bun add nanoid
bun remove uuid @types/uuid

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

되던데!!
로컬에만 해놓고 package.json에 안됐나보네 ㅜㅜ 수정하겠습니다!

"zod": "^3.23.8",
"zustand": "^4.5.4"
},
Expand Down
1 change: 1 addition & 0 deletions src/lib/db/migrations/0004_lying_swordsman.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "invitation_response" ALTER COLUMN "id" SET DATA TYPE text;
244 changes: 244 additions & 0 deletions src/lib/db/migrations/meta/0004_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
{
"id": "f5ad7474-391e-414a-912d-2fb1cb551851",
"prevId": "1e7681b2-7222-4b1a-a6a5-eb338ef65ce8",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.session": {
"name": "session",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"expires_at": {
"name": "expires_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {
"session_user_id_user_id_fk": {
"name": "session_user_id_user_id_fk",
"tableFrom": "session",
"tableTo": "user",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.invitation_response": {
"name": "invitation_response",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"participant_name": {
"name": "participant_name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"attendance": {
"name": "attendance",
"type": "boolean",
"primaryKey": false,
"notNull": true
},
"reason": {
"name": "reason",
"type": "text",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.test_job": {
"name": "test_job",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": true
},
"content": {
"name": "content",
"type": "text",
"primaryKey": false,
"notNull": true
},
"test_id": {
"name": "test_id",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {
"test_job_test_id_test_id_fk": {
"name": "test_job_test_id_test_id_fk",
"tableFrom": "test_job",
"tableTo": "test",
"columnsFrom": ["test_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.test": {
"name": "test",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"number": {
"name": "number",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"test_email_unique": {
"name": "test_email_unique",
"nullsNotDistinct": false,
"columns": ["email"]
}
}
},
"public.user": {
"name": "user",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
},
"provider": {
"name": "provider",
"type": "provider",
"typeSchema": "public",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"user_email_unique": {
"name": "user_email_unique",
"nullsNotDistinct": false,
"columns": ["email"]
}
}
}
},
"enums": {
"public.provider": {
"name": "provider",
"schema": "public",
"values": ["google", "kakao", "naver"]
}
},
"schemas": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
29 changes: 29 additions & 0 deletions src/lib/db/schema/invitation_response.query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use server";
import { nanoid } from "nanoid";

import { db } from "~/lib/db";
import {
invitationResponses,
type InvitationResponseInsert,
} from "~/lib/db/schema/invitation_response";

export async function getAllInvitationResponses() {
return db.select().from(invitationResponses);
}

export async function createInvitationResponses(
participant_name: string,
attendance: boolean,
reason: string,
) {
const data: InvitationResponseInsert = {
id: nanoid(),
participant_name: participant_name,
attendance: attendance,
reason: reason,
created_at: new Date(),
};

const res = db.insert(invitationResponses).values(data);
return res;
}
4 changes: 2 additions & 2 deletions src/lib/db/schema/invitation_response.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { boolean, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
import { boolean, pgTable, text, timestamp } from "drizzle-orm/pg-core";

export const invitationResponses = pgTable("invitation_response", {
id: uuid("id").primaryKey().notNull(),
id: text("id").primaryKey().notNull(),
participant_name: text("participant_name").notNull(),
attendance: boolean("attendance").notNull(),
reason: text("reason"),
Expand Down