Datepicker redesign + DB connection fixes for Prod

This commit is contained in:
AG
2025-12-18 20:49:34 +02:00
parent 3a8f132b91
commit b6cb3059af
10 changed files with 472 additions and 78 deletions

View File

@@ -54,10 +54,33 @@ async function resetDb() {
// 4. Create the Admin user
console.log(`Creating fresh admin user...`);
// In Prisma 7, we must use the adapter for better-sqlite3
// In Prisma 7, PrismaBetterSqlite3 is a factory.
// We use the factory to create the adapter, then we access the internal client
// to disable WAL mode for NAS/Network share compatibility (journal_mode = DELETE).
const { PrismaBetterSqlite3 } = require('@prisma/adapter-better-sqlite3');
const adapter = new PrismaBetterSqlite3({ url: dbPath });
const prisma = new PrismaClient({ adapter });
const factory = new PrismaBetterSqlite3({ url: dbPath });
const adapterWrapper = {
provider: 'sqlite',
adapterName: '@prisma/adapter-better-sqlite3',
async connect() {
const adapter = await factory.connect();
if (adapter.client) {
console.log(`Setting journal_mode = DELETE for NAS compatibility`);
adapter.client.pragma('journal_mode = DELETE');
}
return adapter;
},
async connectToShadowDb() {
const adapter = await factory.connectToShadowDb();
if (adapter.client) {
adapter.client.pragma('journal_mode = DELETE');
}
return adapter;
}
};
const prisma = new PrismaClient({ adapter: adapterWrapper });
try {
const hashedPassword = await bcrypt.hash(adminPassword, 10);