From 3d730ecc64aa8fa6aee851c9698d4e0339ceba77 Mon Sep 17 00:00:00 2001 From: Aidaho Date: Mon, 9 Sep 2024 10:08:43 +0300 Subject: [PATCH] v1.1.3: Add update to rename 'desc' to 'description' in 'servers' table Previously, the code missed renaming the 'desc' column in the 'servers' table. This commit adds a new function `update_db_v_1_1_3` to handle this migration, ensuring the column is renamed appropriately. --- app/create_db.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/create_db.py b/app/create_db.py index eda43b0..7766e51 100644 --- a/app/create_db.py +++ b/app/create_db.py @@ -175,7 +175,6 @@ def update_db_v_1_1(): migrate( migrator.rename_column('smon_status_pages', 'desc', 'description'), migrator.rename_column('smon_agents', 'desc', 'description'), - migrator.rename_column('servers', 'desc', 'description'), migrator.rename_column('smon', 'desc', 'description'), migrator.rename_column('smon_status_pages', 'style', 'custom_style'), migrator.rename_column('smon_status_pages', 'desc', 'description'), @@ -216,6 +215,20 @@ def update_db_v_1_1_2(): print("An error occurred:", e) +def update_db_v_1_1_3(): + try: + migrate( + migrator.rename_column('servers', 'desc', 'description'), + ) + except Exception as e: + if e.args[0] == 'no such column: "desc"' or str(e) == '(1060, no such column: "desc")': + print("Updating... DB has been updated to version 1.3") + elif e.args[0] == "'bool' object has no attribute 'sql'": + print("Updating... DB has been updated to version 1.3") + else: + print("An error occurred:", e) + + def update_ver(): try: Version.update(version='1.1.3').execute() @@ -241,6 +254,7 @@ def update_all(): update_db_v_1_0_7_1() update_db_v_1_1() update_db_v_1_1_2() + update_db_v_1_1_3() if __name__ == "__main__":