Struggling to setup postgresql in prod, pglite in dev

i have the following drizzle-dev.config.ts:
import { defineConfig } from "drizzle-kit";

export default defineConfig({
out: "./drizzle",
schema: "./lib/server/schema/index.ts",
dialect: "postgresql",
driver: "pglite",
dbCredentials: {
url: "./dev-db",
},
});
import { defineConfig } from "drizzle-kit";

export default defineConfig({
out: "./drizzle",
schema: "./lib/server/schema/index.ts",
dialect: "postgresql",
driver: "pglite",
dbCredentials: {
url: "./dev-db",
},
});
i have the drizzle-prod.config.ts:
import { defineConfig } from "drizzle-kit";
import { env } from "~/lib/env/server";

export default defineConfig({
out: "./drizzle",
schema: "./lib/server/schema/index.ts",
breakpoints: true,
dialect: "postgresql",
dbCredentials: {
url: env.DATABASE_URL,
},
});
import { defineConfig } from "drizzle-kit";
import { env } from "~/lib/env/server";

export default defineConfig({
out: "./drizzle",
schema: "./lib/server/schema/index.ts",
breakpoints: true,
dialect: "postgresql",
dbCredentials: {
url: env.DATABASE_URL,
},
});
db.ts
import { drizzle as drizzlePostgres } from "drizzle-orm/postgres-js";
import { drizzle as drizzlePGLite } from "drizzle-orm/pglite";
import postgres from "postgres";
import { env } from "../env/server";
import * as schema from "./schema";
import { migrate } from "drizzle-orm/pglite/migrator";

export const table = schema;

function initDb() {
if (import.meta.env.PROD) {
const driver = postgres(env.DATABASE_URL);
const db = drizzlePostgres(driver, { schema });
return db;
}
return drizzlePGLite("./dev-db", { schema });
}

export const db = initDb();
import { drizzle as drizzlePostgres } from "drizzle-orm/postgres-js";
import { drizzle as drizzlePGLite } from "drizzle-orm/pglite";
import postgres from "postgres";
import { env } from "../env/server";
import * as schema from "./schema";
import { migrate } from "drizzle-orm/pglite/migrator";

export const table = schema;

function initDb() {
if (import.meta.env.PROD) {
const driver = postgres(env.DATABASE_URL);
const db = drizzlePostgres(driver, { schema });
return db;
}
return drizzlePGLite("./dev-db", { schema });
}

export const db = initDb();
what im noticing is the db is allowing insertions but not being show in drizzle studio or querys until i restart the dev server Is it even possible to do what im trying to do? Am i doing something wrong?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?