fix schema.sh appending instead of overwriting

pull/177/head
Aevann 2023-08-04 17:19:56 +03:00
parent 4d5d8fdb70
commit 14431a92fa
1 changed files with 3 additions and 3 deletions

View File

@ -3,9 +3,9 @@
. /e
pg_dump -O -x --schema-only "$DATABASE_URL" > '/d/schema.sql'
pg_dump -O -x --data-only --inserts -t 'badge_defs' "$DATABASE_URL" >> "/d/seed-badges.sql"
pg_dump -O -x --data-only --inserts -t 'badge_defs' "$DATABASE_URL" > "/d/seed-badges.sql"
pg_dump -O -x --data-only --inserts -t 'hat_defs' "$DATABASE_URL" >> "/d/seed-hats.sql"
pg_dump -O -x --data-only --inserts -t 'hat_defs' "$DATABASE_URL" > "/d/seed-hats.sql"
sed -i -E "s/(INSERT INTO public.hat_defs VALUES \(.*', )[0-9]{2,}?,/\12,/g" "/d/seed-hats.sql"
sed -i -E "s/INSERT INTO public.hat_defs VALUES \(.*, [0-9]{1,6}, [0-9]{10}\);//g" "/d/seed-hats.sql"
@ -15,7 +15,7 @@ EXPORT_EMOJIS=$(psql --csv --tuples-only -P "null=NULL" -c \
"$DATABASE_URL")
EXPORT_EMOJIS=$(sed 's/.*/\(&\),/' <<< "$EXPORT_EMOJIS")
echo "INSERT INTO public.emojis (name, kind, author_id, tags) VALUES" >> "/d/seed-emojis.sql"
echo "INSERT INTO public.emojis (name, kind, author_id, tags) VALUES" > "/d/seed-emojis.sql"
echo "${EXPORT_EMOJIS%?}" >> "/d/seed-emojis.sql"
echo "ON CONFLICT (name) DO UPDATE SET tags = EXCLUDED.tags;" >> "/d/seed-emojis.sql"