mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
DB: Prepare update to 0.1.0.
This commit is contained in:
1 parent
3675dc5b9d
commit
bf7b18f158
5 files changed
+102
-3
No files matched your search
@@ -78,6 +78,7 @@ class Friction(SQLSubModel):
|
||||
def _db_update_to_0_1_0(cls, execute, data):
|
||||
table = "friction"
|
||||
reachs = data['id2pid']['river_reach']
|
||||
stricklers = data['id2pid']['stricklers']
|
||||
|
||||
cls.update_db_add_pamhyr_id(execute, table, data)
|
||||
Scenario.update_db_add_scenario(execute, table)
|
||||
@@ -97,6 +98,26 @@ class Friction(SQLSubModel):
|
||||
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_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
|
||||
def _db_load(cls, execute, data=None):
|
||||
|
||||
Reference in new issue
Block a user