34 lines
979 B
JavaScript
34 lines
979 B
JavaScript
const sqlite3 = require("sqlite3").verbose();
|
|
const path = require('path');
|
|
|
|
const dbPath = process.env.DATABASE_PATH || '../';
|
|
const db = new sqlite3.Database(path.join(dbPath, 'database.sqlite'));
|
|
|
|
// db.serialize(() => {
|
|
// db.run(`
|
|
// CREATE TABLE IF NOT EXISTS sheeps (
|
|
// id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
// uuid TEXT UNIQUE
|
|
// )
|
|
// `);
|
|
|
|
// db.run(`
|
|
// CREATE TABLE IF NOT EXISTS administrators (
|
|
// sheep_id INTEGER PRIMARY KEY,
|
|
// can_view_sheeps INTEGER DEFAULT 0,
|
|
// FOREIGN KEY (sheep_id) REFERENCES sheeps(id)
|
|
// )
|
|
// `);
|
|
|
|
// db.run(`
|
|
// CREATE TABLE IF NOT EXISTS sessions (
|
|
// session_id TEXT PRIMARY KEY,
|
|
// sheep_id INTEGER,
|
|
// role TEXT DEFAULT 'sheep',
|
|
// expires_at INTEGER,
|
|
// FOREIGN KEY (sheep_id) REFERENCES sheeps(id)
|
|
// )
|
|
// `);
|
|
// });
|
|
|
|
module.exports = db; |