feeder: write new model file after schema renaming (#42320)
gitea/wcs-olap/pipeline/head There was a failure building this commit Details

This commit is contained in:
Serghei Mihai 2021-01-11 14:28:51 +01:00
parent cbd0ec80a6
commit 30f6873d27
1 changed files with 5 additions and 4 deletions

View File

@ -572,10 +572,6 @@ class WcsOlapFeeder(object):
formdef_feeder.feed()
except WcsApiError as e:
self.logger.error('failed to retrieve formdef %s, %s', formdef.slug, e)
if 'cubes_model_dirs' in self.config:
model_path = os.path.join(self.config['cubes_model_dirs'], '%s.model' % self.schema)
with open(model_path, 'w') as f:
json.dump(self.model, f, indent=2, sort_keys=True)
except Exception:
# keep temporary schema alive for debugging
raise
@ -587,6 +583,11 @@ class WcsOlapFeeder(object):
self.ex('DROP SCHEMA IF EXISTS {schema} CASCADE')
self.logger.debug('renaming schema %s to %s', self.schema + '_temp', self.schema)
self.ex('ALTER SCHEMA {schema_temp} RENAME TO {schema}')
if 'cubes_model_dirs' in self.config:
model_path = os.path.join(self.config['cubes_model_dirs'], '%s.model' % self.schema)
with open(model_path, 'w') as f:
json.dump(self.model, f, indent=2, sort_keys=True)
finally:
# prevent connection from remaining open
self.cur.close()