summaryrefslogtreecommitdiff
path: root/src/mailman/database
diff options
context:
space:
mode:
authorAbhilash Raj2014-09-25 00:47:08 +0530
committerAbhilash Raj2014-09-25 00:47:08 +0530
commit32d118329488df775cd74dad2907ed496022f757 (patch)
tree3981c33507a5e93ce656ffa875ae35a77cfff07f /src/mailman/database
parente0db04cafc3e3d357cb6ce40fcfc7b5d59c1f717 (diff)
downloadmailman-32d118329488df775cd74dad2907ed496022f757.tar.gz
mailman-32d118329488df775cd74dad2907ed496022f757.tar.zst
mailman-32d118329488df775cd74dad2907ed496022f757.zip
add new command `mailman migrate` to migrate the new schema on the old database
Diffstat (limited to 'src/mailman/database')
-rw-r--r--src/mailman/database/alembic/__init__.py0
-rw-r--r--src/mailman/database/alembic/env.py25
2 files changed, 7 insertions, 18 deletions
diff --git a/src/mailman/database/alembic/__init__.py b/src/mailman/database/alembic/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/mailman/database/alembic/__init__.py
diff --git a/src/mailman/database/alembic/env.py b/src/mailman/database/alembic/env.py
index 68d967b7e..002b11aa1 100644
--- a/src/mailman/database/alembic/env.py
+++ b/src/mailman/database/alembic/env.py
@@ -18,30 +18,15 @@
from __future__ import with_statement
from alembic import context
+from alembic.config import Config
from sqlalchemy import create_engine, pool
from logging.config import fileConfig
from mailman.config import config
from mailman.utilities.string import expand
+from mailman.database.model import Model
-# this is the Alembic Config object, which provides
-# access to the values within the .ini file in use.
-alembic_config = context.config
-
-# Interpret the config file for Python logging.
-# This line sets up loggers basically.
-fileConfig(alembic_config.config_file_name)
-
-# add your model's MetaData object here
-# for 'autogenerate' support
-# from myapp import mymodel
-# target_metadata = mymodel.Base.metadata
-target_metadata = None
-
-# other values from the config, defined by the needs of env.py,
-# can be acquired:
-# my_important_option = config.get_main_option("my_important_option")
-# ... etc.
+target_metadata = Model.metadata
def run_migrations_offline():
@@ -70,6 +55,10 @@ def run_migrations_online():
and associate a connection with the context.
"""
+ alembic_cfg= Config()
+ alembic_cfg.set_main_option(
+ "script_location", config.alembic['script_location'])
+
url = expand(config.database.url, config.paths)
engine = create_engine(url)
connection = engine.connect()