Rebased & fixed backend #410

This commit is contained in:
Sven Heidemann 2023-11-14 17:46:12 +01:00
parent e8cc42e155
commit 2de5afd648
8 changed files with 45 additions and 69 deletions

View File

@ -1,45 +0,0 @@
from bot_core.logging.database_logger import DatabaseLogger
from bot_data.abc.migration_abc import MigrationABC
from bot_data.db_context import DBContext
class ScheduledEventMigration(MigrationABC):
name = "1.2.0_ScheduledEventMigration"
def __init__(self, logger: DatabaseLogger, db: DBContext):
MigrationABC.__init__(self)
self._logger = logger
self._db = db
self._cursor = db.cursor
def upgrade(self):
self._logger.debug(__name__, "Running upgrade")
self._cursor.execute(
str(
f"""
CREATE TABLE IF NOT EXISTS `ScheduledEvents` (
`Id` BIGINT NOT NULL AUTO_INCREMENT,
`Interval` VARCHAR(255) NOT NULL,
`Name` VARCHAR(255) NOT NULL,
`Description` VARCHAR(255) NOT NULL,
`ChannelId` BIGINT NULL,
`StartTime` DATETIME(6) NOT NULL,
`EndTime` DATETIME(6) NULL,
`EntityType` ENUM('1','2','3') NOT NULL,
`Location` VARCHAR(255) NULL,
`ServerId` BIGINT,
`CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6),
`LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
PRIMARY KEY(`Id`),
FOREIGN KEY (`ServerId`) REFERENCES `Servers`(`ServerId`)
);
"""
)
)
self._exec(__file__, "scheduled_events.sql")
def downgrade(self):
self._cursor.execute("DROP TABLE `ShortRoleNames`;")
self._cursor.execute("DROP TABLE `ShortRoleNamesHistory`;")

View File

@ -0,0 +1,3 @@
DROP TABLE `ShortRoleNames`;
DROP TABLE `ShortRoleNamesHistory`;

View File

@ -1,18 +1,36 @@
CREATE TABLE IF NOT EXISTS `ScheduledEvents`
(
`Id` BIGINT NOT NULL AUTO_INCREMENT,
`Interval` VARCHAR(255) NOT NULL,
`Name` VARCHAR(255) NOT NULL,
`Description` VARCHAR(255) NOT NULL,
`ChannelId` BIGINT NULL,
`StartTime` DATETIME(6) NOT NULL,
`EndTime` DATETIME(6) NULL,
`EntityType` ENUM ('1','2','3') NOT NULL,
`Location` VARCHAR(255) NULL,
`ServerId` BIGINT,
`CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6),
`LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
PRIMARY KEY (`Id`),
FOREIGN KEY (`ServerId`) REFERENCES `Servers` (`ServerId`)
);
CREATE TABLE IF NOT EXISTS `ScheduledEventsHistory` CREATE TABLE IF NOT EXISTS `ScheduledEventsHistory`
( (
`Id` BIGINT(20) NOT NULL, `Id` BIGINT(20) NOT NULL,
`Interval` VARCHAR(255) NOT NULL, `Interval` VARCHAR(255) NOT NULL,
`Name` VARCHAR(255) NOT NULL, `Name` VARCHAR(255) NOT NULL,
`Description` VARCHAR(255) NOT NULL, `Description` VARCHAR(255) NOT NULL,
`ChannelId` BIGINT NULL, `ChannelId` BIGINT NULL,
`StartTime` DATETIME(6) NOT NULL, `StartTime` DATETIME(6) NOT NULL,
`EndTime` DATETIME(6) NULL, `EndTime` DATETIME(6) NULL,
`EntityType` ENUM ('1','2','3') NOT NULL, `EntityType` ENUM ('1','2','3') NOT NULL,
`Location` VARCHAR(255) NULL, `Location` VARCHAR(255) NULL,
`ServerId` BIGINT(20) DEFAULT NULL, `ServerId` BIGINT(20) DEFAULT NULL,
`Deleted` BOOL DEFAULT FALSE, `Deleted` BOOL DEFAULT FALSE,
`DateFrom` DATETIME(6) NOT NULL, `DateFrom` DATETIME(6) NOT NULL,
`DateTo` DATETIME(6) NOT NULL `DateTo` DATETIME(6) NOT NULL
); );
DROP TRIGGER IF EXISTS `TR_ScheduledEventsUpdate`; DROP TRIGGER IF EXISTS `TR_ScheduledEventsUpdate`;

View File

@ -16,10 +16,10 @@
"LicenseName": "MIT", "LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.", "LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [ "Dependencies": [
"cpl-core>=1.2.1" "cpl-core>=1.2.dev410"
], ],
"DevDependencies": [ "DevDependencies": [
"cpl-cli>=1.2.1" "cpl-cli>=1.2.dev410"
], ],
"PythonVersion": ">=3.10.4", "PythonVersion": ">=3.10.4",
"PythonPath": {}, "PythonPath": {},

View File

@ -16,10 +16,10 @@
"LicenseName": "", "LicenseName": "",
"LicenseDescription": "", "LicenseDescription": "",
"Dependencies": [ "Dependencies": [
"cpl-core>=1.2.1" "cpl-core>=1.2.dev410"
], ],
"DevDependencies": [ "DevDependencies": [
"cpl-cli>=1.2.1" "cpl-cli>=1.2.dev410"
], ],
"PythonVersion": ">=3.10.4", "PythonVersion": ">=3.10.4",
"PythonPath": { "PythonPath": {

View File

@ -16,10 +16,10 @@
"LicenseName": "", "LicenseName": "",
"LicenseDescription": "", "LicenseDescription": "",
"Dependencies": [ "Dependencies": [
"cpl-core>=1.2.1" "cpl-core>=1.2.dev410"
], ],
"DevDependencies": [ "DevDependencies": [
"cpl-cli>=1.2.1" "cpl-cli>=1.2.dev410"
], ],
"PythonVersion": ">=3.10.4", "PythonVersion": ">=3.10.4",
"PythonPath": { "PythonPath": {

View File

@ -16,10 +16,10 @@
"LicenseName": "", "LicenseName": "",
"LicenseDescription": "", "LicenseDescription": "",
"Dependencies": [ "Dependencies": [
"cpl-core>=1.2.1" "cpl-core>=1.2.dev410"
], ],
"DevDependencies": [ "DevDependencies": [
"cpl-cli>=1.2.1" "cpl-cli>=1.2.dev410"
], ],
"PythonVersion": ">=3.10.4", "PythonVersion": ">=3.10.4",
"PythonPath": { "PythonPath": {

View File

@ -2,9 +2,9 @@
"ProjectSettings": { "ProjectSettings": {
"Name": "migration-to-sql", "Name": "migration-to-sql",
"Version": { "Version": {
"Major": "0", "Major": "1",
"Minor": "0", "Minor": "2",
"Micro": "0" "Micro": "2"
}, },
"Author": "", "Author": "",
"AuthorEmail": "", "AuthorEmail": "",
@ -16,10 +16,10 @@
"LicenseName": "", "LicenseName": "",
"LicenseDescription": "", "LicenseDescription": "",
"Dependencies": [ "Dependencies": [
"cpl-core>=2023.10.0" "cpl-core>=1.2.dev410"
], ],
"DevDependencies": [ "DevDependencies": [
"cpl-cli>=2023.4.0.post3" "cpl-cli>=1.2.dev410"
], ],
"PythonVersion": ">=3.10.4", "PythonVersion": ">=3.10.4",
"PythonPath": { "PythonPath": {