summaryrefslogtreecommitdiff
path: root/src/mailman/database/base.py
diff options
context:
space:
mode:
authorAbhilash Raj2014-09-25 15:28:46 +0530
committerAbhilash Raj2014-09-25 15:28:46 +0530
commitf2c619de76bd1614a6609f1a61e34ecf8a4344fc (patch)
tree112e4ad6c50e11e7a33dae4a12b02aa99cec19fd /src/mailman/database/base.py
parent03647b16eb75cc841bb15c3c48ac5f18f77118b8 (diff)
downloadmailman-f2c619de76bd1614a6609f1a61e34ecf8a4344fc.tar.gz
mailman-f2c619de76bd1614a6609f1a61e34ecf8a4344fc.tar.zst
mailman-f2c619de76bd1614a6609f1a61e34ecf8a4344fc.zip
Diffstat (limited to 'src/mailman/database/base.py')
-rw-r--r--src/mailman/database/base.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mailman/database/base.py b/src/mailman/database/base.py
index e360dcedf..0afdad204 100644
--- a/src/mailman/database/base.py
+++ b/src/mailman/database/base.py
@@ -25,6 +25,8 @@ __all__ = [
import logging
+from alembic import command
+from alembic.config import Config
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from zope.interface import implementer
@@ -89,6 +91,18 @@ class SABaseDatabase:
"""
pass
+ def stamp(self, debug=False):
+ """Stamp the database with the latest alembic version.
+ """
+ # Newly created database don't need to migrations from alembic, since
+ # `create_all`` ceates the latest schema. SO patch the database with
+ # the latest alembic version to add a entry in alembic_version table.
+ alembic_cfg = Config()
+ alembic_cfg.set_main_option(
+ "script_location", config.alembic['script_location'])
+ command.stamp(alembic_cfg, "head")
+
+
def initialize(self, debug=None):
"""See `IDatabase`."""
# Calculate the engine url.