-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (56 loc) · 2.03 KB
/
dbml.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Create dbml from database
on:
push:
branches:
- '*'
workflow_dispatch:
jobs:
update_dbdocs:
name: Create trs.dbml
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: trs
POSTGRES_DB: trs
options: >-
--name postgres
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Set postgres wal_level to logical
run: |
docker exec -i postgres bash << EOF
echo "wal_level = logical" >> /var/lib/postgresql/data/postgresql.conf
EOF
docker restart --time 0 postgres
- uses: extractions/setup-just@v2
- name: Install postgresql-client
run: |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null
sudo apt update
sudo apt install postgresql-client-15 -y
- name: Update DB schema
run: dotnet run --project TeachingRecordSystem/src/TeachingRecordSystem.Cli -- migrate-db --connection-string "Host=localhost;Username=postgres;Password=trs;Database=trs"
- name: Dump database
run: |
export PGHOST="localhost"
export PGDATABASE="trs"
export PGUSER="postgres"
export PGPASSWORD="trs"
psql -c '\dt' | sed '1,3d' | head -n -2 | sed 's/ //g' | cut -d'|' -f 2 | tr '\n' ' ' | xargs printf -- ' -t %s' | xargs pg_dump --schema-only >trs.dump
- name: Create dbml file
run: npx -p @dbml/cli sql2dbml trs.dump --postgres -o trs.dbml
- name: Publish dbml file
uses: actions/upload-artifact@v4
with:
name: trs.dbml
path: trs.dbml
if-no-files-found: error