summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mailman/commands/docs/conf.rst2
-rw-r--r--src/mailman/config/schema.cfg4
-rw-r--r--src/mailman/database/alembic/env.py1
-rw-r--r--src/mailman/database/base.py14
-rw-r--r--src/mailman/database/factory.py7
5 files changed, 19 insertions, 9 deletions
diff --git a/src/mailman/commands/docs/conf.rst b/src/mailman/commands/docs/conf.rst
index 7b8529ac3..99ca6b054 100644
--- a/src/mailman/commands/docs/conf.rst
+++ b/src/mailman/commands/docs/conf.rst
@@ -22,7 +22,7 @@ To get a list of all key-value pairs of any section, you need to call the
command without any options.
>>> command.process(FakeArgs)
- [logging.archiver] path: mailman.log
+ [alembic] script_location: mailman:database/alembic
...
[passwords] password_length: 8
...
diff --git a/src/mailman/config/schema.cfg b/src/mailman/config/schema.cfg
index 23382721c..f42ba9b66 100644
--- a/src/mailman/config/schema.cfg
+++ b/src/mailman/config/schema.cfg
@@ -532,7 +532,7 @@ register_bounces_every: 15m
# following values.
# The class implementing the IArchiver interface.
-class:
+class:
# Set this to 'yes' to enable the archiver.
enable: no
@@ -642,4 +642,4 @@ rewrite_duplicate_headers:
MIME-Version X-MIME-Version
[alembic]
-script_location: src/mailman/database/alembic
+script_location: mailman:database/alembic
diff --git a/src/mailman/database/alembic/env.py b/src/mailman/database/alembic/env.py
index 11ea8f6da..2d9d48fd7 100644
--- a/src/mailman/database/alembic/env.py
+++ b/src/mailman/database/alembic/env.py
@@ -57,6 +57,7 @@ def run_migrations_online():
alembic_cfg= Config()
alembic_cfg.set_main_option(
"script_location", config.alembic['script_location'])
+ alembic_cfg.set_section_option('logger_alembic' ,'level' , 'ERROR')
url = expand(config.database.url, config.paths)
engine = create_engine(url)
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.
diff --git a/src/mailman/database/factory.py b/src/mailman/database/factory.py
index d4857866a..0a295331a 100644
--- a/src/mailman/database/factory.py
+++ b/src/mailman/database/factory.py
@@ -29,9 +29,6 @@ __all__ = [
import os
import types
-from alembic.config import Config
-from alembic import command
-
from flufl.lock import Lock
from zope.interface import implementer
from zope.interface.verify import verifyObject
@@ -42,8 +39,6 @@ from mailman.interfaces.database import IDatabase, IDatabaseFactory
from mailman.utilities.modules import call_name
-alembic_cfg = Config("./alembic.ini")
-
@implementer(IDatabaseFactory)
class DatabaseFactory:
@@ -58,7 +53,7 @@ class DatabaseFactory:
verifyObject(IDatabase, database)
database.initialize()
Model.metadata.create_all(database.engine)
- command.stamp(alembic_cfg, "head")
+ database.stamp()
database.commit()
return database