hackforla / HomeUniteUs

We're working with community non-profits who have a Host Home or empty bedrooms initiative to develop a workflow management tool to make the process scalable (across all providers), reduce institutional bias, and effectively capture data.
https://homeunite.us/
GNU General Public License v2.0
35 stars 21 forks source link

Add ER Diagram, remove unused db models #657

Closed Joshua-Douglas closed 1 month ago

Joshua-Douglas commented 3 months ago

This PR makes progress towards #655. Before I update the user models I thought it would be useful to clean out all of the unused data models, and plot the currently used models.

What changes did you make?

Rationale behind the changes?

Testing done for these changes

classDiagram
class host{
   *INTEGER id NOT NULL
   VARCHAR name NOT NULL
}
class housing_program{
   *INTEGER id NOT NULL
   VARCHAR program_name NOT NULL
   INTEGER service_provider NOT NULL
}
class housing_program_service_provider{
   *INTEGER id NOT NULL
   VARCHAR provider_name NOT NULL
}
class user{
   *INTEGER id NOT NULL
   VARCHAR email NOT NULL
}
housing_program_service_provider "1" -- "0..n" housing_program
agosmou commented 2 months ago

I left a comment on the parent issue about labeling this PR so we can find it easily if need be. Lmk your thoughts.

tylerthome commented 2 months ago

Waiting on #648 to merge

Joshua-Douglas commented 2 months ago

Hey @mira-kine & @agosmou,

Thanks for highlighting the lack of a database migration script to account for these changes! I've been relying on the API to autogenerate the db, but this approach requires you to delete the database after each update.

To alter the database more properly I added an alembic migration script to drop the removed tables in 8657569. I also updated the old version's migration script to allow it to process databases that were created by the API without ever running alembic in d76be3d. Before this change the old migration script would throw several "table already exists errors".

Now you should be able to run alembic upgrade head. Once you do that you'll be able to generate the most up-to-date ER diagram, without losing any of your user data.

I also updated the ER diagram to include the alembic version number table in aacbeb4.

classDiagram
class alembic_version{
   *VARCHAR<32> version_num NOT NULL
}
class host{
   *INTEGER id NOT NULL
   VARCHAR name NOT NULL
}
class housing_program{
   *INTEGER id NOT NULL
   VARCHAR program_name NOT NULL
   INTEGER service_provider NOT NULL
}
class housing_program_service_provider{
   *INTEGER id NOT NULL
   VARCHAR provider_name NOT NULL
}
class user{
   *INTEGER id NOT NULL
   VARCHAR email NOT NULL
}
housing_program_service_provider "1" -- "0..n" housing_program
Joshua-Douglas commented 2 months ago

Hey @tylerthome,

Thanks for waiting to merge. PR #648 has been merged, and I made a handful of improvements. The PR is ready for re-review.