Expand the dorm table so it can hold everything buildings.json holds #98
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#98
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
Currently all of our building data lives in
apps/frontend/src/data/buildings.json, but it shouldn't be in the frontend in the first place. This data should be able to be held in the backend. The first step to moving this data to the backend is making sure the postgres db is able to hold the data. So with this issue we will expland the schema and types in the db.For reference, it might be helpful to look at the
Buildinginterface inapps/frontend/src/data/buildingTypes.ts, provided to the app throughBuildingContext.We want that data in Postgres and served by the backend. The blocker is that the
dormtable inapps/backend/src/db/schema.tsis much thinner thanBuilding. It's missing:laundry(location + details)accessibility(wheelchair, service animal, ground floor rooms, strobe alarm)atmosphere(socialness and noise level, both used byscoring.tsfor filtering)gym(available + details)genderHousingcommonAreas.hasLoungeas a boolean (we only havelounge_description)link,description,category,virtualTourLink) and not the same thing asphoto_gallerybuildings.jsonkeys on"etower","mudge"etc., and every frontend URL is/building/:idusing that slug. The table only has an integerserialPK.This issue is only the schema and the types. No route, no seeding, no frontend changes. Please don't try to do everything at once.
Suggested Approach
apps/frontend/src/data/buildingTypes.tsfirst. That interface is the target shape. Also readdocs/data-codebook.md, which documents every field and what it means.scoring.tsfilters or sorts on must be a real column so we can push filtering into SQL later: AC level, laundry location, bathroom types, room types, socialness, noise level, and the accessibility booleans.json()columns, but type them with.$type<GalleryImage[]>()/.$type<FloorPlan[]>()so they aren't unknown downstream.buildingTypes.ts(RoomType,BathroomType,ACLevel,LaundryLocation,KitchenScope,GenderHousing) are numeric enums. Generally, numeric enums are a bad fit for a database.0meansRoomType.TradSingleonly as long as nobody reorders the enum. Convert them topgEnumwith string values ("trad_single","communal","central", and so on).slugcolumn,text("slug").notNull().unique(), holding"etower","mudge", etc. Keep the integeridas the PK; the slug is what URLs and the seed script key on.deno task db:generate, thendeno task db:migrateto verify).Dorm/NewDormtypes from the schema file using$inferSelect/$inferInsert.Help & Resources
$typeon json columns