Rebased & fixed backend #410
This commit is contained in:
parent
e8cc42e155
commit
2de5afd648
@ -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`;")
|
@ -0,0 +1,3 @@
|
||||
DROP TABLE `ShortRoleNames`;
|
||||
|
||||
DROP TABLE `ShortRoleNamesHistory`;
|
@ -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`
|
||||
(
|
||||
`Id` BIGINT(20) NOT NULL,
|
||||
`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,
|
||||
`Id` BIGINT(20) NOT NULL,
|
||||
`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(20) DEFAULT NULL,
|
||||
`Deleted` BOOL DEFAULT FALSE,
|
||||
`DateFrom` DATETIME(6) NOT NULL,
|
||||
`DateTo` DATETIME(6) NOT NULL
|
||||
`DateFrom` DATETIME(6) NOT NULL,
|
||||
`DateTo` DATETIME(6) NOT NULL
|
||||
);
|
||||
|
||||
DROP TRIGGER IF EXISTS `TR_ScheduledEventsUpdate`;
|
@ -16,10 +16,10 @@
|
||||
"LicenseName": "MIT",
|
||||
"LicenseDescription": "MIT, see LICENSE for more details.",
|
||||
"Dependencies": [
|
||||
"cpl-core>=1.2.1"
|
||||
"cpl-core>=1.2.dev410"
|
||||
],
|
||||
"DevDependencies": [
|
||||
"cpl-cli>=1.2.1"
|
||||
"cpl-cli>=1.2.dev410"
|
||||
],
|
||||
"PythonVersion": ">=3.10.4",
|
||||
"PythonPath": {},
|
||||
|
@ -16,10 +16,10 @@
|
||||
"LicenseName": "",
|
||||
"LicenseDescription": "",
|
||||
"Dependencies": [
|
||||
"cpl-core>=1.2.1"
|
||||
"cpl-core>=1.2.dev410"
|
||||
],
|
||||
"DevDependencies": [
|
||||
"cpl-cli>=1.2.1"
|
||||
"cpl-cli>=1.2.dev410"
|
||||
],
|
||||
"PythonVersion": ">=3.10.4",
|
||||
"PythonPath": {
|
||||
|
@ -16,10 +16,10 @@
|
||||
"LicenseName": "",
|
||||
"LicenseDescription": "",
|
||||
"Dependencies": [
|
||||
"cpl-core>=1.2.1"
|
||||
"cpl-core>=1.2.dev410"
|
||||
],
|
||||
"DevDependencies": [
|
||||
"cpl-cli>=1.2.1"
|
||||
"cpl-cli>=1.2.dev410"
|
||||
],
|
||||
"PythonVersion": ">=3.10.4",
|
||||
"PythonPath": {
|
||||
|
@ -16,10 +16,10 @@
|
||||
"LicenseName": "",
|
||||
"LicenseDescription": "",
|
||||
"Dependencies": [
|
||||
"cpl-core>=1.2.1"
|
||||
"cpl-core>=1.2.dev410"
|
||||
],
|
||||
"DevDependencies": [
|
||||
"cpl-cli>=1.2.1"
|
||||
"cpl-cli>=1.2.dev410"
|
||||
],
|
||||
"PythonVersion": ">=3.10.4",
|
||||
"PythonPath": {
|
||||
|
@ -2,9 +2,9 @@
|
||||
"ProjectSettings": {
|
||||
"Name": "migration-to-sql",
|
||||
"Version": {
|
||||
"Major": "0",
|
||||
"Minor": "0",
|
||||
"Micro": "0"
|
||||
"Major": "1",
|
||||
"Minor": "2",
|
||||
"Micro": "2"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
@ -16,10 +16,10 @@
|
||||
"LicenseName": "",
|
||||
"LicenseDescription": "",
|
||||
"Dependencies": [
|
||||
"cpl-core>=2023.10.0"
|
||||
"cpl-core>=1.2.dev410"
|
||||
],
|
||||
"DevDependencies": [
|
||||
"cpl-cli>=2023.4.0.post3"
|
||||
"cpl-cli>=1.2.dev410"
|
||||
],
|
||||
"PythonVersion": ">=3.10.4",
|
||||
"PythonPath": {
|
||||
|
Loading…
Reference in New Issue
Block a user