diff --git a/docs/database/schema.mysql b/docs/database/schema.mysql index 78a1160..0dbff85 100644 --- a/docs/database/schema.mysql +++ b/docs/database/schema.mysql @@ -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, diff --git a/lib/Vroom/Constants.pm b/lib/Vroom/Constants.pm index 270cbd7..b88113d 100644 --- a/lib/Vroom/Constants.pm +++ b/lib/Vroom/Constants.pm @@ -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 => { diff --git a/scripts/db_upgrade.pl b/scripts/db_upgrade.pl index 72e9adb..f01c34f 100644 --- a/scripts/db_upgrade.pl +++ b/scripts/db_upgrade.pl @@ -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"; +}