DB: Fixes for db 0.1.0 creation.

This commit is contained in:
Pierre-Antoine Rouby committed 2024-07-29 16:28:46 +02:00
1 parent 9ec080a107
commit 328f5656bf
11 files changed
+32 -21

No files matched your search

@@ -21,6 +21,7 @@ import logging
from tools import trace, timer
from Model.Tools.PamhyrDB import SQLSubModel
from Model.Scenario import Scenario
from Model.Except import NotImplementedMethodeError
from Model.HydraulicStructures.Basic.Value import (
@@ -48,7 +49,7 @@ class BasicHS(SQLSubModel):
self._data = []
@classmethod
def _db_create(cls, execute):
def _db_create(cls, execute, ext=""):
execute(f"""
CREATE TABLE hydraulic_structures_basic{ext} (
{cls.create_db_add_pamhyr_id()},
@@ -56,9 +57,9 @@ class BasicHS(SQLSubModel):
type TEXT NOT NULL,
enabled BOOLEAN NOT NULL,
hs INTEGER,
FOREIGN KEY(hs) REFERENCES hydraulic_structures(pamhyr_id),
{Scenario.create_db_add_scenario()},
{Scenario.create_db_add_scenario_fk()},
FOREIGN KEY(hs) REFERENCES hydraulic_structures(pamhyr_id),
PRIMARY KEY(pamhyr_id, scenario)
)
""")