Mise en place des objectifs
This commit is contained in:
@@ -2222,4 +2222,23 @@ console.log('[DB] Migrations 2FA OK');
|
||||
]);
|
||||
}
|
||||
|
||||
// ── Migration : table objectifs ──────────────────────────────────────────
|
||||
// Objectifs annuels par investisseur. `type` permet de réutiliser la table
|
||||
// pour d'autres natures d'objectifs plus tard (ex: 'rendement_annuel') —
|
||||
// pour l'instant seul 'versement_annuel' (objectif de dépôts nets) est utilisé.
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS objectifs (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
investisseur_id INTEGER NOT NULL REFERENCES investisseurs(id) ON DELETE CASCADE,
|
||||
type TEXT NOT NULL DEFAULT 'versement_annuel',
|
||||
annee INTEGER NOT NULL,
|
||||
montant REAL NOT NULL,
|
||||
notes TEXT,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
UNIQUE(investisseur_id, type, annee)
|
||||
)
|
||||
`);
|
||||
db.exec('CREATE INDEX IF NOT EXISTS idx_objectifs_investisseur ON objectifs(investisseur_id, type, annee)');
|
||||
|
||||
export default db;
|
||||
|
||||
Reference in New Issue
Block a user