Skip to content

Commit

Permalink
♻️ refactor (library): Refactored schema into separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
aryanprince committed Mar 4, 2024
1 parent 0b6566d commit 9042ac7
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/library/drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion apps/library/src/server/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion apps/library/src/server/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion apps/library/src/server/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions apps/library/src/server/db/schema/main-schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { session, user } from "./auth-schema";

export { session, user };

0 comments on commit 9042ac7

Please sign in to comment.