feat: initial sbsports deployment setup
Add Coolify/Woodpecker CI config, .gitignore, and deployment scripts.
This commit is contained in:
45
server/db.js
Normal file
45
server/db.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import Database from "better-sqlite3";
|
||||
import { join, dirname } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { mkdirSync } from "fs";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const DATA_DIR = process.env.DATA_DIR || join(__dirname, "../data");
|
||||
mkdirSync(DATA_DIR, { recursive: true });
|
||||
|
||||
const db = new Database(join(DATA_DIR, "db.sqlite"));
|
||||
|
||||
// Enable WAL for better concurrent read performance
|
||||
db.pragma("journal_mode = WAL");
|
||||
db.pragma("foreign_keys = ON");
|
||||
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS students (
|
||||
id TEXT PRIMARY KEY,
|
||||
firstName TEXT NOT NULL,
|
||||
lastName TEXT NOT NULL,
|
||||
age INTEGER,
|
||||
sex TEXT,
|
||||
weight REAL,
|
||||
height REAL,
|
||||
imc REAL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS activities (
|
||||
id TEXT PRIMARY KEY,
|
||||
studentId TEXT NOT NULL REFERENCES students(id) ON DELETE CASCADE,
|
||||
type TEXT,
|
||||
durationInput REAL,
|
||||
durationUnit TEXT,
|
||||
duration REAL,
|
||||
displayDuration TEXT,
|
||||
intensity TEXT,
|
||||
lifestyle TEXT,
|
||||
anxiety INTEGER DEFAULT 0,
|
||||
grade TEXT,
|
||||
date TEXT,
|
||||
createdAt TEXT DEFAULT (datetime('now'))
|
||||
);
|
||||
`);
|
||||
|
||||
export default db;
|
||||
Reference in New Issue
Block a user