Skip to content

Commit

Permalink
feat: migrate to supabase (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-lebeau authored Aug 3, 2024
1 parent 3c21a3c commit 6f90f65
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,25 @@ Open [http://localhost:3000](http://localhost:3000) with your browser to see the
## Dashboards

- [Strava](https://www.strava.com/settings/api)
- [Planetscale](https://app.planetscale.com/lebeau-thomas/100-cims)
- [Supabase](https://supabase.com/dashboard/projects)
- [Vercel](https://vercel.com/thomas-lebeau/100-cims)
- [Ngrok](https://dashboard.ngrok.com/tunnels/agents)

## Database

Database is hosted on [Planetscale](https://app.planetscale.com/lebeau-thomas/100-cims).
Database is hosted on [Supabase](https://supabase.com/dashboard/projects).

### Update db schema

Updates are done via [Prisma](https://www.prisma.io/). Edit the schema in `prisma/schema.prisma` and run the following commands to apply the changes to dev environement. Changes to production are done via creating deploy requests in [Planetscale](https://app.planetscale.com/lebeau-thomas/100-cims/dev).
Updates are done via [Prisma](https://www.prisma.io/). Edit the schema in `prisma/schema.prisma` and run the following commands to apply the changes.

#### Development
#### Production

1. Make changes to the schema in `prisma/schema.prisma`
2. Run `npx prisma db push`
3. Run `npx prisma generate`
4. Restart dev server

#### Production

1. Create a deploy request in [Planetscale](https://app.planetscale.com/lebeau-thomas/100-cims/dev)
2. Deploy it!

### Seeding

Resets the database and seeds it with data for `Cim` and `Comarca` tables.
Expand Down
2 changes: 1 addition & 1 deletion e2e/test-users.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// TODO: make sure this user exist and is connected to strava in dev db
export const USER = {
email: "[email protected]",
userId: "clrgyxhx00000ereeuwlk42yq",
userId: "clze42p6k0000whkp2sbhxpic",
stravaAccountId: 130099507, // https://www.strava.com/athletes/130099507
activityId: 10611571930, // https://www.strava.com/activities/10611571930
} as const;
8 changes: 3 additions & 5 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ generator client {
}

datasource db {
provider = "mysql"
provider = "postgresql"
url = env("DATABASE_URL")
relationMode = "prisma"
directUrl = env("DIRECT_URL")
}

model Account {
Expand Down Expand Up @@ -110,8 +110,7 @@ model Activity {
Sync Sync? @relation(fields: [syncId], references: [id], onDelete: Cascade)
Ascent Ascent[]
@@unique([userId, originType, originId(length: 20)]) // TODO: fix originId field length
@@index([userId])
@@unique([userId, originType, originId])
@@index([syncId])
}

Expand All @@ -128,7 +127,6 @@ model Ascent {
@@unique([cimId, userId, activityId])
@@index([userId])
@@index([cimId])
@@index([activityId])
}

Expand Down

1 comment on commit 6f90f65

@vercel
Copy link

@vercel vercel bot commented on 6f90f65 Aug 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.