Start work on alembic
This commit is contained in:
@@ -35,7 +35,8 @@ script_location = alembic
|
||||
# are written from script.py.mako
|
||||
# output_encoding = utf-8
|
||||
|
||||
sqlalchemy.url = driver://user:pass@localhost/dbname
|
||||
# sqlalchemy.url = driver://user:pass@localhost/dbname
|
||||
greed_cfg_file = config/config.toml
|
||||
|
||||
|
||||
[post_write_hooks]
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import importlib
|
||||
from logging.config import fileConfig
|
||||
|
||||
from sqlalchemy import engine_from_config
|
||||
from sqlalchemy import pool
|
||||
|
||||
from alembic import context
|
||||
from ..nuconfig import NuConfig
|
||||
from ..database import TableDeclarativeBase
|
||||
|
||||
|
||||
# this is the Alembic Config object, which provides
|
||||
@@ -19,7 +20,7 @@ fileConfig(config.config_file_name)
|
||||
# for 'autogenerate' support
|
||||
# from myapp import mymodel
|
||||
# target_metadata = mymodel.Base.metadata
|
||||
target_metadata = None
|
||||
target_metadata = TableDeclarativeBase.metadata
|
||||
|
||||
# other values from the config, defined by the needs of env.py,
|
||||
# can be acquired:
|
||||
@@ -27,6 +28,12 @@ target_metadata = None
|
||||
# ... etc.
|
||||
|
||||
|
||||
greed_cfg_file = config.get_main_option("greed_config_file")
|
||||
with open(greed_cfg_file) as f:
|
||||
greed_cfg = NuConfig(f)
|
||||
config["sqlalchemy.url"] = greed_cfg["Database"]["engine"]
|
||||
|
||||
|
||||
def run_migrations_offline():
|
||||
"""Run migrations in 'offline' mode.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user