I see this error with the app, reported by NextJS, please fix it. The er
This commit is contained in:
+8
-7
@@ -9,9 +9,9 @@ db.pragma('journal_mode = WAL');
|
||||
// Auth.js tables
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id TEXT PRIMARY KEY,
|
||||
id TEXT NOT NULL PRIMARY KEY,
|
||||
name TEXT,
|
||||
email TEXT UNIQUE,
|
||||
email TEXT NOT NULL UNIQUE,
|
||||
emailVerified INTEGER,
|
||||
image TEXT,
|
||||
password TEXT
|
||||
@@ -92,13 +92,14 @@ db.exec(`
|
||||
`);
|
||||
|
||||
// --- SCHEMA MIGRATION ---
|
||||
// This will add the emailVerified column if it doesn't exist, fixing old DBs.
|
||||
// This will add the columns if it doesn't exist, fixing old DBs.
|
||||
try {
|
||||
const columns = db.pragma('table_info(users)');
|
||||
const hasEmailVerified = columns.some((col: any) => col.name === 'emailVerified');
|
||||
if (!hasEmailVerified) {
|
||||
if (!columns.some((col: any) => col.name === 'emailVerified')) {
|
||||
db.exec('ALTER TABLE users ADD COLUMN emailVerified INTEGER');
|
||||
console.log('Migrated users table, added emailVerified column.');
|
||||
}
|
||||
if (!columns.some((col: any) => col.name === 'password')) {
|
||||
db.exec('ALTER TABLE users ADD COLUMN password TEXT');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Could not migrate users table:", e);
|
||||
@@ -116,7 +117,7 @@ if (!defaultUser) {
|
||||
"INSERT INTO users (id, email, password, name, emailVerified) VALUES (?, ?, ?, ?, ?)"
|
||||
);
|
||||
// Note: In a real app, hash the password!
|
||||
insertUser.run('cl-admin-user-id', 'admin@example.com', 'password', 'Admin User', null);
|
||||
insertUser.run('cl-admin-user-id', 'admin@example.com', 'password', 'Admin User', Date.now());
|
||||
console.log('Default user created.');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user