Philipp Hörist pushed to branch master at gajim / gajim


Commits:
4a450e6b by Philipp Hörist at 2025-07-02T19:42:58+02:00
fix: Migration: Fix migration for Gajim versions < 1.8.4

Fixes #12308

- - - - -


1 changed file:

- gajim/common/storage/archive/migration.py


Changes:

=====================================
gajim/common/storage/archive/migration.py
=====================================
@@ -128,6 +128,22 @@ def _execute_multiple(self, statements: list[str]) -> None:
             for stmt in statements:
                 conn.execute(sa.text(stmt))
 
+    def _execute_multiple_with_error(
+        self,
+        statements: list[tuple[str, str] | tuple[str, None]]
+    ) -> None:
+        with self._engine.begin() as conn:
+            for stmt, error_string in statements:
+                try:
+                    conn.execute(sa.text(stmt))
+                except sa.exc.OperationalError as e:
+                    if error_string is not None:
+                        sql_error = e.orig.args[0]
+                        if error_string in sql_error:
+                            log.warning('Ignore "%s" for %s', sql_error, 
e.statement)
+                            continue
+                    raise
+
     def _pre_v7(self, user_version: int) -> None:
         if user_version == 0:
             # All migrations from 0.16.9 until 1.0.0
@@ -273,10 +289,11 @@ def _v11_and_v12(self) -> None:
 
     def _v13(self) -> None:
         statements = [
-            'ALTER TABLE occupant ADD COLUMN "blocked" INTEGER NOT NULL 
DEFAULT (0)',
-            'PRAGMA user_version=13',
+            ('ALTER TABLE occupant ADD COLUMN "blocked" INTEGER NOT NULL 
DEFAULT (0)',
+             'duplicate column'),
+            ('PRAGMA user_version=13', None)
         ]
-        self._execute_multiple(statements)
+        self._execute_multiple_with_error(statements)
 
     def _get_account_pks(self, conn: sa.Connection) -> list[int]:
         account_pks: list[int] = []



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/4a450e6b12b21ba646613154972b6141a864ddb2

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/4a450e6b12b21ba646613154972b6141a864ddb2
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to