Skip to content

Commit

Permalink
chore: keep studyu-schema.sql updated by gh action
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesvedder committed Jun 12, 2024
1 parent bb1b638 commit fe0fcad
Show file tree
Hide file tree
Showing 16 changed files with 1,753 additions and 436 deletions.
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

0 comments on commit fe0fcad

Please sign in to comment.