From 8ab900dfce5135586bc6ffdcd00b96a4d7be869a Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Mon, 30 Oct 2023 21:40:27 +0100 Subject: [PATCH] github: update postgres migration sed to handle jwt_storage --- .github/workflows/docker-build-static.yml | 2 +- docs/database_migration.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-build-static.yml b/.github/workflows/docker-build-static.yml index e44be6e..aeefcef 100644 --- a/.github/workflows/docker-build-static.yml +++ b/.github/workflows/docker-build-static.yml @@ -347,7 +347,7 @@ jobs: - name: Export and Converting to Postgress run: | bash ./scripts/sqlite_dump_commands.sh | sqlite3 ./users.db > ./dump.sql - sed -i -r -e "s/X'([[:xdigit:]]+'[^'])/'\\\x\\1/g" -e ":a; s/(INSERT INTO user_attribute_schema\(.*\) VALUES\(.*),1([^']*\);)$/\1,true\2/; s/(INSERT INTO user_attribute_schema\(.*\) VALUES\(.*),0([^']*\);)$/\1,false\2/; ta" -e '1s/^/BEGIN;\n/' -e '$aCOMMIT;' ./dump.sql + sed -i -r -e "s/X'([[:xdigit:]]+'[^'])/'\\\x\\1/g" -e ":a; s/(INSERT INTO (user_attribute_schema|jwt_storage)\(.*\) VALUES\(.*),1([^']*\);)$/\1,true\3/; s/(INSERT INTO (user_attribute_schema|jwt_storage)\(.*\) VALUES\(.*),0([^']*\);)$/\1,false\3/; ta" -e '1s/^/BEGIN;\n/' -e '$aCOMMIT;' ./dump.sql - name: Create schema on postgres run: | diff --git a/docs/database_migration.md b/docs/database_migration.md index 34afbcf..4fe9d24 100644 --- a/docs/database_migration.md +++ b/docs/database_migration.md @@ -51,7 +51,7 @@ format to PostgreSQL format, and wrap it all in a transaction: ```sh sed -i -r -e "s/X'([[:xdigit:]]+'[^'])/'\\\x\\1/g" \ --e ":a; s/(INSERT INTO user_attribute_schema\(.*\) VALUES\(.*),1([^']*\);)$/\1,true\2/; s/(INSERT INTO user_attribute_schema\(.*\) VALUES\(.*),0([^']*\);)$/\1,false\2/; ta" \ +-e ":a; s/(INSERT INTO (user_attribute_schema|jwt_storage)\(.*\) VALUES\(.*),1([^']*\);)$/\1,true\3/; s/(INSERT INTO (user_attribute_schema|jwt_storage)\(.*\) VALUES\(.*),0([^']*\);)$/\1,false\3/; ta" \ -e '1s/^/BEGIN;\n/' \ -e '$aSELECT setval(pg_get_serial_sequence('\''groups'\'', '\''group_id'\''), COALESCE((SELECT MAX(group_id) FROM groups), 1));' \ -e '$aCOMMIT;' /path/to/dump.sql