mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
try to revert back to old migrate history if failed
This commit is contained in:
parent
875c9058b0
commit
90e0777b9b
@ -24,7 +24,7 @@ logger = logging.getLogger(__name__)
|
|||||||
class Servers(BaseModel):
|
class Servers(BaseModel):
|
||||||
server_id = CharField(primary_key=True, default=Helpers.create_uuid())
|
server_id = CharField(primary_key=True, default=Helpers.create_uuid())
|
||||||
created = DateTimeField(default=datetime.datetime.now)
|
created = DateTimeField(default=datetime.datetime.now)
|
||||||
server_uuid = CharField(default="", index=True)
|
# server_uuid = CharField(default="", index=True)
|
||||||
server_name = CharField(default="Server", index=True)
|
server_name = CharField(default="Server", index=True)
|
||||||
path = CharField(default="")
|
path = CharField(default="")
|
||||||
backup_path = CharField(default="")
|
backup_path = CharField(default="")
|
||||||
|
@ -4,7 +4,7 @@ import peewee
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from app.classes.shared.console import Console
|
from app.classes.shared.console import Console
|
||||||
from app.classes.shared.migration import Migrator
|
from app.classes.shared.migration import Migrator, MigrateHistory
|
||||||
from app.classes.models.management import (
|
from app.classes.models.management import (
|
||||||
AuditLog,
|
AuditLog,
|
||||||
Webhooks,
|
Webhooks,
|
||||||
@ -53,6 +53,7 @@ def migrate(migrator: Migrator, database, **kwargs):
|
|||||||
table_name = "servers"
|
table_name = "servers"
|
||||||
database = db
|
database = db
|
||||||
|
|
||||||
|
try:
|
||||||
# Changes on Server Table
|
# Changes on Server Table
|
||||||
migrator.alter_column_type(
|
migrator.alter_column_type(
|
||||||
Servers,
|
Servers,
|
||||||
@ -83,6 +84,17 @@ def migrate(migrator: Migrator, database, **kwargs):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
except Exception as ex:
|
||||||
|
logger.error("Error while migrating Data from Int to UUID (Type Change)")
|
||||||
|
logger.error(ex)
|
||||||
|
Console.error("Error while migrating Data from Int to UUID (Type Change)")
|
||||||
|
Console.error(ex)
|
||||||
|
last_migration = (
|
||||||
|
MigrateHistory.select().order_by(MigrateHistory.id.desc()).get()
|
||||||
|
)
|
||||||
|
last_migration.delete()
|
||||||
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Changes on Audit Log Table
|
# Changes on Audit Log Table
|
||||||
for audit_log in AuditLog.select():
|
for audit_log in AuditLog.select():
|
||||||
@ -152,6 +164,10 @@ def migrate(migrator: Migrator, database, **kwargs):
|
|||||||
logger.error(ex)
|
logger.error(ex)
|
||||||
Console.error("Error while migrating Data from Int to UUID (Foreign Keys)")
|
Console.error("Error while migrating Data from Int to UUID (Foreign Keys)")
|
||||||
Console.error(ex)
|
Console.error(ex)
|
||||||
|
last_migration = (
|
||||||
|
MigrateHistory.select().order_by(MigrateHistory.id.desc()).get()
|
||||||
|
)
|
||||||
|
last_migration.delete()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -166,6 +182,10 @@ def migrate(migrator: Migrator, database, **kwargs):
|
|||||||
logger.error(ex)
|
logger.error(ex)
|
||||||
Console.error("Error while migrating Data from Int to UUID (Primary Keys)")
|
Console.error("Error while migrating Data from Int to UUID (Primary Keys)")
|
||||||
Console.error(ex)
|
Console.error(ex)
|
||||||
|
last_migration = (
|
||||||
|
MigrateHistory.select().order_by(MigrateHistory.id.desc()).get()
|
||||||
|
)
|
||||||
|
last_migration.delete()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Changes on Server Table
|
# Changes on Server Table
|
||||||
|
Loading…
Reference in New Issue
Block a user