-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set alembic
script_location
config at runtime (#84)
* fix: set alembic `script_location` config at runtime * test: alembic `script_location` in unit tests
- Loading branch information
1 parent
84ef00e
commit 170cee3
Showing
3 changed files
with
11 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
"""DB migrations commands """ | ||
from os import getcwd | ||
|
||
from os.path import dirname | ||
from alembic.config import Config | ||
from alembic import command | ||
|
||
|
||
ALEMBIC_CFG = Config(f'{getcwd()}/alembic.ini') | ||
alembic_cfg = Config(f'{getcwd()}/alembic.ini') | ||
alembic_cfg.set_main_option('script_location', dirname(__file__)) | ||
|
||
|
||
def current(verbose=False): | ||
command.current(ALEMBIC_CFG, verbose=verbose) | ||
command.current(alembic_cfg, verbose=verbose) | ||
|
||
|
||
def upgrade(revision="head"): | ||
command.upgrade(ALEMBIC_CFG, revision) | ||
command.upgrade(alembic_cfg, revision) | ||
|
||
|
||
def downgrade(revision): | ||
command.downgrade(ALEMBIC_CFG, revision) | ||
command.downgrade(alembic_cfg, revision) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters