- mysql_query("BEGIN TRANSACTION");
- mysql_query("ALTER TABLE participants ADD CONSTRAINT UNIQUE INDEX pseudo_unique (pseudo);");
- mysql_query("
- CREATE TABLE IF NOT EXISTS periodes (
- id mediumint(3) unsigned NOT NULL auto_increment,
- nom varchar(200) NOT NULL,
- nom_abrege varchar(20) NOT NULL DEFAULT '',
- PRIMARY KEY (id)
- ) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED;
- ");
- mysql_query("INSERT INTO periodes (nom, nom_abrege) VALUES ('vendredi soir à samedi', 'v->s')");
- mysql_query("INSERT INTO periodes (nom, nom_abrege) VALUES ('samedi à dimanche', 's->d')");
- mysql_query("INSERT INTO periodes (nom, nom_abrege) VALUES ('dimanche à lundi', 'd->l')");
- 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;
- ");
- $participations = mysql_query("SELECT participants.id as participant_id, periodes.id as periode_id FROM participants, periodes");
- while ($participation = mysql_fetch_object($participations))
- {
- mysql_query("
- INSERT INTO participations (participant_id, periode_id)
- VALUES (".$participation->participant_id.",".$participation->periode_id.")"
- );
- }
- mysql_query("UPDATE config SET valeur = '2' WHERE nom = 'version'");