Skip to content

Commit

Permalink
Allow upgrading unmanaged local DBs (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
glatterf42 authored Oct 1, 2024
1 parent 215e613 commit 4b0e421
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions ixmp4/cli/platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,24 +167,30 @@ def list_():
)
)
def upgrade():
utils.echo(
f"Establishing self-signed admin connection to '{settings.manager_url}'."
)
if settings.managed:
utils.echo(
f"Establishing self-signed admin connection to '{settings.manager_url}'."
)
manager_conf = ManagerConfig(
str(settings.manager_url),
SelfSignedAuth(settings.secret_hs256),
remote=False,
)
platform_list = manager_conf.list_platforms()
else:
platform_list = settings.toml.list_platforms()

manager_conf = ManagerConfig(
str(settings.manager_url), SelfSignedAuth(settings.secret_hs256), remote=False
)
for m in manager_conf.list_platforms():
if m.dsn.startswith("http"):
for p in platform_list:
if p.dsn.startswith("http"):
# This should probably never happen unless the manager registers an
# external rest platform.
utils.echo(f"Skipping '{m.name}' because it is a REST platform.")
utils.echo(f"Skipping '{p.name}' because it is a REST platform.")
else:
utils.echo(f"Upgrading manager platform '{m.name}' with dsn '{m.dsn}'...")
utils.echo(f"Upgrading platform '{p.name}' with dsn '{p.dsn}'...")
try:
alembic.upgrade_database(m.dsn, "head")
alembic.upgrade_database(p.dsn, "head")
except OperationalError as e:
utils.echo(f"Skipping '{m.name}' because of an error: {str(e)}")
utils.echo(f"Skipping '{p.name}' because of an error: {str(e)}")


@app.command(
Expand Down

0 comments on commit 4b0e421

Please sign in to comment.