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
|
// Auth.js tables
|
||||||
db.exec(`
|
db.exec(`
|
||||||
CREATE TABLE IF NOT EXISTS users (
|
CREATE TABLE IF NOT EXISTS users (
|
||||||
id TEXT PRIMARY KEY,
|
id TEXT NOT NULL PRIMARY KEY,
|
||||||
name TEXT,
|
name TEXT,
|
||||||
email TEXT UNIQUE,
|
email TEXT NOT NULL UNIQUE,
|
||||||
emailVerified INTEGER,
|
emailVerified INTEGER,
|
||||||
image TEXT,
|
image TEXT,
|
||||||
password TEXT
|
password TEXT
|
||||||
@@ -92,13 +92,14 @@ db.exec(`
|
|||||||
`);
|
`);
|
||||||
|
|
||||||
// --- SCHEMA MIGRATION ---
|
// --- 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 {
|
try {
|
||||||
const columns = db.pragma('table_info(users)');
|
const columns = db.pragma('table_info(users)');
|
||||||
const hasEmailVerified = columns.some((col: any) => col.name === 'emailVerified');
|
if (!columns.some((col: any) => col.name === 'emailVerified')) {
|
||||||
if (!hasEmailVerified) {
|
|
||||||
db.exec('ALTER TABLE users ADD COLUMN emailVerified INTEGER');
|
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) {
|
} catch (e) {
|
||||||
console.error("Could not migrate users table:", e);
|
console.error("Could not migrate users table:", e);
|
||||||
@@ -116,7 +117,7 @@ if (!defaultUser) {
|
|||||||
"INSERT INTO users (id, email, password, name, emailVerified) VALUES (?, ?, ?, ?, ?)"
|
"INSERT INTO users (id, email, password, name, emailVerified) VALUES (?, ?, ?, ?, ?)"
|
||||||
);
|
);
|
||||||
// Note: In a real app, hash the password!
|
// 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.');
|
console.log('Default user created.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user