Drop table room_participants

This commit is contained in:
Daniel Berteaud 2015-03-06 11:51:01 +01:00
parent 1acb0795fb
commit b54e652e37
3 changed files with 16 additions and 17 deletions

View File

@ -27,22 +27,6 @@ CREATE TABLE `rooms` (
INDEX (`last_activity`)
) ENGINE INNODB DEFAULT CHARSET=utf8;
CREATE TABLE `room_participants` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`room_id` INT UNSIGNED NOT NULL,
`participant` VARCHAR(60) NOT NULL,
`peer_id` VARCHAR(60) DEFAULT NULL,
`role` VARCHAR(30) DEFAULT 'participant',
`last_activity` DATETIME DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE (`room_id`, `participant`),
UNIQUE (`room_id`, `peer_id`),
UNIQUE (`participant`,`peer_id`),
FOREIGN KEY (`room_id`) REFERENCES `rooms` (`id`)
ON UPDATE CASCADE
ON DELETE CASCADE
) ENGINE INNODB DEFAULT CHARSET=utf8;
CREATE TABLE `email_notifications` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`room_id` INT UNSIGNED NOT NULL,

View File

@ -7,7 +7,7 @@ use base 'Exporter';
our @EXPORT = qw/DB_VERSION COMPONENTS MOH JS_STRINGS API_ACTIONS/;
# Database version
use constant DB_VERSION => 2;
use constant DB_VERSION => 3;
# Components used to generate the credits part
use constant COMPONENTS => {

View File

@ -75,3 +75,18 @@ if ($cur_ver < 2){
print "Successfully upgraded to schema version 2\n";
}
if ($cur_ver < 3){
print "Upgrading the schema to version 3\n";
eval {
$dbh->begin_work;
$dbh->do(qq{ DROP TABLE `room_participants` });
$dbh->commit;
};
if ($@){
print "An error occurred: " . $dbh->errstr . "\n";
local $dbh->{RaiseError} = 0;
$dbh->rollback;
exit 255;
};
print "Successfully upgraded to schema version 3\n";
}