Increase peer_id size

master
Daniel Berteaud 10 years ago
parent 9ffbe83a98
commit 07107e5d39
  1. 4
      docs/database/schema.mysql
  2. 2
      lib/Vroom/Constants.pm
  3. 17
      scripts/db_upgrade.pl

@ -6,7 +6,7 @@ CREATE TABLE `config` (
UNIQUE (`key`) UNIQUE (`key`)
) ENGINE INNODB DEFAULT CHARSET=utf8; ) ENGINE INNODB DEFAULT CHARSET=utf8;
INSERT INTO `config` (`key`,`value`) INSERT INTO `config` (`key`,`value`)
VALUES ('schema_version', '1'); VALUES ('schema_version', '2');
CREATE TABLE `rooms` ( CREATE TABLE `rooms` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
@ -31,7 +31,7 @@ CREATE TABLE `room_participants` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`room_id` INT UNSIGNED NOT NULL, `room_id` INT UNSIGNED NOT NULL,
`participant` VARCHAR(60) NOT NULL, `participant` VARCHAR(60) NOT NULL,
`peer_id` VARCHAR(40) DEFAULT NULL, `peer_id` VARCHAR(60) DEFAULT NULL,
`role` VARCHAR(30) DEFAULT 'participant', `role` VARCHAR(30) DEFAULT 'participant',
`last_activity` DATETIME DEFAULT NULL, `last_activity` DATETIME DEFAULT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),

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

@ -58,3 +58,20 @@ if ($cur_ver == Vroom::Constants::DB_VERSION){
exit 0; exit 0;
} }
if ($cur_ver < 2){
print "Upgrading the schema to version 2\n";
eval {
$dbh->begin_work;
$dbh->do(qq{ ALTER TABLE `room_participants` MODIFY `peer_id` VARCHAR(60) });
$dbh->do(qq{ UPDATE `config` SET `value`='2' WHERE `key`='schema_version' });
$dbh->commit;
};
if ($@){
print "An error occurred: " . $dbh->errstr . "\n";
local $dbh->{RaiseError} = 0;
$dbh->rollback;
exit 255;
};
print "Successfully upgraded to schema version 2\n";
}

Loading…
Cancel
Save