mirror of https://gitlab.com/pamhyr/pamhyr2
Adists: BC: Fix update for scenario.
parent
6cce02650b
commit
0379a8ee02
|
|
@ -91,12 +91,17 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
|||
@classmethod
|
||||
def _db_update(cls, execute, version, data=None):
|
||||
major, minor, release = version.strip().split(".")
|
||||
created = False
|
||||
|
||||
if major == "0" and int(minor) <= 1:
|
||||
if int(release) < 7:
|
||||
cls._db_create(execute)
|
||||
created = True
|
||||
|
||||
elif major == "0" and int(minor) < 2:
|
||||
cls._db_update_to_0_2_0(execute, data)
|
||||
if major == "0" and int(minor) < 2:
|
||||
if not created:
|
||||
cls._db_update_to_0_2_0(execute, data)
|
||||
cls._db_update_to_0_2_0_data(execute, data)
|
||||
|
||||
return True
|
||||
|
||||
|
|
@ -120,12 +125,11 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
|||
execute(f"DROP TABLE {table}")
|
||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||
|
||||
cls._db_update_to_0_2_0_set_node_pid(execute, table, reachs)
|
||||
cls._db_update_to_0_2_0_set_node_pid(execute, table, nodes)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_2_0_data(cls, execute, data):
|
||||
table = "boundary_condition_data_adists"
|
||||
reachs = data['id2pid']['river_reach']
|
||||
|
||||
cls.update_db_add_pamhyr_id(execute, table, data)
|
||||
Scenario.update_db_add_scenario(execute, table)
|
||||
|
|
@ -135,15 +139,13 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
|||
execute(
|
||||
f"INSERT INTO {table}_tmp " +
|
||||
"(pamhyr_id, data0, data1, bca, scenario) " +
|
||||
"SELECT pamhyr_id, data0, data1, bc, scenario) " +
|
||||
"SELECT pamhyr_id, data0, data1, bc, scenario " +
|
||||
f"FROM {table}"
|
||||
)
|
||||
|
||||
execute(f"DROP TABLE {table}")
|
||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||
|
||||
cls._db_update_to_0_2_0_set_reach_pid(execute, table, reachs)
|
||||
|
||||
@classmethod
|
||||
def _db_load(cls, execute, data=None):
|
||||
new = []
|
||||
|
|
@ -197,7 +199,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
|||
values = execute(
|
||||
"SELECT data0, data1 FROM " +
|
||||
"boundary_condition_data_adists " +
|
||||
f"WHERE bc = '{bc.id}' " +
|
||||
f"WHERE bca = '{bc.id}' " +
|
||||
f"AND scenario = {scenario.id}"
|
||||
)
|
||||
|
||||
|
|
@ -228,7 +230,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
|||
)
|
||||
execute(
|
||||
"DELETE FROM boundary_condition_data_adists " +
|
||||
f"WHERE bc = {self.id} " +
|
||||
f"WHERE bca = {self.id} " +
|
||||
f"AND scenario = {self._status.scenario_id} "
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue