Skip to content

Commit fe619b7

Browse files
committed
normalize script
1 parent 4e1373f commit fe619b7

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import sys
2+
import re
3+
4+
# sort column lines in a psql schema dump alphabetically
5+
def sort_columns(match):
6+
lines = [
7+
line.strip().rstrip(',')
8+
for line in match.group(1).split('\n')
9+
if line.strip()
10+
]
11+
return '(\n ' + ',\n '.join(sorted(lines)) + '\n)'
12+
13+
text = sys.stdin.read()
14+
sys.stdout.write(re.sub(r'\(((?:\n [^\n]+)+)\n\)', sort_columns, text))

.github/workflows/database.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ jobs:
175175
run: |
176176
pg_dump -U dirigent -h localhost dirigent \
177177
--schema-only --no-comments --no-privileges --no-owner \
178-
| grep -vE '^(SET |SELECT |GRANT |REVOKE |\\|$)' \
179-
| sort \
178+
| grep -vE '^(SET |SELECT |$)' \
179+
| python3 .github/scripts/normalize-psql-schema.py \
180180
> /tmp/schema_baseline.sql
181181
pg_dump -U dirigent -h localhost dirigent \
182182
--data-only --no-comments --no-privileges --no-owner \
@@ -206,8 +206,8 @@ jobs:
206206
run: |
207207
pg_dump -U dirigent -h localhost dirigent \
208208
--schema-only --no-comments --no-privileges --no-owner \
209-
| grep -vE '^(SET |SELECT |GRANT |REVOKE |\\|$)' \
210-
| sort \
209+
| grep -vE '^(SET |SELECT |$)' \
210+
| python3 .github/scripts/normalize-psql-schema.py \
211211
> /tmp/schema_reverted.sql
212212
pg_dump -U dirigent -h localhost dirigent \
213213
--data-only --no-comments --no-privileges --no-owner \

0 commit comments

Comments
 (0)