crea db con lo mínimo
parent
a4ca22df2e
commit
7e3684522f
Binary file not shown.
@ -1,7 +1,24 @@
|
|||||||
/** @typedef {typeof import('better-sqlite3')} better-sqlite3 */
|
/** @typedef {typeof import('better-sqlite3')} better-sqlite3 */
|
||||||
import Database from '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("journal_mode = WAL");
|
||||||
db.pragma("synchronous = normal");
|
db.pragma("synchronous = normal");
|
||||||
db.pragma("temp_store = memory");
|
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();
|
||||||
|
Loading…
Reference in New Issue