Adists: dif: Fix update.

scenarios
Pierre-Antoine 2025-08-21 11:35:39 +02:00
parent e344678ac5
commit 3ef13666dc
2 changed files with 13 additions and 6 deletions

View File

@ -69,6 +69,9 @@ class DIFAdisTS(SQLSubModel):
)
""")
if ext != "":
return True
return cls._create_submodel(execute)
@classmethod
@ -85,7 +88,7 @@ class DIFAdisTS(SQLSubModel):
if not created:
cls._db_update_to_0_2_0(execute, data)
return True
return cls._update_submodel(execute, version, data)
@classmethod
def _db_update_to_0_2_0(cls, execute, data):

View File

@ -107,22 +107,26 @@ class DIFAdisTSSpec(SQLSubModel):
execute(
f"INSERT INTO {table_new}_tmp " +
"(pamhyr_id, pollutant, reach, begin_rk, end_rk, scenario) " +
"SELECT pamhyr_id, pollutant, edge, begin_rk, end_rk, scenario " +
"(pamhyr_id, dif_default, " +
"method, reach, start_rk, end_rk, " +
"dif, b, c, scenario) " +
"SELECT pamhyr_id, dif_default, " +
"method, reach, start_rk, end_rk, " +
"dif, b, c, scenario " +
f"FROM {table}"
)
execute(f"DROP TABLE {table}")
execute(f"ALTER TABLE {table_new}_tmp RENAME TO {table_new}")
cls._db_update_to_0_2_0_set_reach_pid(execute, table, reachs)
cls._db_update_to_0_2_0_set_reach_pid(execute, table_new, reachs)
cls._db_update_to_0_2_0_set_dif_pid(execute, data)
@classmethod
def _db_update_to_0_2_0_set_dif_pid(cls, execute, data):
pid_dif = data["id2pid"]["dif_adists"]
els = execute(
"SELECT pamhyr_id, dif FROM dif_adists_spec"
"SELECT pamhyr_id, dif_default FROM dif_adists_spec"
)
for row in els:
@ -135,7 +139,7 @@ class DIFAdisTSSpec(SQLSubModel):
execute(
f"UPDATE dif_adists_spec" +
f"SET dif = {pid_dif[dif_id]} " +
f"SET dif_default = {pid_dif[dif_id]} " +
f"WHERE pamhyr_id = {pid}"
)