Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow upgrading unmanaged local DBs #116

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading