summaryrefslogtreecommitdiff
path: root/src/mailman/database/base.py
diff options
context:
space:
mode:
authorBarry Warsaw2014-09-27 20:17:05 -0400
committerBarry Warsaw2014-09-27 20:17:05 -0400
commit2fcc921b2cca02976a7b1ca8da4f15d55595974e (patch)
treea992a10f3859b892287bf7d2510bdd190cf457db /src/mailman/database/base.py
parentb3500aefb15c63ccf60ab4508868f770ffd2d309 (diff)
parent95fc64b4894e5985bb8d0e5e944b2cda38c9a58c (diff)
downloadmailman-2fcc921b2cca02976a7b1ca8da4f15d55595974e.tar.gz
mailman-2fcc921b2cca02976a7b1ca8da4f15d55595974e.tar.zst
mailman-2fcc921b2cca02976a7b1ca8da4f15d55595974e.zip
Diffstat (limited to 'src/mailman/database/base.py')
-rw-r--r--src/mailman/database/base.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mailman/database/base.py b/src/mailman/database/base.py
index e360dcedf..e49d512c0 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
@@ -32,6 +34,7 @@ from zope.interface import implementer
from mailman.config import config
from mailman.interfaces.database import IDatabase
from mailman.utilities.string import expand
+from mailman.utilities.modules import expand_path
log = logging.getLogger('mailman.config')
@@ -89,6 +92,18 @@ class SABaseDatabase:
"""
pass
+ def stamp(self, debug=False):
+ """Stamp the database with the latest Alembic version."""
+ # Newly created databases don't need migrations from Alembic, since
+ # create_all() ceates the latest schema. This patches the database
+ # with the latest Alembic version to add an entry in the
+ # alembic_version table.
+ alembic_cfg = Config()
+ alembic_cfg.set_main_option(
+ 'script_location', expand_path(config.database['alembic_scripts']))
+ command.stamp(alembic_cfg, 'head')
+
+
def initialize(self, debug=None):
"""See `IDatabase`."""
# Calculate the engine url.