From 5bbb1612615cff1ec70a0d25c480954e4db9f89b Mon Sep 17 00:00:00 2001 From: Sahil Patel Date: Mon, 7 Oct 2024 21:20:01 +0530 Subject: [PATCH 1/5] replace "First name" and "Surname" input fields with a single "Fullname" field --- .../alpha/additional-details/_actions.ts | 6 +-- .../alpha/additional-details/_client.tsx | 43 ++++++------------- app/(app)/alpha/additional-details/page.tsx | 6 +-- schema/additionalUserDetails.ts | 9 +--- server/db/schema.ts | 2 - 5 files changed, 18 insertions(+), 48 deletions(-) diff --git a/app/(app)/alpha/additional-details/_actions.ts b/app/(app)/alpha/additional-details/_actions.ts index 78d300d3..ed4eaad0 100644 --- a/app/(app)/alpha/additional-details/_actions.ts +++ b/app/(app)/alpha/additional-details/_actions.ts @@ -23,14 +23,12 @@ export async function slideOneSubmitAction(dataInput: TypeSlideOneSchema) { } try { - const { firstName, surname, username, location } = - slideOneSchema.parse(dataInput); + const { name, username, location } = slideOneSchema.parse(dataInput); await db .update(user) .set({ - firstName, - surname, + name, username, location, }) diff --git a/app/(app)/alpha/additional-details/_client.tsx b/app/(app)/alpha/additional-details/_client.tsx index 5c2a664b..55f8dd04 100644 --- a/app/(app)/alpha/additional-details/_client.tsx +++ b/app/(app)/alpha/additional-details/_client.tsx @@ -42,8 +42,7 @@ import { Divider } from "@/components/ui-components/divider"; type UserDetails = { username: string; - firstName: string; - surname: string; + name: string; gender: string; dateOfBirth: string; location: string; @@ -63,8 +62,7 @@ export default function AdditionalSignUpDetails({ const searchParams = useSearchParams(); const { - surname, - firstName, + name, username, location, dateOfBirth, @@ -75,7 +73,7 @@ export default function AdditionalSignUpDetails({ let slide: number; if (searchParams.get("slide")) { slide = Number(searchParams.get("slide")); - } else if (!surname || !firstName || !username || !location) { + } else if (!name || !username || !location) { slide = 1; } else if (!dateOfBirth || !gender) { slide = 2; @@ -102,7 +100,7 @@ export default function AdditionalSignUpDetails({ function SlideOne({ details }: { details: UserDetails }) { const router = useRouter(); - const { username, firstName, surname, location } = details; + const { username, name, location } = details; const { register, @@ -110,7 +108,7 @@ function SlideOne({ details }: { details: UserDetails }) { formState: { errors, isSubmitting }, } = useForm({ resolver: zodResolver(slideOneSchema), - defaultValues: { username, firstName, surname, location }, + defaultValues: { username, name, location }, }); const onFormSubmit = async (data: TypeSlideOneSchema) => { @@ -139,33 +137,16 @@ function SlideOne({ details }: { details: UserDetails }) {
- + - {errors?.firstName && ( + {errors?.name && ( - {errors.firstName.message} - - )} - -
- -
- - - - {errors?.surname && ( - - {errors.surname.message} + {errors.name.message} )} diff --git a/app/(app)/alpha/additional-details/page.tsx b/app/(app)/alpha/additional-details/page.tsx index a9df96c6..dfe5d1be 100644 --- a/app/(app)/alpha/additional-details/page.tsx +++ b/app/(app)/alpha/additional-details/page.tsx @@ -13,8 +13,7 @@ export default async function Page() { const details = await db.query.user.findFirst({ columns: { username: true, - firstName: true, - surname: true, + name: true, gender: true, dateOfBirth: true, location: true, @@ -29,8 +28,7 @@ export default async function Page() { const detailsWithNullsRemoved = { username: details?.username || "", - firstName: details?.firstName || "", - surname: details?.surname || "", + name: details?.name || "", gender: details?.gender || "", dateOfBirth: details?.dateOfBirth || "", location: details?.location || "", diff --git a/schema/additionalUserDetails.ts b/schema/additionalUserDetails.ts index a293c8ba..667fa2f4 100644 --- a/schema/additionalUserDetails.ts +++ b/schema/additionalUserDetails.ts @@ -1,15 +1,10 @@ import z from "zod"; export const slideOneSchema = z.object({ - firstName: z + name: z .string() .trim() - .min(2, "Min name length is 2 characters.") - .max(50, "Max name length is 50 characters."), - surname: z - .string() - .trim() - .min(2, "Min name length is 2 characters.") + .min(1, "Min name length is 1 characters.") .max(50, "Max name length is 50 characters."), username: z .string() diff --git a/server/db/schema.ts b/server/db/schema.ts index 6049b80f..2070bd6a 100644 --- a/server/db/schema.ts +++ b/server/db/schema.ts @@ -204,8 +204,6 @@ export const user = pgTable( websiteUrl: text("websiteUrl").default("").notNull(), emailNotifications: boolean("emailNotifications").default(true).notNull(), newsletter: boolean("newsletter").default(true).notNull(), - firstName: text("firstName"), - surname: text("surname"), gender: text("gender"), dateOfBirth: timestamp("dateOfBirth", { precision: 3, From d3fd1b5345191d43aa3273a95a94b928ba9b9a5f Mon Sep 17 00:00:00 2001 From: Sahil Patel Date: Mon, 7 Oct 2024 22:26:48 +0530 Subject: [PATCH 2/5] replace surname and firstname with name --- app/(app)/alpha/settings/profile.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/(app)/alpha/settings/profile.ts b/app/(app)/alpha/settings/profile.ts index 580abb34..358e2308 100644 --- a/app/(app)/alpha/settings/profile.ts +++ b/app/(app)/alpha/settings/profile.ts @@ -36,12 +36,7 @@ export const updateProfilePhotoUrlSchema = z.object({ export type saveSettingsInput = z.TypeOf; export const saveSettingsFormOneSchema = z.object({ - firstName: z - .string() - .trim() - .min(2, "Min name length is 2 characters.") - .max(50, "Max name length is 50 characters."), - surname: z + name: z .string() .trim() .min(2, "Min name length is 2 characters.") From 15e935bff3695fefeef3e1e5b98117b306718018 Mon Sep 17 00:00:00 2001 From: Sahil Patel Date: Mon, 7 Oct 2024 22:31:01 +0530 Subject: [PATCH 3/5] name contains at least two characters --- schema/additionalUserDetails.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/additionalUserDetails.ts b/schema/additionalUserDetails.ts index 667fa2f4..60dc6940 100644 --- a/schema/additionalUserDetails.ts +++ b/schema/additionalUserDetails.ts @@ -4,7 +4,7 @@ export const slideOneSchema = z.object({ name: z .string() .trim() - .min(1, "Min name length is 1 characters.") + .min(2, "Min name length is 2 characters.") .max(50, "Max name length is 50 characters."), username: z .string() From 0559773ca1f631052091ca358ac8dfc845707d67 Mon Sep 17 00:00:00 2001 From: Sahil Patel Date: Tue, 8 Oct 2024 12:35:17 +0530 Subject: [PATCH 4/5] remove firstName and surname from user table --- drizzle/0008_remove_firstName_and_surname.sql | 2 + drizzle/meta/0008_snapshot.json | 1349 +++++++++++++++++ drizzle/meta/_journal.json | 9 +- 3 files changed, 1359 insertions(+), 1 deletion(-) create mode 100644 drizzle/0008_remove_firstName_and_surname.sql create mode 100644 drizzle/meta/0008_snapshot.json diff --git a/drizzle/0008_remove_firstName_and_surname.sql b/drizzle/0008_remove_firstName_and_surname.sql new file mode 100644 index 00000000..5f23c5dc --- /dev/null +++ b/drizzle/0008_remove_firstName_and_surname.sql @@ -0,0 +1,2 @@ +ALTER TABLE "user" DROP COLUMN IF EXISTS "firstName";--> statement-breakpoint +ALTER TABLE "user" DROP COLUMN IF EXISTS "surname"; \ No newline at end of file diff --git a/drizzle/meta/0008_snapshot.json b/drizzle/meta/0008_snapshot.json new file mode 100644 index 00000000..5771d967 --- /dev/null +++ b/drizzle/meta/0008_snapshot.json @@ -0,0 +1,1349 @@ +{ + "id": "33fbd4d2-b8c2-4941-9294-77b560ba6ccd", + "prevId": "55722b01-0ed7-44c1-8f69-e2aecd15667a", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.account": { + "name": "account", + "schema": "", + "columns": { + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "providerAccountId": { + "name": "providerAccountId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "token_type": { + "name": "token_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_state": { + "name": "session_state", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "account_userId_user_id_fk": { + "name": "account_userId_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "account_provider_providerAccountId_pk": { + "name": "account_provider_providerAccountId_pk", + "columns": [ + "provider", + "providerAccountId" + ] + } + }, + "uniqueConstraints": {} + }, + "public.BannedUsers": { + "name": "BannedUsers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bannedById": { + "name": "bannedById", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "BannedUsers_userId_key": { + "name": "BannedUsers_userId_key", + "columns": [ + { + "expression": "userId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "BannedUsers_userId_user_id_fk": { + "name": "BannedUsers_userId_user_id_fk", + "tableFrom": "BannedUsers", + "tableTo": "user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "BannedUsers_bannedById_user_id_fk": { + "name": "BannedUsers_bannedById_user_id_fk", + "tableFrom": "BannedUsers", + "tableTo": "user", + "columnsFrom": [ + "bannedById" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "BannedUsers_id_unique": { + "name": "BannedUsers_id_unique", + "nullsNotDistinct": false, + "columns": [ + "id" + ] + } + } + }, + "public.Bookmark": { + "name": "Bookmark", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "postId": { + "name": "postId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "Bookmark_userId_postId_key": { + "name": "Bookmark_userId_postId_key", + "columns": [ + { + "expression": "postId", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "userId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "Bookmark_postId_Post_id_fk": { + "name": "Bookmark_postId_Post_id_fk", + "tableFrom": "Bookmark", + "tableTo": "Post", + "columnsFrom": [ + "postId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Bookmark_userId_user_id_fk": { + "name": "Bookmark_userId_user_id_fk", + "tableFrom": "Bookmark", + "tableTo": "user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "Bookmark_id_unique": { + "name": "Bookmark_id_unique", + "nullsNotDistinct": false, + "columns": [ + "id" + ] + } + } + }, + "public.Comment": { + "name": "Comment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "postId": { + "name": "postId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parentId": { + "name": "parentId", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "Comment_postId_Post_id_fk": { + "name": "Comment_postId_Post_id_fk", + "tableFrom": "Comment", + "tableTo": "Post", + "columnsFrom": [ + "postId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Comment_userId_user_id_fk": { + "name": "Comment_userId_user_id_fk", + "tableFrom": "Comment", + "tableTo": "user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Comment_parentId_fkey": { + "name": "Comment_parentId_fkey", + "tableFrom": "Comment", + "tableTo": "Comment", + "columnsFrom": [ + "parentId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "Comment_id_unique": { + "name": "Comment_id_unique", + "nullsNotDistinct": false, + "columns": [ + "id" + ] + } + } + }, + "public.Flagged": { + "name": "Flagged", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "notifierId": { + "name": "notifierId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postId": { + "name": "postId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "commentId": { + "name": "commentId", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "Flagged_userId_user_id_fk": { + "name": "Flagged_userId_user_id_fk", + "tableFrom": "Flagged", + "tableTo": "user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Flagged_notifierId_user_id_fk": { + "name": "Flagged_notifierId_user_id_fk", + "tableFrom": "Flagged", + "tableTo": "user", + "columnsFrom": [ + "notifierId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Flagged_postId_Post_id_fk": { + "name": "Flagged_postId_Post_id_fk", + "tableFrom": "Flagged", + "tableTo": "Post", + "columnsFrom": [ + "postId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Flagged_commentId_Comment_id_fk": { + "name": "Flagged_commentId_Comment_id_fk", + "tableFrom": "Flagged", + "tableTo": "Comment", + "columnsFrom": [ + "commentId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "Flagged_id_unique": { + "name": "Flagged_id_unique", + "nullsNotDistinct": false, + "columns": [ + "id" + ] + } + } + }, + "public.Like": { + "name": "Like", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "postId": { + "name": "postId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "commentId": { + "name": "commentId", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "Like_userId_commentId_key": { + "name": "Like_userId_commentId_key", + "columns": [ + { + "expression": "userId", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "commentId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "Like_userId_postId_key": { + "name": "Like_userId_postId_key", + "columns": [ + { + "expression": "userId", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "postId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "Like_userId_user_id_fk": { + "name": "Like_userId_user_id_fk", + "tableFrom": "Like", + "tableTo": "user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Like_postId_Post_id_fk": { + "name": "Like_postId_Post_id_fk", + "tableFrom": "Like", + "tableTo": "Post", + "columnsFrom": [ + "postId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Like_commentId_Comment_id_fk": { + "name": "Like_commentId_Comment_id_fk", + "tableFrom": "Like", + "tableTo": "Comment", + "columnsFrom": [ + "commentId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "Like_id_unique": { + "name": "Like_id_unique", + "nullsNotDistinct": false, + "columns": [ + "id" + ] + } + } + }, + "public.Notification": { + "name": "Notification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "type": { + "name": "type", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "postId": { + "name": "postId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "commentId": { + "name": "commentId", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "notifierId": { + "name": "notifierId", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "Notification_userId_user_id_fk": { + "name": "Notification_userId_user_id_fk", + "tableFrom": "Notification", + "tableTo": "user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Notification_postId_Post_id_fk": { + "name": "Notification_postId_Post_id_fk", + "tableFrom": "Notification", + "tableTo": "Post", + "columnsFrom": [ + "postId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Notification_commentId_Comment_id_fk": { + "name": "Notification_commentId_Comment_id_fk", + "tableFrom": "Notification", + "tableTo": "Comment", + "columnsFrom": [ + "commentId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Notification_notifierId_user_id_fk": { + "name": "Notification_notifierId_user_id_fk", + "tableFrom": "Notification", + "tableTo": "user", + "columnsFrom": [ + "notifierId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "Notification_id_unique": { + "name": "Notification_id_unique", + "nullsNotDistinct": false, + "columns": [ + "id" + ] + } + } + }, + "public.Post": { + "name": "Post", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canonicalUrl": { + "name": "canonicalUrl", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "coverImage": { + "name": "coverImage", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "approved": { + "name": "approved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "excerpt": { + "name": "excerpt", + "type": "varchar(156)", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "readTimeMins": { + "name": "readTimeMins", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "published": { + "name": "published", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "showComments": { + "name": "showComments", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "likes": { + "name": "likes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "Post_id_key": { + "name": "Post_id_key", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "Post_slug_key": { + "name": "Post_slug_key", + "columns": [ + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "Post_userId_user_id_fk": { + "name": "Post_userId_user_id_fk", + "tableFrom": "Post", + "tableTo": "user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "Post_id_unique": { + "name": "Post_id_unique", + "nullsNotDistinct": false, + "columns": [ + "id" + ] + } + } + }, + "public.PostTag": { + "name": "PostTag", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "tagId": { + "name": "tagId", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "postId": { + "name": "postId", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "PostTag_tagId_postId_key": { + "name": "PostTag_tagId_postId_key", + "columns": [ + { + "expression": "tagId", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "postId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "PostTag_tagId_Tag_id_fk": { + "name": "PostTag_tagId_Tag_id_fk", + "tableFrom": "PostTag", + "tableTo": "Tag", + "columnsFrom": [ + "tagId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "PostTag_postId_Post_id_fk": { + "name": "PostTag_postId_Post_id_fk", + "tableFrom": "PostTag", + "tableTo": "Post", + "columnsFrom": [ + "postId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "sessionToken": { + "name": "sessionToken", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires": { + "name": "expires", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "session_userId_user_id_fk": { + "name": "session_userId_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.Tag": { + "name": "Tag", + "schema": "", + "columns": { + "createdAt": { + "name": "createdAt", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(20)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "Tag_title_key": { + "name": "Tag_title_key", + "columns": [ + { + "expression": "title", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "Tag_id_unique": { + "name": "Tag_id_unique", + "nullsNotDistinct": false, + "columns": [ + "id" + ] + } + } + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "username": { + "name": "username", + "type": "varchar(40)", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emailVerified": { + "name": "emailVerified", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'/images/person.png'" + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "bio": { + "name": "bio", + "type": "varchar(200)", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "websiteUrl": { + "name": "websiteUrl", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "emailNotifications": { + "name": "emailNotifications", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "newsletter": { + "name": "newsletter", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "gender": { + "name": "gender", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dateOfBirth": { + "name": "dateOfBirth", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "professionalOrStudent": { + "name": "professionalOrStudent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workplace": { + "name": "workplace", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "jobTitle": { + "name": "jobTitle", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "levelOfStudy": { + "name": "levelOfStudy", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "course": { + "name": "course", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "Role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'USER'" + } + }, + "indexes": { + "User_username_key": { + "name": "User_username_key", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "User_email_key": { + "name": "User_email_key", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "User_username_id_idx": { + "name": "User_username_id_idx", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.verificationToken": { + "name": "verificationToken", + "schema": "", + "columns": { + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires": { + "name": "expires", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "verificationToken_identifier_token_pk": { + "name": "verificationToken_identifier_token_pk", + "columns": [ + "identifier", + "token" + ] + } + }, + "uniqueConstraints": {} + } + }, + "enums": { + "public.Role": { + "name": "Role", + "schema": "public", + "values": [ + "MODERATOR", + "ADMIN", + "USER" + ] + } + }, + "schemas": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 2c972f8b..74841879 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -57,6 +57,13 @@ "when": 1727929401418, "tag": "0007_drop_communities_and_events", "breakpoints": true + }, + { + "idx": 8, + "version": "7", + "when": 1728368844216, + "tag": "0008_remove_firstName_and_surname", + "breakpoints": true } ] -} +} \ No newline at end of file From 5a0f11bd35eecec9515b69b4e162e40d89c80e7a Mon Sep 17 00:00:00 2001 From: Sahil Patel Date: Wed, 9 Oct 2024 02:25:39 +0530 Subject: [PATCH 5/5] fix prettier issues --- drizzle/meta/0008_snapshot.json | 234 ++++++++------------------------ drizzle/meta/_journal.json | 2 +- 2 files changed, 59 insertions(+), 177 deletions(-) diff --git a/drizzle/meta/0008_snapshot.json b/drizzle/meta/0008_snapshot.json index 5771d967..04d93719 100644 --- a/drizzle/meta/0008_snapshot.json +++ b/drizzle/meta/0008_snapshot.json @@ -81,12 +81,8 @@ "name": "account_userId_user_id_fk", "tableFrom": "account", "tableTo": "user", - "columnsFrom": [ - "userId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["userId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" } @@ -94,10 +90,7 @@ "compositePrimaryKeys": { "account_provider_providerAccountId_pk": { "name": "account_provider_providerAccountId_pk", - "columns": [ - "provider", - "providerAccountId" - ] + "columns": ["provider", "providerAccountId"] } }, "uniqueConstraints": {} @@ -167,12 +160,8 @@ "name": "BannedUsers_userId_user_id_fk", "tableFrom": "BannedUsers", "tableTo": "user", - "columnsFrom": [ - "userId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["userId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" }, @@ -180,12 +169,8 @@ "name": "BannedUsers_bannedById_user_id_fk", "tableFrom": "BannedUsers", "tableTo": "user", - "columnsFrom": [ - "bannedById" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["bannedById"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" } @@ -195,9 +180,7 @@ "BannedUsers_id_unique": { "name": "BannedUsers_id_unique", "nullsNotDistinct": false, - "columns": [ - "id" - ] + "columns": ["id"] } } }, @@ -252,12 +235,8 @@ "name": "Bookmark_postId_Post_id_fk", "tableFrom": "Bookmark", "tableTo": "Post", - "columnsFrom": [ - "postId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["postId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" }, @@ -265,12 +244,8 @@ "name": "Bookmark_userId_user_id_fk", "tableFrom": "Bookmark", "tableTo": "user", - "columnsFrom": [ - "userId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["userId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" } @@ -280,9 +255,7 @@ "Bookmark_id_unique": { "name": "Bookmark_id_unique", "nullsNotDistinct": false, - "columns": [ - "id" - ] + "columns": ["id"] } } }, @@ -341,12 +314,8 @@ "name": "Comment_postId_Post_id_fk", "tableFrom": "Comment", "tableTo": "Post", - "columnsFrom": [ - "postId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["postId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" }, @@ -354,12 +323,8 @@ "name": "Comment_userId_user_id_fk", "tableFrom": "Comment", "tableTo": "user", - "columnsFrom": [ - "userId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["userId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" }, @@ -367,12 +332,8 @@ "name": "Comment_parentId_fkey", "tableFrom": "Comment", "tableTo": "Comment", - "columnsFrom": [ - "parentId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["parentId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" } @@ -382,9 +343,7 @@ "Comment_id_unique": { "name": "Comment_id_unique", "nullsNotDistinct": false, - "columns": [ - "id" - ] + "columns": ["id"] } } }, @@ -449,12 +408,8 @@ "name": "Flagged_userId_user_id_fk", "tableFrom": "Flagged", "tableTo": "user", - "columnsFrom": [ - "userId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["userId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" }, @@ -462,12 +417,8 @@ "name": "Flagged_notifierId_user_id_fk", "tableFrom": "Flagged", "tableTo": "user", - "columnsFrom": [ - "notifierId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["notifierId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" }, @@ -475,12 +426,8 @@ "name": "Flagged_postId_Post_id_fk", "tableFrom": "Flagged", "tableTo": "Post", - "columnsFrom": [ - "postId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["postId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" }, @@ -488,12 +435,8 @@ "name": "Flagged_commentId_Comment_id_fk", "tableFrom": "Flagged", "tableTo": "Comment", - "columnsFrom": [ - "commentId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["commentId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" } @@ -503,9 +446,7 @@ "Flagged_id_unique": { "name": "Flagged_id_unique", "nullsNotDistinct": false, - "columns": [ - "id" - ] + "columns": ["id"] } } }, @@ -594,12 +535,8 @@ "name": "Like_userId_user_id_fk", "tableFrom": "Like", "tableTo": "user", - "columnsFrom": [ - "userId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["userId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" }, @@ -607,12 +544,8 @@ "name": "Like_postId_Post_id_fk", "tableFrom": "Like", "tableTo": "Post", - "columnsFrom": [ - "postId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["postId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" }, @@ -620,12 +553,8 @@ "name": "Like_commentId_Comment_id_fk", "tableFrom": "Like", "tableTo": "Comment", - "columnsFrom": [ - "commentId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["commentId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" } @@ -635,9 +564,7 @@ "Like_id_unique": { "name": "Like_id_unique", "nullsNotDistinct": false, - "columns": [ - "id" - ] + "columns": ["id"] } } }, @@ -702,12 +629,8 @@ "name": "Notification_userId_user_id_fk", "tableFrom": "Notification", "tableTo": "user", - "columnsFrom": [ - "userId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["userId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" }, @@ -715,12 +638,8 @@ "name": "Notification_postId_Post_id_fk", "tableFrom": "Notification", "tableTo": "Post", - "columnsFrom": [ - "postId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["postId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" }, @@ -728,12 +647,8 @@ "name": "Notification_commentId_Comment_id_fk", "tableFrom": "Notification", "tableTo": "Comment", - "columnsFrom": [ - "commentId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["commentId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" }, @@ -741,12 +656,8 @@ "name": "Notification_notifierId_user_id_fk", "tableFrom": "Notification", "tableTo": "user", - "columnsFrom": [ - "notifierId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["notifierId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" } @@ -756,9 +667,7 @@ "Notification_id_unique": { "name": "Notification_id_unique", "nullsNotDistinct": false, - "columns": [ - "id" - ] + "columns": ["id"] } } }, @@ -900,12 +809,8 @@ "name": "Post_userId_user_id_fk", "tableFrom": "Post", "tableTo": "user", - "columnsFrom": [ - "userId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["userId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" } @@ -915,9 +820,7 @@ "Post_id_unique": { "name": "Post_id_unique", "nullsNotDistinct": false, - "columns": [ - "id" - ] + "columns": ["id"] } } }, @@ -972,12 +875,8 @@ "name": "PostTag_tagId_Tag_id_fk", "tableFrom": "PostTag", "tableTo": "Tag", - "columnsFrom": [ - "tagId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["tagId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" }, @@ -985,12 +884,8 @@ "name": "PostTag_postId_Post_id_fk", "tableFrom": "PostTag", "tableTo": "Post", - "columnsFrom": [ - "postId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["postId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "cascade" } @@ -1027,12 +922,8 @@ "name": "session_userId_user_id_fk", "tableFrom": "session", "tableTo": "user", - "columnsFrom": [ - "userId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["userId"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" } @@ -1087,9 +978,7 @@ "Tag_id_unique": { "name": "Tag_id_unique", "nullsNotDistinct": false, - "columns": [ - "id" - ] + "columns": ["id"] } } }, @@ -1320,10 +1209,7 @@ "compositePrimaryKeys": { "verificationToken_identifier_token_pk": { "name": "verificationToken_identifier_token_pk", - "columns": [ - "identifier", - "token" - ] + "columns": ["identifier", "token"] } }, "uniqueConstraints": {} @@ -1333,11 +1219,7 @@ "public.Role": { "name": "Role", "schema": "public", - "values": [ - "MODERATOR", - "ADMIN", - "USER" - ] + "values": ["MODERATOR", "ADMIN", "USER"] } }, "schemas": {}, @@ -1346,4 +1228,4 @@ "schemas": {}, "tables": {} } -} \ No newline at end of file +} diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 74841879..b2e7a5a1 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -66,4 +66,4 @@ "breakpoints": true } ] -} \ No newline at end of file +}