home · contact · privacy
Only commit migrations once all performed successfully.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 7 Jan 2025 00:19:31 +0000 (01:19 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 7 Jan 2025 00:19:31 +0000 (01:19 +0100)
plomtask/db.py

index e505b0e8c6adb9a0329f2675fab2c0394e147414..2695bda3964c1933182e338d7e0756615d59518a 100644 (file)
@@ -45,12 +45,13 @@ class DatabaseFile:
                     f'Cannot migrate {from_version} to {EXPECTED_DB_VERSION}')
         migrations = cls._available_migrations()
         migrations_todo = migrations[from_version+1:]
-        with sql_connect(path) as conn:
+        with sql_connect(path, autocommit=False) as conn:
             for j, filename in enumerate(migrations_todo):
                 with open(f'{MIGRATIONS_DIR}/{filename}', 'r',
                           encoding='utf-8') as f:
                     conn.executescript(f.read())
                 conn.execute(f'PRAGMA user_version = {from_version + j + 1}')
+            conn.commit()
         return cls(path)
 
     def _check(self) -> None: