fix: déplacer migration csg/crds/solidarite avant le seed taux_pfu
La migration ALTER TABLE ADD COLUMN pour csg, crds et solidarite s'exécutait après le seed qui tentait d'insérer ces colonnes, provoquant un crash SQLite. Déplace le bloc de migration avant le seed pour respecter l'ordre d'exécution.
This commit is contained in:
+20
-19
@@ -493,6 +493,26 @@ db.exec('CREATE INDEX IF NOT EXISTS idx_garantie_types_user ON garantie_types(us
|
||||
}
|
||||
}
|
||||
|
||||
// ── Migration : détail des taux 2778-SD sur taux_pfu ─────────────────────────
|
||||
// Décompose prelev_sociaux en ses 3 composantes pour le calcul de la déclaration
|
||||
// mensuelle 2778-SD (taux identiques au PFU global mais ventilés par case).
|
||||
// Taux 2021-2025 : CSG 9,2 % | CRDS 0,5 % | Solidarité 7,5 % → total 17,2 %
|
||||
// Taux 2026+ : CSG 10,6 %| CRDS 0,5 % | Solidarité 7,5 % → total 18,6 %
|
||||
{
|
||||
const pfuCols = db.prepare('PRAGMA table_info(taux_pfu)').all().map(c => c.name);
|
||||
if (!pfuCols.includes('csg')) {
|
||||
db.exec('ALTER TABLE taux_pfu ADD COLUMN csg REAL NOT NULL DEFAULT 9.2');
|
||||
// Mise à jour des années 2026+ où la CSG passe à 10,6 %
|
||||
db.exec('UPDATE taux_pfu SET csg = 10.6 WHERE annee >= 2026');
|
||||
}
|
||||
if (!pfuCols.includes('crds')) {
|
||||
db.exec('ALTER TABLE taux_pfu ADD COLUMN crds REAL NOT NULL DEFAULT 0.5');
|
||||
}
|
||||
if (!pfuCols.includes('solidarite')) {
|
||||
db.exec('ALTER TABLE taux_pfu ADD COLUMN solidarite REAL NOT NULL DEFAULT 7.5');
|
||||
}
|
||||
}
|
||||
|
||||
// ── Seed taux_pfu si vide ─────────────────────────────────────────────
|
||||
const pfuCount = db.prepare('SELECT COUNT(*) AS n FROM taux_pfu').get().n;
|
||||
if (pfuCount === 0) {
|
||||
@@ -999,25 +1019,6 @@ db.exec(`
|
||||
}
|
||||
}
|
||||
|
||||
// ── Migration : détail des taux 2778-SD sur taux_pfu ─────────────────────────
|
||||
// Décompose prelev_sociaux en ses 3 composantes pour le calcul de la déclaration
|
||||
// mensuelle 2778-SD (taux identiques au PFU global mais ventilés par case).
|
||||
// Taux 2021-2025 : CSG 9,2 % | CRDS 0,5 % | Solidarité 7,5 % → total 17,2 %
|
||||
// Taux 2026+ : CSG 10,6 %| CRDS 0,5 % | Solidarité 7,5 % → total 18,6 %
|
||||
{
|
||||
const pfuCols = db.prepare('PRAGMA table_info(taux_pfu)').all().map(c => c.name);
|
||||
if (!pfuCols.includes('csg')) {
|
||||
db.exec('ALTER TABLE taux_pfu ADD COLUMN csg REAL NOT NULL DEFAULT 9.2');
|
||||
// Mise à jour des années 2026+ où la CSG passe à 10,6 %
|
||||
db.exec('UPDATE taux_pfu SET csg = 10.6 WHERE annee >= 2026');
|
||||
}
|
||||
if (!pfuCols.includes('crds')) {
|
||||
db.exec('ALTER TABLE taux_pfu ADD COLUMN crds REAL NOT NULL DEFAULT 0.5');
|
||||
}
|
||||
if (!pfuCols.includes('solidarite')) {
|
||||
db.exec('ALTER TABLE taux_pfu ADD COLUMN solidarite REAL NOT NULL DEFAULT 7.5');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ── Table taux_credit_impot — Référentiel 2047 crédit d'impôt par pays ───────
|
||||
|
||||
Reference in New Issue
Block a user