Skip to content

Commit

Permalink
feat: Migrate off of PlanetScale
Browse files Browse the repository at this point in the history
  • Loading branch information
simonknittel committed Mar 15, 2024
1 parent 9aa00b6 commit f099075
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 13 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"hashicorp",
"oidc",
"OIDC",
"postgres",
"prisma",
"tfbackend",
"tfvars"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Tools of the Star Citizen organization _Sinister Incorporated_.
- [TypeScript](https://www.typescriptlang.org/)
- [Tailwind CSS](https://tailwindcss.com/)
- [Prisma](https://www.prisma.io/)
- [PlanetScale](https://planetscale.com/)
- [Vercel](https://vercel.com/)
- [NextAuth.js](https://next-auth.js.org/)
- [React Table](https://github.com/TanStack/table)
Expand All @@ -29,6 +28,7 @@ Tools of the Star Citizen organization _Sinister Incorporated_.
- [React Email](https://react.email/)
- [Mailgun](https://www.mailgun.com/)
- [AWS](https://aws.amazon.com/)
- [PostgreSQL](https://www.postgresql.org/)

## Setup

Expand Down
2 changes: 1 addition & 1 deletion app/.env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Prisma
# https://www.prisma.io/docs/reference/database-reference/connection-urls#env
DATABASE_URL="mysql://root:root@127.0.0.1:3306/db"
DATABASE_URL="postgresql://postgres:admin@localhost:5432/db"

# Next Auth
# You can generate a new secret on the command line with:
Expand Down
6 changes: 3 additions & 3 deletions app/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" // PlanetScale doesn't support foreign keys
relationMode = "prisma" // PlanetScale doesn't support foreign keys // TODO: Remove since we are not using PlanetScale anymore
}

//
Expand Down Expand Up @@ -89,7 +89,7 @@ model OperationUnit {
members OperationMember[]
parentUnitId String?
parentUnit OperationUnit? @relation("ChildUnits", fields: [parentUnitId], references: [id], onDelete: NoAction, onUpdate: NoAction)
parentUnit OperationUnit? @relation("ChildUnits", fields: [parentUnitId], references: [id], onDelete: Restrict, onUpdate: Restrict)
childUnits OperationUnit[] @relation("ChildUnits")
}

Expand Down
10 changes: 5 additions & 5 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: "3.8"

services:
db:
image: mysql:8.3.0
psql:
image: postgres:15.6-alpine3.19
restart: on-failure
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: db
POSTGRES_PASSWORD: admin
POSTGRES_DB: db
ports:
- 3306:3306
- 5432:5432
4 changes: 2 additions & 2 deletions docs/changing-database-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
2. Start local database: `docker compose up`
3. Update local database: `npx prisma db push`
4. Commit and push everything to develop
5. Update development branch on PlanetScale: `DATABASE_URL= npx prisma db push`
5. Update stage database: `DATABASE_URL= npx prisma db push`
6. Run production deployment
7. Merge Deploy request on PlanetScale for main branch
7. Update production database: `DATABASE_URL= npx prisma db push`
2 changes: 1 addition & 1 deletion docs/setup-test-and-production.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Setup Test and Production

## 1. Set up PlanetScale
## 1. Set up a PostgreSQL database

## 2. Set up Mailgun

Expand Down
7 changes: 7 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
"@biomejs/biome"
],
"automerge": false
},
{
"matchPackageNames": [
"mysql",
"postgres"
],
"enabled": false
}
],
"configMigration": true,
Expand Down

0 comments on commit f099075

Please sign in to comment.