From ef0ce090add678d7e5f7b68e1817442e09bd3a44 Mon Sep 17 00:00:00 2001 From: Aidaho Date: Mon, 9 Sep 2024 11:58:29 +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 7766e51..88b3157 100644 --- a/app/create_db.py +++ b/app/create_db.py @@ -173,7 +173,6 @@ def update_db_v_1_0_7_1(): def update_db_v_1_1(): try: migrate( - migrator.rename_column('smon_status_pages', 'desc', 'description'), migrator.rename_column('smon_agents', 'desc', 'description'), migrator.rename_column('smon', 'desc', 'description'), migrator.rename_column('smon_status_pages', 'style', 'custom_style'), @@ -229,6 +228,20 @@ def update_db_v_1_1_3(): print("An error occurred:", e) +def update_db_v_1_1_3_1(): + try: + migrate( + migrator.rename_column('smon_status_pages', '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() @@ -255,6 +268,7 @@ def update_all(): update_db_v_1_1() update_db_v_1_1_2() update_db_v_1_1_3() + update_db_v_1_1_3_1() if __name__ == "__main__":