can't find meta/_journal.json file on prod | DRIZZLE

Hi folks, I've finally moved my database and orm to drizzle and pg (I'm using render.com pg database for now) from prisma and mongodb. Everything works fine on local dev and prod envs. However, I'm having this error when my application tries to connect to db in production:
Error: Can't find meta/_journal.json file
at /var/task/.next/server/chunks/693.js:7:29054
at a (/var/task/.next/server/chunks/693.js:7:29499)
at /var/task/.next/server/chunks/3753.js:1:1875
at t.a (/var/task/.next/server/webpack-runtime.js:1:889)
at 8194 (/var/task/.next/server/chunks/3753.js:1:1694)
at t (/var/task/.next/server/webpack-runtime.js:1:128)
at /var/task/.next/server/chunks/3753.js:1:5088
at t.a (/var/task/.next/server/webpack-runtime.js:1:889)
at 63753 (/var/task/.next/server/chunks/3753.js:1:4969)
at t (/var/task/.next/server/webpack-runtime.js:1:128) {
page: '/api/auth/session'
}
Error: Can't find meta/_journal.json file
at /var/task/.next/server/chunks/693.js:7:29054
at a (/var/task/.next/server/chunks/693.js:7:29499)
at /var/task/.next/server/chunks/3753.js:1:1875
at t.a (/var/task/.next/server/webpack-runtime.js:1:889)
at 8194 (/var/task/.next/server/chunks/3753.js:1:1694)
at t (/var/task/.next/server/webpack-runtime.js:1:128)
at /var/task/.next/server/chunks/3753.js:1:5088
at t.a (/var/task/.next/server/webpack-runtime.js:1:889)
at 63753 (/var/task/.next/server/chunks/3753.js:1:4969)
at t (/var/task/.next/server/webpack-runtime.js:1:128) {
page: '/api/auth/session'
}
I see this solution shared on the drizzle forum which I already did before: https://www.answeroverflow.com/m/1093225882879017080 see below for my drizzle configs
// db/index.ts
import { drizzle } from "drizzle-orm/postgres-js";
import { migrate } from "drizzle-orm/postgres-js/migrator";
import postgres from "postgres";
import * as schema from "./schema";
import "dotenv/config";

const sql = postgres(process.env.DATABASE_URL!, { max: 1 });
export const db = drizzle(sql, { schema });

await migrate(db, { migrationsFolder: "drizzle/migrations" });
// db/index.ts
import { drizzle } from "drizzle-orm/postgres-js";
import { migrate } from "drizzle-orm/postgres-js/migrator";
import postgres from "postgres";
import * as schema from "./schema";
import "dotenv/config";

const sql = postgres(process.env.DATABASE_URL!, { max: 1 });
export const db = drizzle(sql, { schema });

await migrate(db, { migrationsFolder: "drizzle/migrations" });
// drizzle.config.ts
import { Config, defineConfig } from "drizzle-kit";
import * as dotenv from "dotenv";
dotenv.config({
path: ".env.local",
});
export default defineConfig({
schema: "./db/schema.ts",
driver: "pg",
dbCredentials: {
connectionString: process.env.DATABASE_URL as string,
ssl: true,
},
verbose: true,
strict: true,
out: "./drizzle/migrations",
}) satisfies Config;
// drizzle.config.ts
import { Config, defineConfig } from "drizzle-kit";
import * as dotenv from "dotenv";
dotenv.config({
path: ".env.local",
});
export default defineConfig({
schema: "./db/schema.ts",
driver: "pg",
dbCredentials: {
connectionString: process.env.DATABASE_URL as string,
ssl: true,
},
verbose: true,
strict: true,
out: "./drizzle/migrations",
}) satisfies Config;
you can see my drizzle folder in the first picture. I can see the same folder structure and _journal.json file on vercel source page (pic 2) Do you have any idea to solve this error? Thanks in advance for your helps! Let me know if you require more information about the project or question. the repo: https://github.com/4Furki4/Turkish-Dictionary (branch 4furki4/issue55) live: https://turkish-dictionary-git-4furki4-issue55-4furki4.vercel.app/
No description
No description
1 Reply
Furki4_4
Furki4_4OP13mo ago
calling this async migrate function in the migrateToLatest seems solved the issue. BUT IDK WHY
export const migrateToLatest = async () => {
await migrate(db, { migrationsFolder: "drizzle/migrations" });
};
export const migrateToLatest = async () => {
await migrate(db, { migrationsFolder: "drizzle/migrations" });
};
Want results from more Discord servers?
Add your server