WSU-Software-Development-Club / WSU-Software-Development-Club/self-hosting
Set up SQLAlchemy + Alembic with a User model
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
Why
This is the first real database code and it establishes how models and migrations work for every feature after it.
Depends on: the healthchecks issue (api must wait for Postgres before running migrations).
Files to touch
backend/app/db.py(new): engine + sessionbackend/app/models.py(new):Usermodelbackend/alembic/(new): migration environmentbackend/requirements.txt- api service
commandindocker-compose.yml
Definition of done
-
Usermodel withid,email(unique, indexed),password_hash,created_at - Database URL is built from the env vars in
.env -
alembic upgrade headruns automatically when the api container starts - After
docker compose up, auserstable exists in Postgres (verify withdocker compose exec db psql -U $POSTGRES_USER -d $POSTGRES_DB -c '\dt') - CI workflow updated with a Postgres service so tests still pass
Hints
Run alembic init alembic inside the backend container, then point env.py at the app's metadata. Alembic tutorial: https://alembic.sqlalchemy.org/en/latest/tutorial.html
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with backend/requirements.txt, backend/app/db.py, backend/app/models.py, and the Alembic tutorial; then inspect the api command in docker-compose.yml and the existing CI workflow. Set up the migration environment and User model, run migrations on container startup, and verify the users table with the provided docker compose exec command while ensuring CI tests still pass with Postgres.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker-compose, postgresql, python, sqlalchemy
- Domain
- backend, ci-cd, database, devops
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100