Assigner les disciplines et régions en bloc dans l'admin
[auf_savoirs_en_partage_django.git] / auf_savoirs_en_partage / sql / 2010-11-01.sql
1 -- Ajout des tables many-to-many pour les régions et les disciplines
2
3 BEGIN;
4 CREATE TABLE `savoirs_evenement_regions` (
5 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
6 `evenement_id` integer NOT NULL,
7 `region_id` integer NOT NULL,
8 UNIQUE (`evenement_id`, `region_id`)
9 )
10 ;
11 ALTER TABLE `savoirs_evenement_regions` ADD CONSTRAINT `evenement_id_refs_id_5e92e839` FOREIGN KEY (`evenement_id`) REFERENCES `savoirs_evenement` (`id`);
12 ALTER TABLE `savoirs_evenement_regions` ADD CONSTRAINT `region_id_refs_id_771e693` FOREIGN KEY (`region_id`) REFERENCES `ref_region` (`id`);
13 CREATE TABLE `actualite_regions` (
14 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
15 `actualite_id` integer NOT NULL,
16 `region_id` integer NOT NULL,
17 UNIQUE (`actualite_id`, `region_id`)
18 )
19 ;
20 ALTER TABLE `actualite_regions` ADD CONSTRAINT `actualite_id_refs_id_actualite_7d8ac265` FOREIGN KEY (`actualite_id`) REFERENCES `actualite` (`id_actualite`);
21 ALTER TABLE `actualite_regions` ADD CONSTRAINT `region_id_refs_id_57ede84a` FOREIGN KEY (`region_id`) REFERENCES `ref_region` (`id`);
22 CREATE TABLE `actualite_disciplines` (
23 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
24 `actualite_id` integer NOT NULL,
25 `discipline_id` integer NOT NULL,
26 UNIQUE (`actualite_id`, `discipline_id`)
27 )
28 ;
29 ALTER TABLE `actualite_disciplines` ADD CONSTRAINT `actualite_id_refs_id_actualite_23f21297` FOREIGN KEY (`actualite_id`) REFERENCES `actualite` (`id_actualite`);
30 ALTER TABLE `actualite_disciplines` ADD CONSTRAINT `discipline_id_refs_id_discipline_682cd4d8` FOREIGN KEY (`discipline_id`) REFERENCES `discipline` (`id_discipline`);
31 CREATE TABLE `sitotheque_site_regions` (
32 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
33 `site_id` integer NOT NULL,
34 `region_id` integer NOT NULL,
35 UNIQUE (`site_id`, `region_id`)
36 )
37 ;
38 ALTER TABLE `sitotheque_site_regions` ADD CONSTRAINT `site_id_refs_id_637ee69d` FOREIGN KEY (`site_id`) REFERENCES `sitotheque_site` (`id`);
39 ALTER TABLE `sitotheque_site_regions` ADD CONSTRAINT `region_id_refs_id_63442bff` FOREIGN KEY (`region_id`) REFERENCES `ref_region` (`id`);
40 COMMIT;