Data migration code to set the deleted field to 0

The field does not have a default value.
This caused a subcloud cannot be unmanaged after an upgrade.

Test in a simulated environment:
Reproduced the issue with manually setting deleted filed to Null.
Deleted the subcloud_status record with endpoint dc-cert to
simulate pre-upgrade env,
run the sql script to simulate upgrade data migration.
Was able to successfully unmanage the subcloud after.

Change-Id: I4195c1901345c27d10b9dea59ee3f7acb9b1cd12
Story: 2007347
Task: 40113
Signed-off-by: Bin Qian <bin.qian@windriver.com>
This commit is contained in:
Bin Qian
2020-06-25 13:05:07 -04:00
parent ece13f7408
commit 5d66be5049

View File

@@ -106,8 +106,8 @@ def update_subcloud_status():
LOG.info("Nothing to do - load status records already exist.")
cur.execute("INSERT into subcloud_status("
"subcloud_id, endpoint_type, sync_status) "
"select id, 'dc-cert', 'in-sync' "
"subcloud_id, endpoint_type, sync_status, deleted) "
"select id, 'dc-cert', 'in-sync', 0 "
"from subclouds where id not in "
"(select subcloud_id from subcloud_status "
"where endpoint_type = 'dc-cert')")