mirror of https://github.com/dani/vroom.git
Increase peer_id size
This commit is contained in:
parent
9ffbe83a98
commit
07107e5d39
|
@ -6,7 +6,7 @@ CREATE TABLE `config` (
|
|||
UNIQUE (`key`)
|
||||
) ENGINE INNODB DEFAULT CHARSET=utf8;
|
||||
INSERT INTO `config` (`key`,`value`)
|
||||
VALUES ('schema_version', '1');
|
||||
VALUES ('schema_version', '2');
|
||||
|
||||
CREATE TABLE `rooms` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
|
@ -31,7 +31,7 @@ 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(40) DEFAULT NULL,
|
||||
`peer_id` VARCHAR(60) DEFAULT NULL,
|
||||
`role` VARCHAR(30) DEFAULT 'participant',
|
||||
`last_activity` DATETIME DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
|
|
|
@ -7,7 +7,7 @@ use base 'Exporter';
|
|||
our @EXPORT = qw/DB_VERSION COMPONENTS MOH JS_STRINGS API_ACTIONS/;
|
||||
|
||||
# Database version
|
||||
use constant DB_VERSION => 1;
|
||||
use constant DB_VERSION => 2;
|
||||
|
||||
# Components used to generate the credits part
|
||||
use constant COMPONENTS => {
|
||||
|
|
|
@ -58,3 +58,20 @@ if ($cur_ver == Vroom::Constants::DB_VERSION){
|
|||
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…
Reference in New Issue