summaryrefslogtreecommitdiff
path: root/src/mailman/database/factory.py
diff options
context:
space:
mode:
authorBarry Warsaw2014-10-13 15:24:24 -0400
committerBarry Warsaw2014-10-13 15:24:24 -0400
commit8bc9e217f5c367794b05105bfc80fffac0e4b863 (patch)
treeab83ccf1bf806bbeddbcf413e17623e8bba9b2b1 /src/mailman/database/factory.py
parentb8715f08a812906fe02289fe4213667ca8f0437e (diff)
parent1a2868b416a139a0cb62fb33bc4225560e19958a (diff)
downloadmailman-8bc9e217f5c367794b05105bfc80fffac0e4b863.tar.gz
mailman-8bc9e217f5c367794b05105bfc80fffac0e4b863.tar.zst
mailman-8bc9e217f5c367794b05105bfc80fffac0e4b863.zip
Diffstat (limited to 'src/mailman/database/factory.py')
-rw-r--r--src/mailman/database/factory.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/mailman/database/factory.py b/src/mailman/database/factory.py
index 9cbe1088f..64174449d 100644
--- a/src/mailman/database/factory.py
+++ b/src/mailman/database/factory.py
@@ -28,8 +28,8 @@ __all__ = [
import os
import types
+import alembic.command
-from alembic import command
from alembic.migration import MigrationContext
from alembic.script import ScriptDirectory
from flufl.lock import Lock
@@ -84,6 +84,8 @@ class SchemaManager:
last_version = self._database.store.query(Version.c.version).filter(
Version.c.component == 'schema'
).order_by(Version.c.version.desc()).first()
+ # Don't leave open transactions or they will block any schema change.
+ self._database.commit()
return last_version
def setup_database(self):
@@ -99,7 +101,8 @@ class SchemaManager:
if storm_version is None:
# Initial database creation.
Model.metadata.create_all(self._database.engine)
- command.stamp(alembic_cfg, 'head')
+ self._database.commit()
+ alembic.command.stamp(alembic_cfg, 'head')
else:
# The database was previously managed by Storm.
if storm_version.version < LAST_STORM_SCHEMA_VERSION:
@@ -107,9 +110,9 @@ class SchemaManager:
'Upgrades skipping beta versions is not supported.')
# Run migrations to remove the Storm-specific table and upgrade
# to SQLAlchemy and Alembic.
- command.upgrade(alembic_cfg, 'head')
+ alembic.command.upgrade(alembic_cfg, 'head')
elif current_rev != head_rev:
- command.upgrade(alembic_cfg, 'head')
+ alembic.command.upgrade(alembic_cfg, 'head')
return head_rev