Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Refactor database schema #642

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/dump-database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Dumps database schema
on:
push:
paths:
- ".github/workflows/dump-database.yml"
- "database/**"
- "supabase/**"
workflow_dispatch:

jobs:
pgtap:
runs-on: ubuntu-latest
services:
postgres:
image: supabase/postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Prepare Supabase CI Seed
run: |
cp supabase/seed-ci.sql supabase/seed.sql

- name: Set up Supabase CLI
uses: supabase/setup-cli@v1
with:
version: latest

- name: Start Supabase database
run: |
supabase db start

- name: Export public database schema into database/studyu-schema.sql
run: |
supabase db dump --local --keep-comments --schema public --file database/studyu-schema.sql
2 changes: 1 addition & 1 deletion .github/workflows/supabase-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
services:
postgres:
image: supabase/postgres:15.1.0.90
image: supabase/postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
Expand Down
12 changes: 12 additions & 0 deletions database/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Database

This directory contains the StudyU database schema and migration scripts.

Do not make any changes to the `studyu-schema.sql` file directly. Instead, create a new migration
script in the `migrations` directory. The schema file will be updated automatically by the CI/CD pipeline.

## Migrations

Any new database schema changes should be added as a new migration script in the `migrations` directory.
The migration script should be named `{timestamp}__{description}.sql`, where `{timestamp}` is the current
timestamp and `{description}` is a short description of the migration.
Loading
Loading