fix(seed): enforce only the 8 canonical topic categories

The topic grids (PM system + wizard) showed extra categories like «سیم»,
«کابل», «ثبثب», «dsfg». Those rows were leftover junk in material_categories
from earlier testing — previously invisible because the frontend hardcoded
the 8-topic list; the API-driven topic grid surfaced them. The rows are
deleted (they had no references) and the seeder now deletes any category
outside the 8 canonical slugs, so a re-seed always yields exactly the same
8 categories as before. Dump refreshed from the clean state.
This commit is contained in:
ali_mohaghegh
2026-09-02 18:28:54 +03:30
parent acb9958059
commit a55c679bb7
2 changed files with 12 additions and 0 deletions
+12
View File
@@ -212,6 +212,18 @@ async def run() -> None:
"category_reference_units, unit_conversions, standard_conversions " "category_reference_units, unit_conversions, standard_conversions "
"RESTART IDENTITY CASCADE" "RESTART IDENTITY CASCADE"
)) ))
# Only the 8 canonical topic categories may exist — any leftover slug
# (e.g. «سیم», «کابل» from earlier testing) is removed so the topic
# grids keep showing exactly the same 8 categories as always.
await db.execute(
text(
"DELETE FROM material_categories WHERE slug NOT IN ("
"'mechanical-installations-pipes','electrical-equipment-supplies',"
"'doors-windows-glass','metals-steel-sections','construction-materials',"
"'construction-chemicals','finishing-interior-decoration',"
"'construction-tools-equipment')"
)
)
# ---- users (roles bound to Casdoor identities by username) ---- # ---- users (roles bound to Casdoor identities by username) ----
users: dict[str, User] = {} users: dict[str, User] = {}
Binary file not shown.