Overview
Comment:Fix migration
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev | 1.0.0-alpha3
Files: files | file ages | folders
SHA1: cd548120ebcbdf012bebe12377ef9b4682d51e87
User & Date: bohwaz on 2020-11-01 12:48:10
Other Links: branch diff | manifest | tags
Context
2020-11-01
13:20
Fix: balance sheet had errors with negative sums. Some assets can be negative and must be left as negative. check-in: 12d73e8cb4 user: bohwaz tags: dev, 1.0.0-alpha3
12:48
Fix migration check-in: cd548120eb user: bohwaz tags: dev, 1.0.0-alpha3
02:42
New release to test check-in: 7ae0fed6a2 user: bohwaz tags: dev, 1.0.0-alpha3
Changes

Modified src/include/data/1.0.0_migration.sql from [517448ff3c] to [1a4afa91ca].

102
103
104
105
106
107
108

109
110
111
112
113
114
115

--------- MIGRATION COTISATIONS ----------

INSERT INTO services SELECT id, intitule, description, duree, debut, fin FROM cotisations;
INSERT INTO services_users SELECT cm.id, cm.id_membre, cm.id_cotisation,
	NULL,
	1,

	CASE
		WHEN c.duree IS NOT NULL THEN date(cm.date, '+'||c.duree||' days')
		WHEN c.fin IS NOT NULL THEN c.fin
		ELSE NULL
	END
	FROM cotisations_membres cm
	INNER JOIN cotisations c ON c.id = cm.id_cotisation;







>







102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

--------- MIGRATION COTISATIONS ----------

INSERT INTO services SELECT id, intitule, description, duree, debut, fin FROM cotisations;
INSERT INTO services_users SELECT cm.id, cm.id_membre, cm.id_cotisation,
	NULL,
	1,
	cm.date,
	CASE
		WHEN c.duree IS NOT NULL THEN date(cm.date, '+'||c.duree||' days')
		WHEN c.fin IS NOT NULL THEN c.fin
		ELSE NULL
	END
	FROM cotisations_membres cm
	INNER JOIN cotisations c ON c.id = cm.id_cotisation;

Modified src/include/data/1.0.0_schema.sql from [7a06e30bc9] to [9620b90e42].

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
    id INTEGER NOT NULL PRIMARY KEY,
    id_user INTEGER NOT NULL REFERENCES membres (id) ON DELETE CASCADE,
    id_service INTEGER NOT NULL REFERENCES services (id) ON DELETE CASCADE,
    id_fee INTEGER NULL REFERENCES services_fees (id) ON DELETE CASCADE,

    paid INTEGER NOT NULL DEFAULT 0,

    date TEXT NULL DEFAULT CURRENT_DATE CHECK (date(date) IS NOT NULL AND date(date) = date)
    expiry_date TEXT NULL CHECK (date(expiry_date) IS NULL OR date(expiry_date) = expiry_date)
);

CREATE UNIQUE INDEX IF NOT EXISTS su_unique ON services_users (id_user, id_service, expiry_date);

CREATE TABLE IF NOT EXISTS services_reminders
-- Rappels de devoir renouveller une cotisation
(
    id INTEGER NOT NULL PRIMARY KEY,
    id_service INTEGER NOT NULL REFERENCES services (id) ON DELETE CASCADE,








|



|







67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
    id INTEGER NOT NULL PRIMARY KEY,
    id_user INTEGER NOT NULL REFERENCES membres (id) ON DELETE CASCADE,
    id_service INTEGER NOT NULL REFERENCES services (id) ON DELETE CASCADE,
    id_fee INTEGER NULL REFERENCES services_fees (id) ON DELETE CASCADE,

    paid INTEGER NOT NULL DEFAULT 0,

    date TEXT NULL DEFAULT CURRENT_DATE CHECK (date(date) IS NOT NULL AND date(date) = date),
    expiry_date TEXT NULL CHECK (date(expiry_date) IS NULL OR date(expiry_date) = expiry_date)
);

CREATE UNIQUE INDEX IF NOT EXISTS su_unique ON services_users (id_user, id_service, date);

CREATE TABLE IF NOT EXISTS services_reminders
-- Rappels de devoir renouveller une cotisation
(
    id INTEGER NOT NULL PRIMARY KEY,
    id_service INTEGER NOT NULL REFERENCES services (id) ON DELETE CASCADE,