diff --git a/src/lib/db/carteles_dev.sqlite b/src/lib/db/carteles_dev.sqlite index e69de29..7f0c286 100644 Binary files a/src/lib/db/carteles_dev.sqlite and b/src/lib/db/carteles_dev.sqlite differ diff --git a/src/lib/db/db.js b/src/lib/db/db.js index fa7d436..e1bbf28 100644 --- a/src/lib/db/db.js +++ b/src/lib/db/db.js @@ -1,7 +1,24 @@ /** @typedef {typeof import('better-sqlite3')} better-sqlite3 */ import Database from 'better-sqlite3'; -export const db = new Database('./carteles_dev.sqlite', { verbose: console.log }) +export const db = new Database('./carteles_dev.sqlite', { fileMustExist: true, verbose: console.log }) db.pragma("journal_mode = WAL"); db.pragma("synchronous = normal"); db.pragma("temp_store = memory"); + +const createUserTable = db.prepare(`CREATE TABLE IF NOT EXISTS Users ( + email TEXT PRIMARY KEY UNIQUE NOT NULL, + password TEXT, + isAdmin INTEGER + );`); + +const createPostersTable = db.prepare(`CREATE TABLE IF NOT EXISTS Posters ( + id INTEGER PRIMARY KEY UNIQUE NOT NULL, + image BLOB, + template TEXT, + name TEXT, + content TEXT +);`); + +createUserTable.run(); +createPostersTable.run();