From 121012c1f804c04e870bdc0ed6ba94dd00f3fd33 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 27 Sep 2022 13:02:27 +0200 Subject: [PATCH] add migrations for monitors and mobiles --- .../versions/e919fe0611ff_placeholder_monitors.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/migrations/versions/e919fe0611ff_placeholder_monitors.py b/ereuse_devicehub/migrations/versions/e919fe0611ff_placeholder_monitors.py index cf7efdbc..ff4c0515 100644 --- a/ereuse_devicehub/migrations/versions/e919fe0611ff_placeholder_monitors.py +++ b/ereuse_devicehub/migrations/versions/e919fe0611ff_placeholder_monitors.py @@ -5,7 +5,7 @@ Revises: bcfda54aaf2f Create Date: 2022-09-27 10:55:00.859262 """ -from alembic import context +from alembic import context, op from ereuse_devicehub.db import db from ereuse_devicehub.devicehub import Devicehub @@ -74,13 +74,22 @@ def remove_device(device): def upgrade(): + con = op.get_bind() + devices = con.execute(f'select * from {get_inv()}.device') + if not list(devices): + return + init_app() clone_monitors() db.session.commit() def downgrade(): - pass + con = op.get_bind() + devices = con.execute(f'select * from {get_inv()}.device') + if not list(devices): + return + # init_app() # remove_placeholders() # db.session.commit()