diff --git a/bot/src/bot_data/scripts/0.1/Initial_down.sql b/bot/src/bot_data/scripts/0.1/Initial_down.sql new file mode 100644 index 00000000..c1c80bab --- /dev/null +++ b/bot/src/bot_data/scripts/0.1/Initial_down.sql @@ -0,0 +1,12 @@ +DROP TABLE `Servers`; + +DROP TABLE `Users`; + +DROP TABLE `Clients`; + +DROP TABLE `KnownUsers`; + +DROP TABLE `UserJoinedServers`; + +DROP TABLE `UserJoinedVoiceChannel`; + diff --git a/bot/src/bot_data/scripts/0.1/Initial_up.sql b/bot/src/bot_data/scripts/0.1/Initial_up.sql new file mode 100644 index 00000000..7c5b0be2 --- /dev/null +++ b/bot/src/bot_data/scripts/0.1/Initial_up.sql @@ -0,0 +1,70 @@ +CREATE TABLE IF NOT EXISTS `Servers` +( + `ServerId` BIGINT NOT NULL AUTO_INCREMENT, + `DiscordServerId` BIGINT NOT NULL, + `CreatedAt` DATETIME(6), + `LastModifiedAt` DATETIME(6), + PRIMARY KEY (`ServerId`) +); + +CREATE TABLE IF NOT EXISTS `Users` +( + `UserId` BIGINT NOT NULL AUTO_INCREMENT, + `DiscordId` BIGINT NOT NULL, + `XP` BIGINT NOT NULL DEFAULT 0, + `ServerId` BIGINT, + `CreatedAt` DATETIME(6), + `LastModifiedAt` DATETIME(6), + FOREIGN KEY (`ServerId`) REFERENCES Servers (`ServerId`), + PRIMARY KEY (`UserId`) +); + +CREATE TABLE IF NOT EXISTS `Clients` +( + `ClientId` BIGINT NOT NULL AUTO_INCREMENT, + `DiscordClientId` BIGINT NOT NULL, + `SentMessageCount` BIGINT NOT NULL DEFAULT 0, + `ReceivedMessageCount` BIGINT NOT NULL DEFAULT 0, + `DeletedMessageCount` BIGINT NOT NULL DEFAULT 0, + `ReceivedCommandsCount` BIGINT NOT NULL DEFAULT 0, + `MovedUsersCount` BIGINT NOT NULL DEFAULT 0, + `ServerId` BIGINT, + `CreatedAt` DATETIME(6), + `LastModifiedAt` DATETIME(6), + FOREIGN KEY (`ServerId`) REFERENCES Servers (`ServerId`), + PRIMARY KEY (`ClientId`) +); + +CREATE TABLE IF NOT EXISTS `KnownUsers` +( + `KnownUserId` BIGINT NOT NULL AUTO_INCREMENT, + `DiscordId` BIGINT NOT NULL, + `CreatedAt` DATETIME(6), + `LastModifiedAt` DATETIME(6), + PRIMARY KEY (`KnownUserId`) +); + +CREATE TABLE IF NOT EXISTS `UserJoinedServers` +( + `JoinId` BIGINT NOT NULL AUTO_INCREMENT, + `UserId` BIGINT NOT NULL, + `JoinedOn` DATETIME(6) NOT NULL, + `LeavedOn` DATETIME(6), + `CreatedAt` DATETIME(6), + `LastModifiedAt` DATETIME(6), + FOREIGN KEY (`UserId`) REFERENCES Users (`UserId`), + PRIMARY KEY (`JoinId`) +); + +CREATE TABLE IF NOT EXISTS `UserJoinedVoiceChannel` +( + `JoinId` BIGINT NOT NULL AUTO_INCREMENT, + `UserId` BIGINT NOT NULL, + `DiscordChannelId` BIGINT NOT NULL, + `JoinedOn` DATETIME(6) NOT NULL, + `LeavedOn` DATETIME(6), + `CreatedAt` DATETIME(6), + `LastModifiedAt` DATETIME(6), + FOREIGN KEY (`UserId`) REFERENCES Users (`UserId`), + PRIMARY KEY (`JoinId`) +);