mirror of https://gitlab.com/pamhyr/pamhyr2
DB: Some fixes for db update to 0.1.0.
parent
2290e2eb6d
commit
74c61262b7
|
|
@ -91,8 +91,8 @@ class PointXYZ(Point, SQLSubModel):
|
|||
|
||||
execute(
|
||||
f"INSERT INTO {table}_tmp " +
|
||||
"(pamhyr_id, name, x, y, z, profile, sl, scenario) " +
|
||||
"SELECT pamhyr_id, name, x, y, z, profile, sl, scenario " +
|
||||
"(pamhyr_id, ind, name, x, y, z, profile, sl, scenario) " +
|
||||
"SELECT pamhyr_id, ind, name, x, y, z, profile, sl, scenario " +
|
||||
f"FROM {table}"
|
||||
)
|
||||
|
||||
|
|
@ -133,6 +133,9 @@ class PointXYZ(Point, SQLSubModel):
|
|||
pid = next(it)
|
||||
sl_id = next(it)
|
||||
|
||||
if sl_id == -1:
|
||||
continue
|
||||
|
||||
execute(
|
||||
f"UPDATE {table} " +
|
||||
f"SET sl = {sl[sl_id]} " +
|
||||
|
|
|
|||
|
|
@ -92,6 +92,9 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
)
|
||||
""")
|
||||
|
||||
if ext == "_tmp":
|
||||
return True
|
||||
|
||||
return cls._create_submodel(execute)
|
||||
|
||||
@classmethod
|
||||
|
|
@ -160,6 +163,9 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
pid = next(it)
|
||||
sl_id = next(it)
|
||||
|
||||
if sl_id == -1:
|
||||
continue
|
||||
|
||||
execute(
|
||||
f"UPDATE {table} " +
|
||||
f"SET sl = {sl[sl_id]} " +
|
||||
|
|
|
|||
|
|
@ -64,6 +64,9 @@ class BasicHS(SQLSubModel):
|
|||
)
|
||||
""")
|
||||
|
||||
if ext == "_tmp":
|
||||
return True
|
||||
|
||||
return cls._create_submodel(execute)
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
|
|
@ -72,6 +72,9 @@ class HydraulicStructure(SQLSubModel):
|
|||
)
|
||||
""")
|
||||
|
||||
if ext == "_tmp":
|
||||
return True
|
||||
|
||||
return cls._create_submodel(execute)
|
||||
|
||||
@classmethod
|
||||
|
|
@ -83,7 +86,7 @@ class HydraulicStructure(SQLSubModel):
|
|||
if rl < 6:
|
||||
cls._db_create(execute)
|
||||
|
||||
if rl < 11:
|
||||
if 6 < rl < 11:
|
||||
for v in ["input", "output"]:
|
||||
execute(
|
||||
f"""
|
||||
|
|
|
|||
|
|
@ -309,13 +309,13 @@ class RiverReach(Edge, SQLSubModel):
|
|||
class River(Graph, SQLSubModel):
|
||||
_sub_classes = [
|
||||
StricklersList,
|
||||
SedimentLayerList,
|
||||
RiverNode,
|
||||
RiverReach,
|
||||
BoundaryConditionList,
|
||||
LateralContributionList,
|
||||
InitialConditionsDict,
|
||||
SolverParametersList,
|
||||
SedimentLayerList,
|
||||
ReservoirList,
|
||||
HydraulicStructureList,
|
||||
AddFileList,
|
||||
|
|
|
|||
|
|
@ -103,11 +103,11 @@ class Scenario(SQLSubModel):
|
|||
"ADD COLUMN scenario INTEGER NOT NULL DEFAULT 0"
|
||||
)
|
||||
|
||||
execute(
|
||||
f"ALTER TABLE {table} " +
|
||||
"ADD CONSTRAINT fk_scenario FOREIGN KEY (scenario) " +
|
||||
"REFERENCES scenario(id)"
|
||||
)
|
||||
# execute(
|
||||
# f"ALTER TABLE {table} " +
|
||||
# "ADD CONSTRAINT fk_scenario FOREIGN KEY (scenario) " +
|
||||
# "REFERENCES scenario(id)"
|
||||
# )
|
||||
|
||||
@classmethod
|
||||
def _db_load(cls, execute, data=None):
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class Layer(SQLSubModel):
|
|||
if major == minor == "0":
|
||||
if int(release) < 2:
|
||||
cls._db_create(execute)
|
||||
|
||||
else:
|
||||
cls._db_update_to_0_1_0(execute, data)
|
||||
|
||||
return cls._update_submodel(execute, version, data)
|
||||
|
|
@ -142,9 +142,9 @@ class Layer(SQLSubModel):
|
|||
|
||||
execute(
|
||||
f"INSERT INTO {table}_tmp " +
|
||||
"(pamhyr_id, name, type, height, " +
|
||||
"(pamhyr_id, ind, name, type, height, " +
|
||||
"d50, sigma, critical_constraint, sl, scenario) " +
|
||||
"SELECT pamhyr_id, name, type, height, " +
|
||||
"SELECT pamhyr_id, ind, name, type, height, " +
|
||||
"d50, sigma, critical_constraint, sl, scenario " +
|
||||
f"FROM {table}"
|
||||
)
|
||||
|
|
@ -296,6 +296,9 @@ class SedimentLayer(SQLSubModel):
|
|||
)
|
||||
""")
|
||||
|
||||
if ext == "_tmp":
|
||||
return True
|
||||
|
||||
return cls._create_submodel(execute)
|
||||
|
||||
@classmethod
|
||||
|
|
@ -304,7 +307,7 @@ class SedimentLayer(SQLSubModel):
|
|||
if major == minor == "0":
|
||||
if int(release) < 2:
|
||||
cls._db_create(execute)
|
||||
|
||||
else:
|
||||
cls._db_update_to_0_1_0(execute, data)
|
||||
|
||||
return cls._update_submodel(execute, version, data)
|
||||
|
|
|
|||
Loading…
Reference in New Issue