-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* setup action * interactive: false * turbo * testing complete * readme * test migrate ci * fix * exit code * fix postgres version
- Loading branch information
Showing
15 changed files
with
156 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: "Bun setup" | ||
description: "Sets up bun and installs dependencies" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: 1.1.27 | ||
|
||
- shell: bash | ||
run: bun install --frozen-lockfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Apply Database Migrations | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
migrate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/bun | ||
|
||
- name: Apply Migrations | ||
env: | ||
DATABASE_PRISMA_URL: ${{ secrets.DATABASE_PRISMA_URL }} | ||
run: bun db:migrate:prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Check Database Migrations | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
check-migrations: | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
postgres: | ||
image: postgres:15 | ||
env: | ||
POSTGRES_USER: user | ||
POSTGRES_PASSWORD: password | ||
POSTGRES_DB: db | ||
ports: | ||
- 5432:5432 | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: 1.1.27 | ||
|
||
- name: Install dependencies | ||
run: bun install --frozen-lockfile | ||
|
||
- name: Check migrations | ||
run: bun db:migrate:check postgres://user:password@localhost:5432/db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Database Package | ||
|
||
This package contains all the database-related stuff for the project. We use the Prisma ORM to manage the database schema and migrations. | ||
|
||
## Table of Contents | ||
|
||
- [Database Package](#database-package) | ||
- [Table of Contents](#table-of-contents) | ||
- [Setup](#setup) | ||
- [Installation](#installation) | ||
- [Migrations](#migrations) | ||
- [Creating/Applying Migrations](#creatingapplying-migrations) | ||
- [Prisma Studio](#prisma-studio) | ||
|
||
## Setup | ||
|
||
### Installation | ||
|
||
1. Generate Prisma binaries and typescript types: | ||
|
||
```sh | ||
bun db:generate | ||
``` | ||
|
||
2. Start the database: | ||
|
||
```sh | ||
bun db:up | ||
``` | ||
|
||
3. Push changes to the schema to your database | ||
|
||
```sh | ||
bun db:push | ||
``` | ||
|
||
## Migrations | ||
|
||
### Creating/Applying Migrations | ||
|
||
To create a new migration, follow these steps: | ||
|
||
1. Make changes to your Prisma schema file located at [`apps/db/prisma/schema.prisma`](./prisma/schema.prisma). | ||
|
||
2. Generate a new migration: | ||
|
||
```sh | ||
bun db:migrate | ||
``` | ||
|
||
3. Follow the prompts to name your migration. | ||
|
||
### Prisma Studio | ||
|
||
Prisma Studio is a visual editor for your database. To open Prisma Studio, run: | ||
|
||
```sh | ||
bun db:studio | ||
``` | ||
|
||
This will open a web interface where you can view and edit your database records. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters