example for drizzle + SQLite + next.js + migrate -> docker

Has anyone seen an example for drizzle + SQLite + next.js + migrate -> docker?
1 Reply
Aaqu
AaquOP2mo ago
seems to work, *don't forget to copy in dockerfile the drizzle folder **I skip static generation "build": "next build --experimental-build-mode=compile",
const dbPath = path.join(
"/",
process.env.NODE_ENV === "production" ? String(process.env.PROD_DB) : String(process.env.DEV_DB),
);
const dbExists = fs.existsSync(dbPath);
const sqlite = new Database(dbPath);
export const db: BetterSQLite3Database = drizzle(sqlite);

if (!dbExists) {
console.log("Database does not exist. Creating a new one...");
migrate(db, {
migrationsFolder: path.join(process.cwd(), "drizzle"),
});
}
const dbPath = path.join(
"/",
process.env.NODE_ENV === "production" ? String(process.env.PROD_DB) : String(process.env.DEV_DB),
);
const dbExists = fs.existsSync(dbPath);
const sqlite = new Database(dbPath);
export const db: BetterSQLite3Database = drizzle(sqlite);

if (!dbExists) {
console.log("Database does not exist. Creating a new one...");
migrate(db, {
migrationsFolder: path.join(process.cwd(), "drizzle"),
});
}
if you are using the next docker example, you need to add write permissions to the drizzle path
Want results from more Discord servers?
Add your server