X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=php%2Fupdate_db.php;fp=php%2Fupdate_db.php;h=5ff59047cb7ed9de31d748fcedc7ad3a5256045c;hb=27f3004da65f2b5803709b3fa76a791c9b38a0c9;hp=0000000000000000000000000000000000000000;hpb=262be7e249593a2764a7c452f70dc5ac68887d5c;p=cl7.git diff --git a/php/update_db.php b/php/update_db.php new file mode 100644 index 0000000..5ff5904 --- /dev/null +++ b/php/update_db.php @@ -0,0 +1,117 @@ + 2 + if ($version == 1) + { + mysql_query("BEGIN TRANSACTION"); + mysql_query(" + CREATE TABLE IF NOT EXISTS periodes ( + id mediumint(3) unsigned NOT NULL auto_increment, + nom varchar(200) NOT NULL, + PRIMARY KEY (id) + ) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED; + "); + mysql_query("INSERT INTO periodes (nom) VALUES ('Vendredi soir à samedi')"); + mysql_query("INSERT INTO periodes (nom) VALUES ('Samedi à dimanche')"); + mysql_query("INSERT INTO periodes (nom) VALUES ('Dimanche à lundi')"); + mysql_query(" + CREATE TABLE IF NOT EXISTS participations ( + participant_id mediumint(3) unsigned NOT NULL, + periode_id mediumint(3) unsigned NOT NULL, + PRIMARY KEY USING BTREE (participant_id, periode_id), + KEY FK_periode (periode_id), + CONSTRAINT FK_participant_participations FOREIGN KEY (participant_id) REFERENCES participants (id) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT FK_periode_participations FOREIGN KEY (periode_id) REFERENCES periodes (id) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + "); + mysql_query("UPDATE config SET valeur = '2' WHERE nom = 'version')"); + mysql_query("COMMIT"); + } +} + +update_db(); + +?>