mirror of
https://github.com/Steffo99/greed.git
synced 2024-11-24 06:44:19 +00:00
Start work on alembic
This commit is contained in:
parent
e09e7cc6e7
commit
fbf376435c
2 changed files with 11 additions and 3 deletions
|
@ -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.
|
||||
|
||||
|
|
Loading…
Reference in a new issue