Overview
Comment: | Utilisation des cascades pour nettoyer les foreign keys dans les tables (merci SQLite!) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA1: |
2bcf7bd531d101d68fc9a48909e1e8dc |
User & Date: | bohwaz on 2017-08-31 07:52:03 |
Other Links: | branch diff | manifest | tags |
Context
2017-09-01
| ||
03:44 | Refonte formulaire saisie compta pour pouvoir changer d'un type à l'autre sans recharger la page (et donc vider les champs) check-in: 563749cf65 user: bohwaz tags: dev | |
2017-08-31
| ||
07:52 | Utilisation des cascades pour nettoyer les foreign keys dans les tables (merci SQLite!) check-in: 2bcf7bd531 user: bohwaz tags: dev | |
07:24 | Modernisation code check-in: 10e35860a4 user: bohwaz tags: dev | |
Changes
Modified src/include/data/0.8.0.sql from [36649e1378] to [9ec86cab92].
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
..
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
-- Ajouter champ clé PGP
ALTER TABLE membres ADD COLUMN clef_pgp TEXT NULL;
--------------------------------------------------------------------------------
-- Mise à jour des tables contenant un champ date pour ajouter la contrainte --
-- Ceci afin de forcer les champs à contenir un format de date correct --
--------------------------------------------------------------------------------
-- Convertir les dates UNIX en date Y-m-d, apparemment il y en a encore parfois ?
UPDATE wiki_pages SET date_creation = datetime(date_creation, "unixepoch") WHERE CAST(date_creation AS INT) = date_creation;
UPDATE wiki_pages SET date_creation = datetime(date_creation) WHERE datetime(date_creation) != date_creation;
-- Renommage des tables qu'il faut mettre à jour
ALTER TABLE cotisations_membres RENAME TO cotisations_membres_old;
ALTER TABLE rappels_envoyes RENAME TO rappels_envoyes_old;
ALTER TABLE wiki_pages RENAME TO wiki_pages_old;
ALTER TABLE wiki_revisions RENAME TO wiki_revisions_old;
ALTER TABLE compta_exercices RENAME TO compta_exercices_old;
ALTER TABLE compta_journal RENAME TO compta_journal_old;
ALTER TABLE compta_rapprochement RENAME TO compta_rapprochement_old;
ALTER TABLE fichiers RENAME TO fichiers_old;
-- Suppression des index pour que les nouveaux soient liés aux nouvelles tables
DROP INDEX cm_unique;
DROP INDEX wiki_uri;
DROP INDEX wiki_revisions_id_page;
DROP INDEX wiki_revisions_id_auteur;
DROP INDEX compta_operations_exercice;
................................................................................
DROP TRIGGER wiki_recherche_contenu_chiffre;
-- Création des tables mises à jour (et de leurs index)
.read schema.sql
-- Copie des données
INSERT INTO cotisations_membres SELECT * FROM cotisations_membres_old;
INSERT INTO rappels_envoyes SELECT id, id_membre, id_cotisation, id_rappel, date, media FROM rappels_envoyes_old;
INSERT INTO wiki_pages SELECT * FROM wiki_pages_old;
INSERT INTO wiki_revisions SELECT * FROM wiki_revisions_old;
INSERT INTO compta_exercices SELECT * FROM compta_exercices_old;
INSERT INTO compta_journal SELECT * FROM compta_journal_old;
INSERT INTO compta_rapprochement SELECT * FROM compta_rapprochement_old;
INSERT INTO fichiers SELECT * FROM fichiers_old;
-- Suppression des anciennes tables
DROP TABLE cotisations_membres_old;
DROP TABLE rappels_envoyes_old;
DROP TABLE wiki_pages_old;
DROP TABLE wiki_revisions_old;
DROP TABLE compta_exercices_old;
DROP TABLE compta_journal_old;
DROP TABLE compta_rapprochement_old;
DROP TABLE fichiers_old;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
..
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
-- Ajouter champ clé PGP ALTER TABLE membres ADD COLUMN clef_pgp TEXT NULL; -------------------------------------------------------------------------------- -- Mise à jour des tables contenant un champ date pour ajouter la contrainte -- -- Ceci afin de forcer les champs à contenir un format de date correct -- -- On en profite pour ajouter les ON DELETE nécessaires -- -------------------------------------------------------------------------------- -- Convertir les dates UNIX en date Y-m-d, apparemment il y en a encore parfois ? UPDATE wiki_pages SET date_creation = datetime(date_creation, "unixepoch") WHERE CAST(date_creation AS INT) = date_creation; UPDATE wiki_pages SET date_creation = datetime(date_creation) WHERE datetime(date_creation) != date_creation; -- Renommage des tables qu'il faut mettre à jour ALTER TABLE cotisations_membres RENAME TO cotisations_membres_old; ALTER TABLE rappels RENAME TO rappels_old; ALTER TABLE rappels_envoyes RENAME TO rappels_envoyes_old; ALTER TABLE wiki_pages RENAME TO wiki_pages_old; ALTER TABLE wiki_revisions RENAME TO wiki_revisions_old; ALTER TABLE compta_categories RENAME TO compta_categories_old; ALTER TABLE compta_comptes_bancaires RENAME TO compta_comptes_bancaires_old; ALTER TABLE compta_exercices RENAME TO compta_exercices_old; ALTER TABLE compta_journal RENAME TO compta_journal_old; ALTER TABLE compta_rapprochement RENAME TO compta_rapprochement_old; ALTER TABLE fichiers RENAME TO fichiers_old; ALTER TABLE membres_operations RENAME TO membres_operations_old; ALTER TABLE membres_categories RENAME TO membres_categories_old; -- Suppression des index pour que les nouveaux soient liés aux nouvelles tables DROP INDEX cm_unique; DROP INDEX wiki_uri; DROP INDEX wiki_revisions_id_page; DROP INDEX wiki_revisions_id_auteur; DROP INDEX compta_operations_exercice; ................................................................................ DROP TRIGGER wiki_recherche_contenu_chiffre; -- Création des tables mises à jour (et de leurs index) .read schema.sql -- Copie des données INSERT INTO cotisations_membres SELECT * FROM cotisations_membres_old; INSERT INTO rappels SELECT * FROM rappels_old; INSERT INTO rappels_envoyes SELECT id, id_membre, id_cotisation, id_rappel, date, media FROM rappels_envoyes_old; INSERT INTO wiki_pages SELECT * FROM wiki_pages_old; INSERT INTO wiki_revisions SELECT * FROM wiki_revisions_old; INSERT INTO compta_categories SELECT * FROM compta_categories_old; INSERT INTO compta_comptes_bancaires SELECT * FROM compta_comptes_bancaires_old; INSERT INTO compta_exercices SELECT * FROM compta_exercices_old; INSERT INTO compta_journal SELECT * FROM compta_journal_old; INSERT INTO compta_rapprochement SELECT * FROM compta_rapprochement_old; INSERT INTO fichiers SELECT * FROM fichiers_old; INSERT INTO membres_operations SELECT * FROM membres_operations_old; INSERT INTO membres_categories SELECT * FROM membres_categories_old; -- Suppression des anciennes tables DROP TABLE cotisations_membres_old; DROP TABLE rappels_old; DROP TABLE rappels_envoyes_old; DROP TABLE wiki_pages_old; DROP TABLE wiki_revisions_old; DROP TABLE compta_categories_old; DROP TABLE compta_comptes_bancaires_old; DROP TABLE compta_exercices_old; DROP TABLE compta_journal_old; DROP TABLE compta_rapprochement_old; DROP TABLE fichiers_old; DROP TABLE membres_operations_old; DROP TABLE membres_categories_old; |
Modified src/include/data/schema.sql from [bbc47a008e] to [666c258805].
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 .. 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 ... 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 ... 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 ... 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 ... 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 ... 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
droit_membres INTEGER NOT NULL DEFAULT 1, droit_compta INTEGER NOT NULL DEFAULT 1, droit_inscription INTEGER NOT NULL DEFAULT 0, droit_connexion INTEGER NOT NULL DEFAULT 1, droit_config INTEGER NOT NULL DEFAULT 0, cacher INTEGER NOT NULL DEFAULT 0, id_cotisation_obligatoire INTEGER NULL REFERENCES cotisations (id) ); -- Membres de l'asso -- Table dynamique générée par l'application -- voir Garradin\Membres\Champs.php CREATE TABLE membres_sessions -- Sessions ( selecteur TEXT NOT NULL, hash TEXT NOT NULL, id_membre INTEGER NOT NULL, expire TEXT NOT NULL CHECK (datetime(expire) IS NOT NULL AND datetime(expire) = expire), FOREIGN KEY (id_membre) REFERENCES membres (id), PRIMARY KEY (selecteur, id_membre) ); CREATE TABLE IF NOT EXISTS cotisations -- Types de cotisations et activités ( id INTEGER PRIMARY KEY NOT NULL, ................................................................................ FOREIGN KEY (id_categorie_compta) REFERENCES compta_categories (id) ); CREATE TABLE IF NOT EXISTS cotisations_membres -- Enregistrement des cotisations et activités ( id INTEGER NOT NULL PRIMARY KEY, id_membre INTEGER NOT NULL REFERENCES membres (id), id_cotisation INTEGER NOT NULL REFERENCES cotisations (id), date TEXT NOT NULL DEFAULT CURRENT_DATE CHECK (date(date) IS NOT NULL AND date(date) = date) ); CREATE UNIQUE INDEX IF NOT EXISTS cm_unique ON cotisations_membres (id_membre, id_cotisation, date); CREATE TABLE IF NOT EXISTS membres_operations -- Liaision des enregistrement des paiements en compta ( id_membre INTEGER NOT NULL REFERENCES membres (id), id_operation INTEGER NOT NULL REFERENCES compta_journal (id), id_cotisation INTEGER NULL REFERENCES cotisations_membres (id), PRIMARY KEY (id_membre, id_operation) ); CREATE TABLE IF NOT EXISTS rappels -- Rappels de devoir renouveller une cotisation ( id INTEGER NOT NULL PRIMARY KEY, id_cotisation INTEGER NOT NULL REFERENCES cotisations (id), delai INTEGER NOT NULL, -- Délai en jours pour envoyer le rappel sujet TEXT NOT NULL, texte TEXT NOT NULL ); CREATE TABLE IF NOT EXISTS rappels_envoyes -- Enregistrement des rappels envoyés à qui et quand ( id INTEGER NOT NULL PRIMARY KEY, id_membre INTEGER NOT NULL REFERENCES membres (id), id_cotisation INTEGER NOT NULL REFERENCES cotisations (id), id_rappel INTEGER NULL REFERENCES rappels (id), date TEXT NOT NULL DEFAULT CURRENT_DATE CHECK (date(date) IS NOT NULL AND date(date) = date), media INTEGER NOT NULL -- Média utilisé pour le rappel : 1 = email, 2 = courrier, 3 = autre ); -- ................................................................................ contenu TEXT NULL, -- Contenu de la dernière révision FOREIGN KEY (id) REFERENCES wiki_pages(id) ); CREATE TABLE IF NOT EXISTS wiki_revisions -- Révisions du contenu des pages ( id_page INTEGER NOT NULL, revision INTEGER NULL, id_auteur INTEGER NULL, contenu TEXT NOT NULL, modification TEXT NULL, -- Description des modifications effectuées chiffrement INTEGER NOT NULL DEFAULT 0, -- 1 si le contenu est chiffré, 0 sinon date TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP CHECK (datetime(date) IS NOT NULL AND datetime(date) = date), PRIMARY KEY(id_page, revision), FOREIGN KEY (id_page) REFERENCES wiki_pages (id), -- Clé externe obligatoire FOREIGN KEY (id_auteur) REFERENCES membres (id) -- Clé externe non-obligatoire (peut être supprimée après en cas de suppression de membre) ); CREATE INDEX IF NOT EXISTS wiki_revisions_id_page ON wiki_revisions (id_page); CREATE INDEX IF NOT EXISTS wiki_revisions_id_auteur ON wiki_revisions (id_auteur); -- Triggers pour synchro avec table wiki_pages CREATE TRIGGER IF NOT EXISTS wiki_recherche_delete AFTER DELETE ON wiki_pages ................................................................................ id TEXT NOT NULL PRIMARY KEY, banque TEXT NOT NULL, iban TEXT NULL, bic TEXT NULL, FOREIGN KEY(id) REFERENCES compta_comptes(id) ); CREATE TABLE IF NOT EXISTS compta_journal -- Journal des opérations comptables ( id INTEGER PRIMARY KEY, ................................................................................ id_auteur INTEGER NULL, id_categorie INTEGER NULL, -- Numéro de catégorie (en mode simple) FOREIGN KEY(moyen_paiement) REFERENCES compta_moyens_paiement(code), FOREIGN KEY(compte_debit) REFERENCES compta_comptes(id), FOREIGN KEY(compte_credit) REFERENCES compta_comptes(id), FOREIGN KEY(id_exercice) REFERENCES compta_exercices(id), FOREIGN KEY(id_auteur) REFERENCES membres(id), FOREIGN KEY(id_categorie) REFERENCES compta_categories(id) ); CREATE INDEX IF NOT EXISTS compta_operations_exercice ON compta_journal (id_exercice); CREATE INDEX IF NOT EXISTS compta_operations_date ON compta_journal (date); CREATE INDEX IF NOT EXISTS compta_operations_comptes ON compta_journal (compte_debit, compte_credit); CREATE INDEX IF NOT EXISTS compta_operations_auteur ON compta_journal (id_auteur); ................................................................................ type INTEGER NOT NULL DEFAULT 1, -- 1 = recette, -1 = dépense, 0 = autre (utilisé uniquement pour l'interface) intitule TEXT NOT NULL, description TEXT NULL, compte TEXT NOT NULL, -- Compte affecté par cette catégorie FOREIGN KEY(compte) REFERENCES compta_comptes(id) ); CREATE TABLE IF NOT EXISTS plugins ( id TEXT NOT NULL PRIMARY KEY, officiel INTEGER NOT NULL DEFAULT 0, nom TEXT NOT NULL, ................................................................................ callback TEXT NOT NULL, PRIMARY KEY (signal, plugin) ); CREATE TABLE IF NOT EXISTS compta_rapprochement -- Rapprochement entre compta et relevés de comptes ( id_operation INTEGER NOT NULL PRIMARY KEY REFERENCES compta_journal (id), date TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP CHECK (datetime(date) IS NOT NULL AND datetime(date) = date), id_auteur INTEGER NULL REFERENCES membres (id) ); CREATE TABLE IF NOT EXISTS fichiers -- Données sur les fichiers ( id INTEGER NOT NULL PRIMARY KEY, nom TEXT NOT NULL, -- nom de fichier (par exemple image1234.jpeg) type TEXT NULL, -- Type MIME image INTEGER NOT NULL DEFAULT 0, -- 1 = image reconnue datetime TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP CHECK (datetime(datetime) IS NOT NULL AND datetime(datetime) = datetime), -- Date d'ajout ou mise à jour du fichier id_contenu INTEGER NOT NULL REFERENCES fichiers_contenu (id) ); CREATE INDEX IF NOT EXISTS fichiers_date ON fichiers (datetime); CREATE TABLE IF NOT EXISTS fichiers_contenu -- Contenu des fichiers ( |
| | | < | | | | | | | | | | | | < < | | | | | | |
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 .. 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 ... 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 ... 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 ... 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 ... 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 ... 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
droit_membres INTEGER NOT NULL DEFAULT 1, droit_compta INTEGER NOT NULL DEFAULT 1, droit_inscription INTEGER NOT NULL DEFAULT 0, droit_connexion INTEGER NOT NULL DEFAULT 1, droit_config INTEGER NOT NULL DEFAULT 0, cacher INTEGER NOT NULL DEFAULT 0, id_cotisation_obligatoire INTEGER NULL REFERENCES cotisations (id) ON DELETE SET NULL ); -- Membres de l'asso -- Table dynamique générée par l'application -- voir Garradin\Membres\Champs.php CREATE TABLE IF NOT EXISTS membres_sessions -- Sessions ( selecteur TEXT NOT NULL, hash TEXT NOT NULL, id_membre INTEGER NOT NULL REFERENCES membres (id) ON DELETE CASCADE, expire TEXT NOT NULL CHECK (datetime(expire) IS NOT NULL AND datetime(expire) = expire), PRIMARY KEY (selecteur, id_membre) ); CREATE TABLE IF NOT EXISTS cotisations -- Types de cotisations et activités ( id INTEGER PRIMARY KEY NOT NULL, ................................................................................ FOREIGN KEY (id_categorie_compta) REFERENCES compta_categories (id) ); CREATE TABLE IF NOT EXISTS cotisations_membres -- Enregistrement des cotisations et activités ( id INTEGER NOT NULL PRIMARY KEY, id_membre INTEGER NOT NULL REFERENCES membres (id) ON DELETE CASCADE, id_cotisation INTEGER NOT NULL REFERENCES cotisations (id) ON DELETE CASCADE, date TEXT NOT NULL DEFAULT CURRENT_DATE CHECK (date(date) IS NOT NULL AND date(date) = date) ); CREATE UNIQUE INDEX IF NOT EXISTS cm_unique ON cotisations_membres (id_membre, id_cotisation, date); CREATE TABLE IF NOT EXISTS membres_operations -- Liaision des enregistrement des paiements en compta ( id_membre INTEGER NOT NULL REFERENCES membres (id) ON DELETE CASCADE, id_operation INTEGER NOT NULL REFERENCES compta_journal (id) ON DELETE CASCADE, id_cotisation INTEGER NULL REFERENCES cotisations_membres (id) ON DELETE SET NULL, PRIMARY KEY (id_membre, id_operation) ); CREATE TABLE IF NOT EXISTS rappels -- Rappels de devoir renouveller une cotisation ( id INTEGER NOT NULL PRIMARY KEY, id_cotisation INTEGER NOT NULL REFERENCES cotisations (id) ON DELETE CASCADE, delai INTEGER NOT NULL, -- Délai en jours pour envoyer le rappel sujet TEXT NOT NULL, texte TEXT NOT NULL ); CREATE TABLE IF NOT EXISTS rappels_envoyes -- Enregistrement des rappels envoyés à qui et quand ( id INTEGER NOT NULL PRIMARY KEY, id_membre INTEGER NOT NULL REFERENCES membres (id) ON DELETE CASCADE, id_cotisation INTEGER NOT NULL REFERENCES cotisations (id) ON DELETE CASCADE, id_rappel INTEGER NULL REFERENCES rappels (id) ON DELETE CASCADE, date TEXT NOT NULL DEFAULT CURRENT_DATE CHECK (date(date) IS NOT NULL AND date(date) = date), media INTEGER NOT NULL -- Média utilisé pour le rappel : 1 = email, 2 = courrier, 3 = autre ); -- ................................................................................ contenu TEXT NULL, -- Contenu de la dernière révision FOREIGN KEY (id) REFERENCES wiki_pages(id) ); CREATE TABLE IF NOT EXISTS wiki_revisions -- Révisions du contenu des pages ( id_page INTEGER NOT NULL REFERENCES wiki_pages (id) ON DELETE CASCADE, revision INTEGER NULL, id_auteur INTEGER NULL REFERENCES membres (id) ON DELETE SET NULL, contenu TEXT NOT NULL, modification TEXT NULL, -- Description des modifications effectuées chiffrement INTEGER NOT NULL DEFAULT 0, -- 1 si le contenu est chiffré, 0 sinon date TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP CHECK (datetime(date) IS NOT NULL AND datetime(date) = date), PRIMARY KEY(id_page, revision) ); CREATE INDEX IF NOT EXISTS wiki_revisions_id_page ON wiki_revisions (id_page); CREATE INDEX IF NOT EXISTS wiki_revisions_id_auteur ON wiki_revisions (id_auteur); -- Triggers pour synchro avec table wiki_pages CREATE TRIGGER IF NOT EXISTS wiki_recherche_delete AFTER DELETE ON wiki_pages ................................................................................ id TEXT NOT NULL PRIMARY KEY, banque TEXT NOT NULL, iban TEXT NULL, bic TEXT NULL, FOREIGN KEY(id) REFERENCES compta_comptes(id) ON DELETE CASCADE ); CREATE TABLE IF NOT EXISTS compta_journal -- Journal des opérations comptables ( id INTEGER PRIMARY KEY, ................................................................................ id_auteur INTEGER NULL, id_categorie INTEGER NULL, -- Numéro de catégorie (en mode simple) FOREIGN KEY(moyen_paiement) REFERENCES compta_moyens_paiement(code), FOREIGN KEY(compte_debit) REFERENCES compta_comptes(id), FOREIGN KEY(compte_credit) REFERENCES compta_comptes(id), FOREIGN KEY(id_exercice) REFERENCES compta_exercices(id), FOREIGN KEY(id_auteur) REFERENCES membres(id) ON DELETE SET NULL, FOREIGN KEY(id_categorie) REFERENCES compta_categories(id) ON DELETE SET NULL ); CREATE INDEX IF NOT EXISTS compta_operations_exercice ON compta_journal (id_exercice); CREATE INDEX IF NOT EXISTS compta_operations_date ON compta_journal (date); CREATE INDEX IF NOT EXISTS compta_operations_comptes ON compta_journal (compte_debit, compte_credit); CREATE INDEX IF NOT EXISTS compta_operations_auteur ON compta_journal (id_auteur); ................................................................................ type INTEGER NOT NULL DEFAULT 1, -- 1 = recette, -1 = dépense, 0 = autre (utilisé uniquement pour l'interface) intitule TEXT NOT NULL, description TEXT NULL, compte TEXT NOT NULL, -- Compte affecté par cette catégorie FOREIGN KEY(compte) REFERENCES compta_comptes(id) ON DELETE CASCADE ); CREATE TABLE IF NOT EXISTS plugins ( id TEXT NOT NULL PRIMARY KEY, officiel INTEGER NOT NULL DEFAULT 0, nom TEXT NOT NULL, ................................................................................ callback TEXT NOT NULL, PRIMARY KEY (signal, plugin) ); CREATE TABLE IF NOT EXISTS compta_rapprochement -- Rapprochement entre compta et relevés de comptes ( id_operation INTEGER NOT NULL PRIMARY KEY REFERENCES compta_journal (id) ON DELETE CASCADE, date TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP CHECK (datetime(date) IS NOT NULL AND datetime(date) = date), id_auteur INTEGER NULL REFERENCES membres (id) ); CREATE TABLE IF NOT EXISTS fichiers -- Données sur les fichiers ( id INTEGER NOT NULL PRIMARY KEY, nom TEXT NOT NULL, -- nom de fichier (par exemple image1234.jpeg) type TEXT NULL, -- Type MIME image INTEGER NOT NULL DEFAULT 0, -- 1 = image reconnue datetime TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP CHECK (datetime(datetime) IS NOT NULL AND datetime(datetime) = datetime), -- Date d'ajout ou mise à jour du fichier id_contenu INTEGER NOT NULL REFERENCES fichiers_contenu (id) ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS fichiers_date ON fichiers (datetime); CREATE TABLE IF NOT EXISTS fichiers_contenu -- Contenu des fichiers ( |
Modified src/include/lib/Garradin/Cotisations.php from [8bdc434117] to [895e912baf].
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
*/ public function delete($id) { $db = DB::getInstance(); $db->begin(); // Inscrire à NULL les opérations liées à cette cotisation, ainsi on conserve le lien avec les membres $db->update('membres_operations', ['id_cotisation' => null], 'id_cotisation IN (SELECT id FROM cotisations_membres WHERE id_cotisation = :id_select)', ['id_select' => (int) $id]); $db->delete('rappels', 'id_cotisation = ?', (int) $id); $db->delete('rappels_envoyes', 'id_cotisation = ?', (int) $id); $db->delete('cotisations_membres', 'id_cotisation = ?', (int) $id); $db->delete('cotisations', 'id = ?', (int) $id); $db->commit(); return true; } |
| < < < < < < < < |
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
*/
public function delete($id)
{
$db = DB::getInstance();
$db->begin();
// Les lignes liées dans les autres tables seront supprimées grâce à ON DELETE CASCADE
$db->delete('cotisations', 'id = ?', (int) $id);
$db->commit();
return true;
}
|
Modified src/include/lib/Garradin/Membres.php from [5324be994b] to [4adbad4a37].
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
$id = (int) $id; } Plugin::fireSignal('membre.suppression', $membres); $db = DB::getInstance(); $membres = implode(',', $membres); $where = sprintf('id_auteur IN (%s)', $membres); // Mise à jour des références, membre qui n'existe plus $db->update('wiki_revisions', ['id_auteur' => null], $where); $db->update('compta_journal', ['id_auteur' => null], $where); $db->update('compta_rapprochement', ['id_auteur' => null], $where); $where = sprintf('id_membre IN (%s)', $membres); // Suppression des données liées au membre $db->delete('rappels_envoyes', $where); $db->delete('membres_operations', $where); $db->delete('cotisations_membres', $where); //$db->exec('DELETE FROM wiki_suivi WHERE id_membre IN ('.$membres.');'); // Suppression du membre $where = sprintf('id IN (%s)', $membres); return $db->delete('membres', $where); } /** * @deprecated remplacer par envoyer message à tableau de membres */ public function sendMessageToCategory($dest, $sujet, $message, $subscribed_only = false) { |
< < < < < < < < < < < < < < < < < < | |
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 |
$id = (int) $id;
}
Plugin::fireSignal('membre.suppression', $membres);
$db = DB::getInstance();
// Suppression du membre
return $db->delete('membres', $db->where('id', $membres));
}
/**
* @deprecated remplacer par envoyer message à tableau de membres
*/
public function sendMessageToCategory($dest, $sujet, $message, $subscribed_only = false)
{
|
Modified src/include/lib/Garradin/Membres/Cotisations.php from [5f23efdd6e] to [e3d6aba6dc].
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
* Supprimer un événement de cotisation
* @param integer $id ID de l'événement à supprimer
* @return integer true en cas de succès
*/
public function delete($id)
{
$db = DB::getInstance();
$db->update('membres_operations', ['id_cotisation' => null], 'id_cotisation = ' . (int)$id);
return $db->delete('cotisations_membres', 'id = ' . (int)$id);
}
public function get($id)
{
return DB::getInstance()->first('SELECT * FROM cotisations_membres WHERE id = ?;', (int)$id);
}
|
< |
134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
* Supprimer un événement de cotisation * @param integer $id ID de l'événement à supprimer * @return integer true en cas de succès */ public function delete($id) { $db = DB::getInstance(); return $db->delete('cotisations_membres', 'id = ' . (int)$id); } public function get($id) { return DB::getInstance()->first('SELECT * FROM cotisations_membres WHERE id = ?;', (int)$id); } |