diff --git a/README.md b/README.md index 05582f2..ab24c15 100644 --- a/README.md +++ b/README.md @@ -74,9 +74,9 @@ Migrations ---------- Once all dependencies are installed it is necessary to run database migrations. -Before that please edit [alembic.ini](alembic.ini) line #32 +Before that it is necessary to set env variable: - sqlalchemy.url = mysql+pymysql://root:root@localhost/functions + export LAOS_MIGRATIONS_DB=mysql+pymysql://root:root@localhost/functions In this section please specify connection URI to your own MySQL database. Once the file is saved, just use alembic to apply the migrations: diff --git a/alembic.ini b/alembic.ini index 11d8746..3d2655b 100644 --- a/alembic.ini +++ b/alembic.ini @@ -29,7 +29,7 @@ script_location = migrations # are written from script.py.mako # output_encoding = utf-8 -sqlalchemy.url = mysql+pymysql://root:root@192.168.0.112/functions +sqlalchemy.url = "" # Logging configuration diff --git a/migrations/env.py b/migrations/env.py index 058378b..f2e5d88 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -3,6 +3,8 @@ from alembic import context from sqlalchemy import engine_from_config, pool from logging.config import fileConfig +import os + # this is the Alembic Config object, which provides # access to the values within the .ini file in use. config = context.config @@ -21,6 +23,7 @@ target_metadata = None # can be acquired: # my_important_option = config.get_main_option("my_important_option") # ... etc. +config.set_main_option("sqlalchemy.url", os.getenv("LAOS_MIGRATIONS_DB")) def run_migrations_offline():