Ajout couts par service (cloud, site, mail, user) + resume admin detaille HT

This commit is contained in:
2026-08-24 12:59:36 +00:00
parent 84011ac243
commit 8cd9e75682
4 changed files with 107 additions and 18 deletions
+14
View File
@@ -35,12 +35,26 @@ db.exec(`
team_members TEXT DEFAULT '[]',
notes TEXT DEFAULT '',
monthly_price REAL DEFAULT 0,
cloud_cost REAL DEFAULT 0,
website_cost REAL DEFAULT 0,
email_cost REAL DEFAULT 0,
user_cost REAL DEFAULT 0,
created_at TEXT DEFAULT (datetime('now')),
updated_at TEXT DEFAULT (datetime('now')),
FOREIGN KEY (parent_id) REFERENCES domains(id)
);
`);
// Migration: add cost columns if missing
const columns = db.prepare('PRAGMA table_info(domains)').all().map(c => c.name);
const addCostCol = (col) => {
if (!columns.includes(col)) db.exec('ALTER TABLE domains ADD COLUMN ' + col + ' REAL DEFAULT 0');
};
addCostCol('cloud_cost');
addCostCol('website_cost');
addCostCol('email_cost');
addCostCol('user_cost');
const userCount = db.prepare('SELECT COUNT(*) as count FROM users').get().count;
if (userCount === 0) {
const insert = db.prepare('INSERT INTO users (username, password_hash, name, role) VALUES (?, ?, ?, ?)');