Initial commit
This commit is contained in:
35
svar-gantt-app/scripts/init-db.ts
Normal file
35
svar-gantt-app/scripts/init-db.ts
Normal file
@ -0,0 +1,35 @@
|
||||
// scripts/init-db.ts
|
||||
import Database from 'better-sqlite3';
|
||||
import { mkdirSync, existsSync } from 'fs';
|
||||
|
||||
if (!existsSync('data')) {
|
||||
mkdirSync('data');
|
||||
}
|
||||
|
||||
const db = new Database('data.db');
|
||||
|
||||
db.exec(`
|
||||
DROP TABLE IF EXISTS tasks;
|
||||
DROP TABLE IF EXISTS links;
|
||||
|
||||
CREATE TABLE tasks (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
text TEXT NOT NULL,
|
||||
start TEXT NOT NULL,
|
||||
end TEXT NOT NULL,
|
||||
duration INTEGER,
|
||||
progress INTEGER,
|
||||
type TEXT,
|
||||
parent INTEGER,
|
||||
lazy BOOLEAN DEFAULT 0 -- ✅ Ajout ici
|
||||
);
|
||||
|
||||
CREATE TABLE links (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
source INTEGER,
|
||||
target INTEGER,
|
||||
type TEXT
|
||||
);
|
||||
`);
|
||||
|
||||
console.log('✅ Base de données initialisée avec succès.');
|
||||
Reference in New Issue
Block a user