refactor(backend): passe les tables data au singulier et clarifie alert_id
La convention de docs/architecture/40-data.md impose des noms de tables au singulier, que les quatre tables d'authentification respectent déjà. Les six tables data passent donc au singulier, avec leurs contraintes et leurs index. La révision n'étant appliquée que sur des bases locales, elle est modifiée sur place plutôt que doublée d'une migration de renommage. alert_id désignait deux colonnes différentes : la clé métier text de l'API Mock et la clé étrangère bigint de recommendation. La première devient source_alert_id, la seconde pointe désormais vers alert.alert_id.
This commit is contained in:
@@ -41,12 +41,12 @@ async def data_site(data_connection: AsyncConnection) -> str:
|
||||
return site_id
|
||||
|
||||
|
||||
async def test_readings_is_a_time_hypertable_when_migrated(
|
||||
async def test_reading_is_a_time_hypertable_when_migrated(
|
||||
data_connection: AsyncConnection,
|
||||
) -> None:
|
||||
query = text(
|
||||
"SELECT column_name FROM timescaledb_information.dimensions "
|
||||
"WHERE hypertable_schema = 'public' AND hypertable_name = 'readings'"
|
||||
"WHERE hypertable_schema = 'public' AND hypertable_name = 'reading'"
|
||||
)
|
||||
|
||||
result = await data_connection.execute(query)
|
||||
@@ -216,7 +216,7 @@ async def test_alert_rejects_prediction_when_site_differs(
|
||||
async with data_connection.begin_nested():
|
||||
await data_connection.execute(
|
||||
insert(Alert).values(
|
||||
alert_id=str(uuid4()),
|
||||
source_alert_id=str(uuid4()),
|
||||
site_id=other_site,
|
||||
source="enervision",
|
||||
timestamp=MOMENT,
|
||||
@@ -236,7 +236,7 @@ async def test_recommendation_is_unique_when_alert_and_rule_match(
|
||||
await data_connection.execute(
|
||||
insert(Alert)
|
||||
.values(
|
||||
alert_id=str(uuid4()),
|
||||
source_alert_id=str(uuid4()),
|
||||
site_id=data_site,
|
||||
source="api_mock",
|
||||
timestamp=MOMENT,
|
||||
@@ -245,7 +245,7 @@ async def test_recommendation_is_unique_when_alert_and_rule_match(
|
||||
message="Test",
|
||||
raw_data={},
|
||||
)
|
||||
.returning(Alert.id)
|
||||
.returning(Alert.alert_id)
|
||||
)
|
||||
).scalar_one()
|
||||
statement = insert(Recommendation).values(
|
||||
|
||||
Reference in New Issue
Block a user