From 9042ac7afe24e3b66c1a4aaaba6e0290ad2cbb68 Mon Sep 17 00:00:00 2001 From: Aryan Prince Date: Mon, 4 Mar 2024 05:34:02 +0000 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor=20(library):=20Re?= =?UTF-8?q?factored=20schema=20into=20separate=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/library/drizzle.config.ts | 2 +- .../library/src/app/(auth)/signup/signup-form-experimental.tsx | 2 +- apps/library/src/server/actions.ts | 2 +- apps/library/src/server/auth.ts | 2 +- apps/library/src/server/db/index.ts | 2 +- .../library/src/server/db/{schema.ts => schema/auth-schema.ts} | 0 apps/library/src/server/db/schema/main-schema.ts | 3 +++ 7 files changed, 8 insertions(+), 5 deletions(-) rename apps/library/src/server/db/{schema.ts => schema/auth-schema.ts} (100%) create mode 100644 apps/library/src/server/db/schema/main-schema.ts diff --git a/apps/library/drizzle.config.ts b/apps/library/drizzle.config.ts index 4ec8a2b..79fe88e 100644 --- a/apps/library/drizzle.config.ts +++ b/apps/library/drizzle.config.ts @@ -3,7 +3,7 @@ import type { Config } from "drizzle-kit"; import { env } from "~/env"; export default { - schema: "./src/server/db/schema.ts", + schema: "./src/server/db/schema/main-schema.ts", out: "./src/server/db/migrations", driver: "pg", dbCredentials: { diff --git a/apps/library/src/app/(auth)/signup/signup-form-experimental.tsx b/apps/library/src/app/(auth)/signup/signup-form-experimental.tsx index fd5a62b..1e09487 100644 --- a/apps/library/src/app/(auth)/signup/signup-form-experimental.tsx +++ b/apps/library/src/app/(auth)/signup/signup-form-experimental.tsx @@ -22,7 +22,7 @@ import { import { Input } from "~/components/ui/input"; import { lucia } from "~/server/auth"; import { db } from "~/server/db/index"; -import { user } from "~/server/db/schema"; +import { user } from "~/server/db/schema/main-schema"; const formSchema = z.object({ username: z.string().min(8, "Username too short").max(50), diff --git a/apps/library/src/server/actions.ts b/apps/library/src/server/actions.ts index f918819..fffbfa8 100644 --- a/apps/library/src/server/actions.ts +++ b/apps/library/src/server/actions.ts @@ -7,7 +7,7 @@ import { generateId, Scrypt } from "lucia"; import { lucia, validateRequest } from "~/server/auth"; import { db } from "~/server/db/index"; -import { user } from "./db/schema"; +import { user } from "./db/schema/main-schema"; interface ActionResult { error: string; diff --git a/apps/library/src/server/auth.ts b/apps/library/src/server/auth.ts index 8914091..01aa290 100644 --- a/apps/library/src/server/auth.ts +++ b/apps/library/src/server/auth.ts @@ -5,7 +5,7 @@ import { DrizzlePostgreSQLAdapter } from "@lucia-auth/adapter-drizzle"; import { Lucia } from "lucia"; import { db } from "~/server/db/index"; -import { session, user } from "~/server/db/schema"; +import { session, user } from "~/server/db/schema/main-schema"; const adapter = new DrizzlePostgreSQLAdapter(db, session, user); diff --git a/apps/library/src/server/db/index.ts b/apps/library/src/server/db/index.ts index acd6785..83e03f5 100644 --- a/apps/library/src/server/db/index.ts +++ b/apps/library/src/server/db/index.ts @@ -3,7 +3,7 @@ import { drizzle } from "drizzle-orm/postgres-js"; import postgres from "postgres"; import { env } from "~/env.js"; -import * as schema from "./schema"; +import * as schema from "./schema/main-schema"; // Fix for "sorry, too many clients already" declare global { diff --git a/apps/library/src/server/db/schema.ts b/apps/library/src/server/db/schema/auth-schema.ts similarity index 100% rename from apps/library/src/server/db/schema.ts rename to apps/library/src/server/db/schema/auth-schema.ts diff --git a/apps/library/src/server/db/schema/main-schema.ts b/apps/library/src/server/db/schema/main-schema.ts new file mode 100644 index 0000000..a222139 --- /dev/null +++ b/apps/library/src/server/db/schema/main-schema.ts @@ -0,0 +1,3 @@ +import { session, user } from "./auth-schema"; + +export { session, user };