mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
DB: Prepare to update 0.1.0.
This commit is contained in:
1 parent
1dfdcb0413
commit
3675dc5b9d
3 files changed
+60
No files matched your search
@@ -80,6 +80,7 @@ class BasicHS(SQLSubModel):
|
||||
@classmethod
|
||||
def _db_update_to_0_1_0(cls, execute, data):
|
||||
table = "hydraulic_structures_basic"
|
||||
hs = data['id2pid']['hydraulic_structures']
|
||||
|
||||
cls.update_db_add_pamhyr_id(execute, table, data)
|
||||
Scenario.update_db_add_scenario(execute, table)
|
||||
@@ -96,6 +97,25 @@ class BasicHS(SQLSubModel):
|
||||
execute(f"DROP TABLE {table}")
|
||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||
|
||||
cls._db_update_to_0_1_0_set_hs_pid(execute, table, hs)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_1_0_set_hs_pid(cls, execute, table, hs):
|
||||
els = execute(
|
||||
f"SELECT pamhyr_id, hs FROM {table}"
|
||||
)
|
||||
|
||||
for row in els:
|
||||
it = iter(row)
|
||||
pid = next(it)
|
||||
hs_id = next(it)
|
||||
|
||||
execute(
|
||||
f"UPDATE {table} " +
|
||||
f"SET hs = {hs[hs_id]} " +
|
||||
f"WHERE pamhyr_id = {pid}"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _get_ctor_from_type(cls, t):
|
||||
from Model.HydraulicStructures.Basic.Types import (
|
||||
|
||||
Reference in new issue
Block a user