Skip to content

Commit

Permalink
Fix running alembic from installed package (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
pbylicki authored Apr 10, 2020
1 parent 9b5b309 commit b4e2d74
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include README.md
include rfhub2/alembic.ini
recursive-include rfhub2/static *
recursive-include rfhub2/templates *
recursive-exclude rfhub2 *~ #*#
4 changes: 3 additions & 1 deletion rfhub2/db/migrate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from alembic.config import Config
from alembic.runtime.migration import MigrationContext
from alembic import command
from pathlib import Path
from sqlalchemy.engine import Connection, Engine
from sqlalchemy.engine.reflection import Inspector

Expand All @@ -18,7 +19,8 @@ def has_revision(connection: Connection) -> bool:


def migrate_db(engine: Engine) -> None:
alembic_cfg = Config("rfhub2/alembic.ini")
config_path = Path(__file__).resolve().parent.parent / "alembic.ini"
alembic_cfg = Config(config_path)
with engine.begin() as connection:
# check if database has not been migrated yet with alembic
if has_tables(connection) and not has_revision(connection):
Expand Down
2 changes: 1 addition & 1 deletion rfhub2/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "0.17"
version = "0.18"
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
],
packages=[
'rfhub2',
'rfhub2.alembic',
'rfhub2.alembic.versions',
'rfhub2.api',
'rfhub2.api.endpoints',
'rfhub2.api.middleware',
Expand Down

0 comments on commit b4e2d74

Please sign in to comment.