From f1dff9b17a01ea43168cdf60614e6184e9928f57 Mon Sep 17 00:00:00 2001 From: Mia Moir Date: Wed, 4 Sep 2024 15:30:41 +0100 Subject: [PATCH] Remove username from user --- app/(authenticated)/layout.tsx | 1 - components/UserContext.tsx | 1 - lib/auth/google/index.ts | 1 - lib/auth/slack/index.ts | 1 - .../20240904143009_remove_username/migration.sql | 11 +++++++++++ lib/db/schema.prisma | 1 - lib/db/types/user.ts | 1 - 7 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 lib/db/migrations/20240904143009_remove_username/migration.sql diff --git a/app/(authenticated)/layout.tsx b/app/(authenticated)/layout.tsx index c937d538..9dcbb3e4 100644 --- a/app/(authenticated)/layout.tsx +++ b/app/(authenticated)/layout.tsx @@ -25,7 +25,6 @@ export default async function AuthenticatedLayout({ Sentry.setUser({ id: user.user_id, - username: user.username, email: user.email, }); diff --git a/components/UserContext.tsx b/components/UserContext.tsx index 09693a3b..0119ef24 100644 --- a/components/UserContext.tsx +++ b/components/UserContext.tsx @@ -17,7 +17,6 @@ export function UserProvider(props: { useEffect(() => { Sentry.setUser({ id: props.user.user_id, - username: props.user.username, email: props.user.email, }); }, [props.user]); diff --git a/lib/auth/google/index.ts b/lib/auth/google/index.ts index 27cca4aa..9dad3c35 100644 --- a/lib/auth/google/index.ts +++ b/lib/auth/google/index.ts @@ -91,7 +91,6 @@ export async function findOrCreateUserFromGoogleToken(rawToken: string) { first_name: claims.given_name!, last_name: claims.family_name!, email: claims.email!, - username: claims.email!.split("@")[0], avatar: claims.picture, identities: { create: { diff --git a/lib/auth/slack/index.ts b/lib/auth/slack/index.ts index 9128e615..6e81c6d0 100644 --- a/lib/auth/slack/index.ts +++ b/lib/auth/slack/index.ts @@ -86,7 +86,6 @@ export async function findOrCreateUserFromSlackToken(userInfo: SlackTokenJson) { first_name: userInfo.given_name!, last_name: userInfo.family_name!, email: userInfo.email!, - username: userInfo.email!.split("@")[0], avatar: userInfo.picture!, identities: { create: { diff --git a/lib/db/migrations/20240904143009_remove_username/migration.sql b/lib/db/migrations/20240904143009_remove_username/migration.sql new file mode 100644 index 00000000..f729fbcf --- /dev/null +++ b/lib/db/migrations/20240904143009_remove_username/migration.sql @@ -0,0 +1,11 @@ +/* + Warnings: + + - You are about to drop the column `username` on the `users` table. All the data in the column will be lost. + +*/ +-- DropIndex +DROP INDEX "users_username_key"; + +-- AlterTable +ALTER TABLE "users" DROP COLUMN "username"; diff --git a/lib/db/schema.prisma b/lib/db/schema.prisma index 6230f66a..17b79724 100644 --- a/lib/db/schema.prisma +++ b/lib/db/schema.prisma @@ -55,7 +55,6 @@ model Role { /// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments model User { user_id Int @id @default(autoincrement()) - username String @unique email String @unique first_name String last_name String diff --git a/lib/db/types/user.ts b/lib/db/types/user.ts index 7eb58d61..d52c8648 100644 --- a/lib/db/types/user.ts +++ b/lib/db/types/user.ts @@ -9,7 +9,6 @@ const jsonSchema: z.ZodSchema = z.lazy(() => z.union([literalSchema, z.arr export const _UserModel = z.object({ user_id: z.number().int(), - username: z.string(), email: z.string(), first_name: z.string(), last_name: z.string(),