mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-02 04:46:18 -05:00
Running alembic check in cicd.
This commit is contained in:
parent
4fae4ae1b4
commit
0181f08bec
15 changed files with 174 additions and 43 deletions
10
main.py
10
main.py
|
|
@ -32,7 +32,7 @@ logger = logger.getChild('wrolpi-main')
|
|||
|
||||
def db_main(args):
|
||||
"""
|
||||
Handle database migrations. This uses Alembic, supported commands are "upgrade" and "downgrade".
|
||||
Handle database migrations. This uses Alembic, supported commands are "upgrade", "downgrade", and "check".
|
||||
"""
|
||||
from alembic.config import Config
|
||||
from alembic import command
|
||||
|
|
@ -48,6 +48,11 @@ def db_main(args):
|
|||
command.upgrade(config, 'head')
|
||||
elif args.command == 'downgrade':
|
||||
command.downgrade(config, '-1')
|
||||
elif args.command == 'check':
|
||||
command.check(config)
|
||||
elif args.command == 'revision':
|
||||
message = getattr(args, 'message', None) or 'auto migration'
|
||||
command.revision(config, message=message, autogenerate=True)
|
||||
else:
|
||||
print(f'Unknown DB command: {args.command}')
|
||||
return 2
|
||||
|
|
@ -100,7 +105,8 @@ def main():
|
|||
|
||||
# DB Parser for running Alembic migrations
|
||||
db_parser = sub_commands.add_parser('db')
|
||||
db_parser.add_argument('command', help='Supported commands: upgrade, downgrade')
|
||||
db_parser.add_argument('command', help='Supported commands: upgrade, downgrade, check, revision')
|
||||
db_parser.add_argument('-m', '--message', help='Migration message (for revision command)')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue