freesched/db/init.js

19 lines
669 B
JavaScript
Raw Normal View History

2025-02-21 20:20:12 +00:00
// db/init.js
const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('db/freesched.db');
db.serialize(() => {
db.run(`CREATE TABLE IF NOT EXISTS availability (
id INTEGER PRIMARY KEY AUTOINCREMENT,
date TEXT NOT NULL UNIQUE,
times TEXT NOT NULL
)`);
// Example initial data for April 2021 (matching screenshot)
db.run(`INSERT OR IGNORE INTO availability (date, times) VALUES (?, ?)`,
['2025-02-21', '9:30am,10:00am,10:30am,11:00am,11:30am,2:00pm']);
db.run(`INSERT OR IGNORE INTO availability (date, times) VALUES (?, ?)`,
['2025-02-22', '10:00am,11:00am,2:00pm']);
});
db.close();