mirror of https://gitlab.com/pamhyr/pamhyr2
DB: Prepare update to 0.1.0.
parent
3675dc5b9d
commit
bf7b18f158
|
|
@ -78,6 +78,7 @@ class Friction(SQLSubModel):
|
||||||
def _db_update_to_0_1_0(cls, execute, data):
|
def _db_update_to_0_1_0(cls, execute, data):
|
||||||
table = "friction"
|
table = "friction"
|
||||||
reachs = data['id2pid']['river_reach']
|
reachs = data['id2pid']['river_reach']
|
||||||
|
stricklers = data['id2pid']['stricklers']
|
||||||
|
|
||||||
cls.update_db_add_pamhyr_id(execute, table, data)
|
cls.update_db_add_pamhyr_id(execute, table, data)
|
||||||
Scenario.update_db_add_scenario(execute, table)
|
Scenario.update_db_add_scenario(execute, table)
|
||||||
|
|
@ -97,6 +98,26 @@ class Friction(SQLSubModel):
|
||||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||||
|
|
||||||
cls._db_update_to_0_1_0_set_reach_pid(execute, table, reachs)
|
cls._db_update_to_0_1_0_set_reach_pid(execute, table, reachs)
|
||||||
|
cls._db_update_to_0_1_0_set_stricklers_pid(execute, table, stricklers)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_update_to_0_1_0_set_stricklers_pid(cls, execute, table, stricklers):
|
||||||
|
els = execute(
|
||||||
|
f"SELECT pamhyr_id, begin_strickler, end_strickler FROM {table}"
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in els:
|
||||||
|
it = iter(row)
|
||||||
|
pid = next(it)
|
||||||
|
b_s_id = next(it)
|
||||||
|
e_s_id = next(it)
|
||||||
|
|
||||||
|
execute(
|
||||||
|
f"UPDATE {table} " +
|
||||||
|
f"SET begin_strickler = {stricklers[b_s_id]}, " +
|
||||||
|
f"end_strickler = {stricklers[e_s_id]} " +
|
||||||
|
f"WHERE pamhyr_id = {pid}"
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_load(cls, execute, data=None):
|
def _db_load(cls, execute, data=None):
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,8 @@ class PointXYZ(Point, SQLSubModel):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update_to_0_1_0(cls, execute, data):
|
def _db_update_to_0_1_0(cls, execute, data):
|
||||||
table = "geometry_pointXYZ"
|
table = "geometry_pointXYZ"
|
||||||
|
reachs = data['id2pid']['sedimentary_layer']
|
||||||
|
profiles = data['id2pid']['geometry_profileXYZ']
|
||||||
|
|
||||||
cls.update_db_add_pamhyr_id(execute, table, data)
|
cls.update_db_add_pamhyr_id(execute, table, data)
|
||||||
Scenario.update_db_add_scenario(execute, table)
|
Scenario.update_db_add_scenario(execute, table)
|
||||||
|
|
@ -89,14 +91,51 @@ class PointXYZ(Point, SQLSubModel):
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
f"INSERT INTO {table}_tmp " +
|
f"INSERT INTO {table}_tmp " +
|
||||||
"(pamhyr_id, name, comment, minor, medium, scenario) " +
|
"(pamhyr_id, name, x, y, z, profile, sl, scenario) " +
|
||||||
"SELECT pamhyr_id, name, comment, minor, medium, scenario " +
|
"SELECT pamhyr_id, name, x, y, z, profile, sl, scenario " +
|
||||||
f"FROM {table}"
|
f"FROM {table}"
|
||||||
)
|
)
|
||||||
|
|
||||||
execute(f"DROP TABLE {table}")
|
execute(f"DROP TABLE {table}")
|
||||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||||
|
|
||||||
|
cls._db_update_to_0_1_0_set_profile_pid(execute, table, profiles)
|
||||||
|
cls._db_update_to_0_1_0_set_sl_pid(execute, table, sl)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_update_to_0_1_0_set_profile_pid(cls, execute, table, profiles):
|
||||||
|
els = execute(
|
||||||
|
f"SELECT pamhyr_id, profile FROM {table}"
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in els:
|
||||||
|
it = iter(row)
|
||||||
|
pid = next(it)
|
||||||
|
profile_id = next(it)
|
||||||
|
|
||||||
|
execute(
|
||||||
|
f"UPDATE {table} " +
|
||||||
|
f"SET profile = {profiles[profile_id]} " +
|
||||||
|
f"WHERE pamhyr_id = {pid}"
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_update_to_0_1_0_set_sl_pid(cls, execute, table, sl):
|
||||||
|
els = execute(
|
||||||
|
f"SELECT pamhyr_id, sl FROM {table}"
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in els:
|
||||||
|
it = iter(row)
|
||||||
|
pid = next(it)
|
||||||
|
sl_id = next(it)
|
||||||
|
|
||||||
|
execute(
|
||||||
|
f"UPDATE {table} " +
|
||||||
|
f"SET sl = {sl[sl_id]} " +
|
||||||
|
f"WHERE pamhyr_id = {pid}"
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_load(cls, execute, data=None):
|
def _db_load(cls, execute, data=None):
|
||||||
status = data["status"]
|
status = data["status"]
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||||
def _db_update_to_0_1_0(cls, execute, data):
|
def _db_update_to_0_1_0(cls, execute, data):
|
||||||
table = "geometry_profileXYZ"
|
table = "geometry_profileXYZ"
|
||||||
reachs = data['id2pid']['river_reach']
|
reachs = data['id2pid']['river_reach']
|
||||||
|
sl = data['id2pid']['sedimentary_layer']
|
||||||
|
|
||||||
cls.update_db_add_pamhyr_id(execute, table, data)
|
cls.update_db_add_pamhyr_id(execute, table, data)
|
||||||
Scenario.update_db_add_scenario(execute, table)
|
Scenario.update_db_add_scenario(execute, table)
|
||||||
|
|
@ -143,6 +144,24 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||||
|
|
||||||
cls._db_update_to_0_1_0_set_reach_pid(execute, table, reachs)
|
cls._db_update_to_0_1_0_set_reach_pid(execute, table, reachs)
|
||||||
|
cls._db_update_to_0_1_0_set_sl_pid(execute, table, sl)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_update_to_0_1_0_set_sl_pid(cls, execute, table, sl):
|
||||||
|
els = execute(
|
||||||
|
f"SELECT pamhyr_id, sl FROM {table}"
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in els:
|
||||||
|
it = iter(row)
|
||||||
|
pid = next(it)
|
||||||
|
sl_id = next(it)
|
||||||
|
|
||||||
|
execute(
|
||||||
|
f"UPDATE {table} " +
|
||||||
|
f"SET sl = {sl[sl_id]} " +
|
||||||
|
f"WHERE pamhyr_id = {pid}"
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_load(cls, execute, data=None):
|
def _db_load(cls, execute, data=None):
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ class Data(SQLSubModel):
|
||||||
cls._db_update_to_0_1_0_set_lc_pid(execute, table, lcs)
|
cls._db_update_to_0_1_0_set_lc_pid(execute, table, lcs)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update_to_0_1_0_set_lc_pid(cls, execute, table, bcs):
|
def _db_update_to_0_1_0_set_lc_pid(cls, execute, table, lcs):
|
||||||
els = execute(
|
els = execute(
|
||||||
f"SELECT pamhyr_id, lc FROM {table}"
|
f"SELECT pamhyr_id, lc FROM {table}"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,7 @@ class Layer(SQLSubModel):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update_to_0_1_0(cls, execute, data):
|
def _db_update_to_0_1_0(cls, execute, data):
|
||||||
table = "sedimentary_layer_layer"
|
table = "sedimentary_layer_layer"
|
||||||
|
sl = data['id2pid']['sedimentary_layer']
|
||||||
|
|
||||||
cls.update_db_add_pamhyr_id(execute, table, data)
|
cls.update_db_add_pamhyr_id(execute, table, data)
|
||||||
Scenario.update_db_add_scenario(execute, table)
|
Scenario.update_db_add_scenario(execute, table)
|
||||||
|
|
@ -151,6 +152,25 @@ class Layer(SQLSubModel):
|
||||||
execute(f"DROP TABLE {table}")
|
execute(f"DROP TABLE {table}")
|
||||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||||
|
|
||||||
|
cls._db_update_to_0_1_0_set_sl_pid(execute, table, sl)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_update_to_0_1_0_set_sl_pid(cls, execute, table, sl):
|
||||||
|
els = execute(
|
||||||
|
f"SELECT pamhyr_id, sl FROM {table}"
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in els:
|
||||||
|
it = iter(row)
|
||||||
|
pid = next(it)
|
||||||
|
sl_id = next(it)
|
||||||
|
|
||||||
|
execute(
|
||||||
|
f"UPDATE {table} " +
|
||||||
|
f"SET sl = {sl[sl_id]} " +
|
||||||
|
f"WHERE pamhyr_id = {pid}"
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_load(cls, execute, data=None):
|
def _db_load(cls, execute, data=None):
|
||||||
new = []
|
new = []
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue