Seed dorm data from buildings.json to backend #124
Labels
No labels
backend
beginner friendly
bug
chore
documentation
enhancement
frontend
needs-triage
no-stale
priority/high
priority/low
priority/medium
size/L
size/M
size/S
size/XL
size/XS
stage/backlog
stage/done
stage/in progress
stage/in-progress
stage/ready
stale
wontfix
needs/docs
needs/research
needs/upstream
type/bug
type/external
type/feature
type/refactor
urgency
high
urgency
immediate
urgency
low
urgency
medium
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ScottyLabs/housing#124
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Overall Objective
This blocks a lot so we need this done quickly. Plz only do if u can hammer this out immediately.
Move all 26 buildings out of
apps/frontend/src/data/buildings.jsonand into Postgres, with a repeatable seed script.Compared to the
Buildinginterface inapps/frontend/src/data/buildingTypes.ts, the table is missing:laundry(location and details)accessibility(wheelchair, service animal, ground floor rooms, strobe alarm)atmosphere(socialness, noise level, both used byscoring.ts)gym(available and details)genderHousingcommonAreas.hasLoungeas a boolean, we only havelounge_descriptionlink,description,category,virtualTourLinkand are not the same thing asphoto_gallerybuildings.jsonkeys on"etower"and"fairfax", and every frontend URL uses it. The table only has an integer serial primary key.So this issue is two things: expand the schema, then seed it.
Suggested Approach
scoring.tsfilters or ranks on must be a real column so filtering can move into SQL later: AC level, laundry location, bathroom types, room types, socialness, noise level, gender housing, and the accessibility booleans.json()but type them with.$type<GalleryImage[]>()and.$type<FloorPlan[]>().docs/database-schema.mdspecifically warns that untyped json columns come back asunknown.RoomType,BathroomType,ACLevel,LaundryLocation,KitchenScope,GenderHousing) are numeric. Numeric enums are a poor fit for a database, since0only meansRoomType.TradSingleuntil somebody reorders the enum. Convert topgEnumwith string values and changebuildingTypes.tsto string enums in the same PR so the two sides cannot disagree.slug:text("slug").notNull().unique(). Keep the integeridas the primary key; the slug is what URLs and the seed script key on.deno task db:generate, thendeno task db:migrateto verify). ExportDormandNewDormfrom the schema file using$inferSelectand$inferInsert;docs/database-schema.mdhas the exact snippet and nobody has implemented it yet.apps/backend/scripts/seed-dorms.ts. Model the script shape onapps/backend/scripts/generate-openapi.tsand the database connection onapps/backend/src/db/migrations.ts. Readbuildings.jsonwith a relativenew URL(..., import.meta.url)rather than adding a cross-app workspace dependency.Help & Resources