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,3 +1,21 @@
|
|||||||
|
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,
|
@ -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": {},
|
||||||
|
@ -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": {
|
||||||
|
@ -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": {
|
||||||
|
@ -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": {
|
||||||
|
@ -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": {
|
||||||
|
Loading…
Reference in New Issue
Block a user