HackUCF / OnboardLite

MIT License
0 stars 2 forks source link

Abstract Database Calls #19

Open jontyms opened 5 months ago

jontyms commented 5 months ago

All database calls should be abstracted in a different module that should allow easier switching to Postgres in the future

jeffreydivi commented 5 months ago

After discussions with @Helithumper, I disagree that going from one NoSQL walled garden to another is a good idea. Ideally, an ORM like SQLAlchemy should be used, which gives you options between different database types, and could even help ease the migration between different DB backends.

You should also find one that supports data type migrations. The migration from int to str for Discord snowflakes was a mess that you can see in the code right now. This should be purged from the earth if possible, and in the future, a DB migration would help clean this up.

However, here be dragons: the Kennelish code for pre-populating fields in forms + saving them to the database is very easy to mess up and is known to consist of risky code that must be heavily vetted. Peyton and I advise somehow limiting what can be pushed through this logic by using an allow-list of values scraped from either the Pydantic schema for the database or the sum of all database keys defined in the forms (those JSON files in forms).

I fully expect to have to do some consulting for this. You know where to find me.

Also for your enjoyment: https://sqlmodel.tiangolo.com. That should help you all a lot in this migration.

Helithumper commented 4 months ago

Thought about this a little bit there's two parts to this.

One. Immigration tool in order to move the original data that's in dynamo into a local sequel database.

Two. Design of a local database. it doesn't have to be psql could be even be SQLite. It is incredibly simple given that it's a single table of not very many columns anyways.

I think the first part of this is to replace the current calls to dynamo DB with a function which returns back a list of users, and that should at least cover the large scale refactoring work that would need to be done in order for this to occur.