-
Notifications
You must be signed in to change notification settings - Fork 9
94 lines (83 loc) · 2.55 KB
/
migration.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Run Migration Tests and Benchmarks
on:
push:
branches:
- main
paths:
- postgres/migrations/**
- postgres/benches/**
pull_request:
branches:
- main
paths:
- postgres/migrations/**
- postgres/benches/**
env:
PGHOST: localhost
PGPORT: 5432
PGUSER: postgres
PGPASSWORD: password
PGDB: postgres
jobs:
migrations:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Packages
run: |
sudo apt-get update
sudo apt-get -y install postgresql-client
- name: Start postgres
working-directory: ./postgres/migrations
run: |
docker build -t appflowy_postgres .
docker run -e POSTGRES_PASSWORD=password -p 5432:5432 -d appflowy_postgres
sleep 10 # wait for ready
- name: Run all up migrations
working-directory: ./postgres/migrations
run: |
for sql_script in $(ls | grep _up.sql | sort)
do
echo "Executing $sql_script"
psql --host=$PGHOST --username=$PGUSER --dbname=$PGDB --file=$sql_script --variable ON_ERROR_STOP=on
if [ $? -ne 0 ]
then
echo "Migration $sql_script failed"
exit 1
fi
done
- name: Run migration tests
working-directory: ./postgres/migrations_tests
run: |
./check
./af_user
./af_user_update
./af_collab_update
- uses: Swatinem/rust-cache@v2
with:
workspaces: |
AppFlowy-Supabase/postgres
cache-all-crates: true
- name: Run benchmark (insert into af_collab_update)
working-directory: ./postgres
run: cargo bench
- name: Run all down migrations
working-directory: ./postgres/migrations
run: |
for sql_script in $(ls | grep .down.sql | sort -r)
do
echo "Executing $sql_script"
psql --host=$PGHOST --username=$PGUSER --dbname=$PGDB --file=$sql_script --variable ON_ERROR_STOP=on
if [ $? -ne 0 ]
then
echo "Migration $sql_script failed"
exit 1
fi
done
# should not have any relations after down
ITEMS=$(psql --host=$PGHOST --username=$PGUSER --dbname=$PGDB --command "\d")
if [[ "$ITEMS" ]]; then
echo "There are still items after executing all down scripts"
exit 1
fi