Set up the database schema with Drizzle #27

Closed
opened 2026-06-15 21:20:37 +00:00 by gostmeaper · 0 comments
gostmeaper commented 2026-06-15 21:20:37 +00:00 (Migrated from codeberg.org)

Overall Objective

We need a PostgreSQL database with all tables created before any backend feature can be built. This issue sets up Drizzle ORM in Deno, connects it to Postgres, and runs the initial migration to create all tables.

This will be done after the team has come together to discuss further about the initial tables needed. However, we'll be able to update, add, and remove tables if needed later, but setup would be required for us to continue with the backend.

Suggested Approach

You'll likely need to learn how postgres and drizzle orm work to do this. Ask for help from Yiyoung or your tech lead. Generally this will be using Docker, Dizzle ORM, and Deno if you need a start with looking things up and trying to understand everything. The general instruction/process should be the following.

  1. Add dependencies to deno.json; check if it's already there it should be through Sushrut's PR:
json   "imports": {
     "drizzle-orm": "deno:drizzle-orm",
     "drizzle-kit": "deno:drizzle-kit",
     "postgres": "deno:postgres"
   }
  1. Create src/db/index.ts (or look for where Sushrut put it; he also supposedly also put an example in there). Instantiate a Drizzle client using Deno.env.get("DATABASE_URL")
  2. Copy the full schema from the database schema→ "Drizzle Schema" into src/db/schema.ts
  3. Add a drizzle.config.ts at the project root pointing at src/db/schema.ts
  4. Add tasks to deno.json: db:generate, db:migrate, db:studio
  5. Run deno task db:generate then deno task db:migrate
  6. Verify all tables exist in the DB

Additionally, once everything seems to be working you might want to add docs for others to start the db with.

Help & Resources

### Overall Objective We need a PostgreSQL database with all tables created before any backend feature can be built. This issue sets up Drizzle ORM in Deno, connects it to Postgres, and runs the initial migration to create all tables. This will be done after the team has come together to discuss further about the initial tables needed. However, we'll be able to update, add, and remove tables if needed later, but setup would be required for us to continue with the backend. ### Suggested Approach You'll likely need to learn how postgres and drizzle orm work to do this. Ask for help from Yiyoung or your tech lead. Generally this will be using Docker, Dizzle ORM, and Deno if you need a start with looking things up and trying to understand everything. The general instruction/process should be the following. 1. Add dependencies to deno.json; check if it's already there it should be through Sushrut's PR: ```json json "imports": { "drizzle-orm": "deno:drizzle-orm", "drizzle-kit": "deno:drizzle-kit", "postgres": "deno:postgres" } ``` 2. Create src/db/index.ts (or look for where Sushrut put it; he also supposedly also put an example in there). Instantiate a Drizzle client using Deno.env.get("DATABASE_URL") 3. Copy the full schema from the [database schema](https://lucid.app/lucidchart/cb169728-397a-4993-801b-1c5beeed62b9/edit?viewport_loc=-1185%2C-680%2C2459%2C1864%2C0_0&invitationId=inv_0eebfa91-3957-4426-a47b-316f727e67d6)→ "Drizzle Schema" into src/db/schema.ts 4. Add a drizzle.config.ts at the project root pointing at src/db/schema.ts 5. Add tasks to deno.json: db:generate, db:migrate, db:studio 6. Run deno task db:generate then deno task db:migrate 7. Verify all tables exist in the DB Additionally, once everything seems to be working you might want to add docs for others to start the db with. ### Help & Resources - [Drizzle + PostgreSQL docs](https://orm.drizzle.team/docs/get-started-postgresql) - [Drizzle + Deno](https://orm.drizzle.team/docs/get-started/postgresql-new) - [README](../../ScottyLabs/housing/src/branch/main/README.md) - [Contributing Guidelines](../../ScottyLabs/housing/src/branch/main/docs/CONTRIBUTING.md)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ScottyLabs/housing#27
No description provided.