Philipp Hörist pushed to branch ogp-image-preview at gajim / gajim


Commits:
eb88a9be by Philipp Hörist at 2026-02-23T20:55:43+01:00
Fix migration

- - - - -


1 changed file:

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


Changes:

=====================================
gajim/common/storage/archive/migration.py
=====================================
@@ -103,6 +103,7 @@ class Migration:
     def __init__(self, archive: AlchemyStorage, user_version: int) -> None:
         self._archive = archive
         self._engine = archive.get_engine()
+        self._start_version = user_version
 
         self._account_pks: dict[JID, int] = {}
         self._remote_pks: dict[JID, int] = {}
@@ -363,17 +364,20 @@ def _v16(self) -> None:
 
     def _v17(self) -> None:
         app.ged.raise_event(DBMigrationStart(version=17))
-        self._execute_multiple(
-            [
-                'ALTER TABLE opengraph DROP COLUMN "image"',
-                'ALTER TABLE opengraph DROP COLUMN "site_name"',
-                'ALTER TABLE opengraph DROP COLUMN "type"',
-                'ALTER TABLE opengraph RENAME COLUMN "url" TO "about"',
-                'ALTER TABLE opengraph ADD COLUMN "image_type" TEXT',
-                'ALTER TABLE opengraph ADD COLUMN "image_bytes" BLOB',
-                "PRAGMA user_version=17",
-            ]
-        )
+        if self._start_version == 16:
+            # if the start version is < 16, the version 16 migration will
+            # create the current table, no need to alter it
+            self._execute_multiple(
+                [
+                    'ALTER TABLE opengraph DROP COLUMN "image"',
+                    'ALTER TABLE opengraph DROP COLUMN "site_name"',
+                    'ALTER TABLE opengraph DROP COLUMN "type"',
+                    'ALTER TABLE opengraph RENAME COLUMN "url" TO "about"',
+                    'ALTER TABLE opengraph ADD COLUMN "image_type" TEXT',
+                    'ALTER TABLE opengraph ADD COLUMN "image_bytes" BLOB',
+                ]
+            )
+        self._execute_multiple(["PRAGMA user_version=17"])
 
     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/eb88a9beefdd6426ad53bb3fe812dec236b63c66

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/eb88a9beefdd6426ad53bb3fe812dec236b63c66
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