From ed8522c96a9ec352ea2c9ea6d84c718c692921bc Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 30 Oct 2020 21:39:03 +0100 Subject: [PATCH] script for set the owners to components from parent device --- migration_owners.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 migration_owners.py diff --git a/migration_owners.py b/migration_owners.py new file mode 100644 index 00000000..d1b428dc --- /dev/null +++ b/migration_owners.py @@ -0,0 +1,11 @@ +from ereuse_devicehub.resources.device import models as m +from ereuse_devicehub.db import db + +def migrate(app): + with app.app_context(): + for c in m.Component.query.filter(): + if c.parent_id: + c.owner_id = c.parent.owner.id + db.session.add(c) + db.session.commit() + db.session.flush()