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