You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is just a rough schema, open to suggestions. The difference between address and building_name is that the address is the location of the building, and the building_name is the nickname of the building. For example, an address of a building may be "144 Erb St. East" and the building_name may be "144".
Make sure the buildings SHOW currently uses belongs in the model as well (meaning, when the migration is run, the table will also have the three buildings)
Update the residents table to use the building_id from the new table
Create CRUD endpoints for the buildings table
Delete might be tricky since if a resident is assigned to a building, you won't be able to delete that building due to foreign key constraints. I'm open to what a feasible approach to this is, here are my thoughts: Approach 1: Delete the building if there are no residents linked to it. If there are residents linked to it, throw some error where the user is informed that the delete failed as residents are linked to the building. This would involve a lot of error handling and front-end work. Approach 2: Add a status column to the table, to "deactivate" the building. I don't like this approach, because we have to also add an "activate" building setting. Also, some residents may be living in a deactivated building, which doesn't make sense.
Update the log_records model to use the building table
Add documentation for the model and endpoints
Implementation
Refer to our models and APIs in the codebase
The text was updated successfully, but these errors were encountered:
Summary
Currently, we have our buildings hard-coded across the application. Ideally, these should be stored in the db.
Goals
Create a new model called
buildings
, here is what the schema should look likeThis is just a rough schema, open to suggestions. The difference between address and building_name is that the address is the location of the building, and the building_name is the nickname of the building. For example, an address of a building may be "144 Erb St. East" and the building_name may be "144".
Make sure the buildings SHOW currently uses belongs in the model as well (meaning, when the migration is run, the table will also have the three buildings)
Update the
residents
table to use thebuilding_id
from the new tableCreate CRUD endpoints for the buildings table
Delete might be tricky since if a resident is assigned to a building, you won't be able to delete that building due to foreign key constraints. I'm open to what a feasible approach to this is, here are my thoughts:
Approach 1: Delete the building if there are no residents linked to it. If there are residents linked to it, throw some error where the user is informed that the delete failed as residents are linked to the building. This would involve a lot of error handling and front-end work.
Approach 2: Add a status column to the table, to "deactivate" the building. I don't like this approach, because we have to also add an "activate" building setting. Also, some residents may be living in a deactivated building, which doesn't make sense.
Update the log_records model to use the building table
Add documentation for the model and endpoints
Implementation
The text was updated successfully, but these errors were encountered: