Aaqu
Aaqu
DTDrizzle Team
Created by Aaqu on 9/20/2024 in #help
example for drizzle + SQLite + next.js + migrate -> docker
if you are using the next docker example, you need to add write permissions to the drizzle path
3 replies
DTDrizzle Team
Created by Aaqu on 9/20/2024 in #help
example for drizzle + SQLite + next.js + migrate -> docker
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"),
});
}
3 replies