2017-09-10 01:52:34 +00:00
|
|
|
|
namespace NadekoBot.Migrations
|
|
|
|
|
{
|
|
|
|
|
internal class MigrationQueries
|
|
|
|
|
{
|
|
|
|
|
public static string UserClub { get; } = @"
|
|
|
|
|
CREATE TABLE DiscordUser_tmp(
|
|
|
|
|
Id INTEGER PRIMARY KEY,
|
|
|
|
|
AvatarId TEXT,
|
|
|
|
|
Discriminator TEXT,
|
|
|
|
|
UserId INTEGER UNIQUE NOT NULL,
|
|
|
|
|
DateAdded TEXT,
|
|
|
|
|
Username TEXT
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
INSERT INTO DiscordUser_tmp
|
|
|
|
|
SELECT Id, AvatarId, Discriminator, UserId, DateAdded, Username
|
|
|
|
|
FROM DiscordUser;
|
|
|
|
|
|
|
|
|
|
DROP TABLE DiscordUser;
|
|
|
|
|
|
|
|
|
|
CREATE TABLE DiscordUser(
|
|
|
|
|
Id INTEGER PRIMARY KEY,
|
|
|
|
|
AvatarId TEXT,
|
|
|
|
|
Discriminator TEXT,
|
|
|
|
|
UserId INTEGER UNIQUE NOT NULL,
|
|
|
|
|
DateAdded TEXT,
|
|
|
|
|
Username TEXT,
|
|
|
|
|
ClubId INTEGER,
|
|
|
|
|
CONSTRAINT FK_DiscordUser_Clubs_ClubId FOREIGN KEY(ClubId) REFERENCES Clubs(Id) ON DELETE RESTRICT
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
INSERT INTO DiscordUser
|
|
|
|
|
SELECT Id, AvatarId, Discriminator, UserId, DateAdded, Username, NULL
|
|
|
|
|
FROM DiscordUser_tmp;
|
|
|
|
|
|
|
|
|
|
DROP TABLE DiscordUser_tmp;";
|
2017-09-13 03:10:26 +00:00
|
|
|
|
public static string TotalXp { get; } =
|
|
|
|
|
@"UPDATE DiscordUser
|
2017-09-13 06:12:07 +00:00
|
|
|
|
SET TotalXp = ifnull((SELECT SUM(Xp) FROM UserXpStats WHERE UserId = DiscordUser.UserId), 0)";
|
2017-09-13 03:10:26 +00:00
|
|
|
|
|
2017-09-10 01:52:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|