mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 08:52:15 -07:00
Support database changes
This commit is contained in:
parent
ab5a370e32
commit
1771ed68a4
3 changed files with 24 additions and 3 deletions
8
servatrice/migrations/servatrice_0033_to_0034.sql
Normal file
8
servatrice/migrations/servatrice_0033_to_0034.sql
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
-- Servatrice db migration from version 33 to version 34
|
||||||
|
|
||||||
|
ALTER TABLE cockatrice_users ADD COLUMN leftPawnColorOverride varchar(255);
|
||||||
|
ALTER TABLE cockatrice_users ADD COLUMN rightPawnColorOverride varchar(255);
|
||||||
|
|
||||||
|
ALTER TABLE cockatrice_users ADD INDEX `idx_pawnColorOverrides` (`leftPawnColorOverride`, `rightPawnColorOverride`);
|
||||||
|
|
||||||
|
UPDATE cockatrice_schema_version SET version=34 WHERE version=33;
|
||||||
|
|
@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `cockatrice_schema_version` (
|
||||||
PRIMARY KEY (`version`)
|
PRIMARY KEY (`version`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
INSERT INTO cockatrice_schema_version VALUES(33);
|
INSERT INTO cockatrice_schema_version VALUES(34);
|
||||||
|
|
||||||
-- users and user data tables
|
-- users and user data tables
|
||||||
CREATE TABLE IF NOT EXISTS `cockatrice_users` (
|
CREATE TABLE IF NOT EXISTS `cockatrice_users` (
|
||||||
|
|
@ -41,6 +41,8 @@ CREATE TABLE IF NOT EXISTS `cockatrice_users` (
|
||||||
`privlevelStartDate` datetime NOT NULL,
|
`privlevelStartDate` datetime NOT NULL,
|
||||||
`privlevelEndDate` datetime NOT NULL,
|
`privlevelEndDate` datetime NOT NULL,
|
||||||
`passwordLastChangedDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
`passwordLastChangedDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
|
`leftPawnColorOverride` varchar(255),
|
||||||
|
`rightPawnColorOverride` varchar(255),
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `name` (`name`),
|
UNIQUE KEY `name` (`name`),
|
||||||
KEY `token` (`token`),
|
KEY `token` (`token`),
|
||||||
|
|
@ -48,7 +50,8 @@ CREATE TABLE IF NOT EXISTS `cockatrice_users` (
|
||||||
INDEX `idx_admin` (`admin`),
|
INDEX `idx_admin` (`admin`),
|
||||||
INDEX `idx_active` (`active`),
|
INDEX `idx_active` (`active`),
|
||||||
INDEX `idx_privlevel` (`privlevel`),
|
INDEX `idx_privlevel` (`privlevel`),
|
||||||
INDEX `idx_clientid` (`clientid`)
|
INDEX `idx_clientid` (`clientid`),
|
||||||
|
INDEX `idx_pawnColorOverrides` (`leftPawnColorOverride`, `rightPawnColorOverride`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `cockatrice_decklist_files` (
|
CREATE TABLE IF NOT EXISTS `cockatrice_decklist_files` (
|
||||||
|
|
|
||||||
|
|
@ -607,6 +607,15 @@ ServerInfo_User Servatrice_DatabaseInterface::evalUserQueryResult(const QSqlQuer
|
||||||
|
|
||||||
result.set_user_level(userLevel);
|
result.set_user_level(userLevel);
|
||||||
|
|
||||||
|
const auto &pawn_left_override = query->value(10).toString();
|
||||||
|
const auto &pawn_right_override = query->value(11).toString();
|
||||||
|
if (!pawn_left_override.isEmpty()) {
|
||||||
|
result.mutable_pawn_colors()->set_left_side(pawn_left_override.toStdString());
|
||||||
|
}
|
||||||
|
if (!pawn_right_override.isEmpty()) {
|
||||||
|
result.mutable_pawn_colors()->set_right_side(pawn_right_override.toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
const QString country = query->value(3).toString();
|
const QString country = query->value(3).toString();
|
||||||
if (!country.isEmpty())
|
if (!country.isEmpty())
|
||||||
result.set_country(country.toStdString());
|
result.set_country(country.toStdString());
|
||||||
|
|
@ -654,7 +663,8 @@ ServerInfo_User Servatrice_DatabaseInterface::getUserData(const QString &name, b
|
||||||
|
|
||||||
QSqlQuery *query =
|
QSqlQuery *query =
|
||||||
prepareQuery("select id, name, admin, country, privlevel, realname, avatar_bmp, registrationDate, "
|
prepareQuery("select id, name, admin, country, privlevel, realname, avatar_bmp, registrationDate, "
|
||||||
"email, clientid from {prefix}_users where name = :name and active = 1");
|
"email, clientid, leftPawnColorOverride, rightPawnColorOverride from {prefix}_users where "
|
||||||
|
"name = :name and active = 1");
|
||||||
query->bindValue(":name", name);
|
query->bindValue(":name", name);
|
||||||
if (!execSqlQuery(query))
|
if (!execSqlQuery(query))
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue