CLI: Add command db.upgrade

This command is a shortcut for "alembic upgrade head".
pull/37/head
Fabian P. Schmidt 2016-01-31 02:25:21 +01:00
rodzic 0e66e77b3e
commit d8046043ae
2 zmienionych plików z 15 dodań i 1 usunięć

Wyświetl plik

@ -125,6 +125,7 @@ available commands:
import_ddb Import registered devices from the DDB.
import_file Import registered devices from a local file.
init Initialize the database.
upgrade Upgrade database to the latest version.
[gateway]
run Run the aprs client.

Wyświetl plik

@ -6,6 +6,8 @@ from ogn.collect.database import update_devices
from manager import Manager
manager = Manager()
ALEMBIC_CONFIG_FILE = "alembic.ini"
@manager.command
def init():
@ -15,11 +17,22 @@ def init():
from alembic import command
Base.metadata.create_all(engine)
alembic_cfg = Config("alembic.ini")
alembic_cfg = Config(ALEMBIC_CONFIG_FILE)
command.stamp(alembic_cfg, "head")
print("Done.")
@manager.command
def upgrade():
"""Upgrade database to the latest version."""
from alembic.config import Config
from alembic import command
alembic_cfg = Config(ALEMBIC_CONFIG_FILE)
command.upgrade(alembic_cfg, 'head')
@manager.command
def drop(sure='n'):
"""Drop all tables."""