diff --git a/argos/commands.py b/argos/commands.py index ca87647..afc7a75 100644 --- a/argos/commands.py +++ b/argos/commands.py @@ -172,7 +172,8 @@ async def migrate(): settings = get_app_settings() - alembic_cfg = Config("alembic.ini") + current_dir = os.path.dirname(__file__) + alembic_cfg = Config(os.path.join(current_dir, "server/migrations/alembic.ini")) alembic_cfg.set_main_option("sqlalchemy.url", settings.database_url) command.upgrade(alembic_cfg, "head") diff --git a/alembic.ini b/argos/server/migrations/alembic.ini similarity index 87% rename from alembic.ini rename to argos/server/migrations/alembic.ini index 4c84fe0..fa98093 100644 --- a/alembic.ini +++ b/argos/server/migrations/alembic.ini @@ -1,11 +1,11 @@ [alembic] -script_location = alembic +script_location = %(here)s prepend_sys_path = . version_path_separator = os sqlalchemy.url = sqlite:////tmp/argos.db -version_locations = %(here)s/argos/server/migrations/versions +version_locations = %(here)s/versions # Logging configuration [loggers] diff --git a/docs/developer/migrations.md b/docs/developer/migrations.md index a5190e8..72e75c8 100644 --- a/docs/developer/migrations.md +++ b/docs/developer/migrations.md @@ -7,7 +7,7 @@ First, do your changes in the code, change the model, add new tables, etc. Once you're done, you can create a new migration. ```bash -venv/bin/alembic revision --autogenerate -m "migration reason" +venv/bin/alembic -c argos/server/migrations/alembic.ini revision --autogenerate -m "migration reason" ``` Edit the created file to remove comments and adapt it to make sure the migration is complete (Alembic is not powerful enough to cover all the corner cases).