Skip to content

Commit de0039e

Browse files
committed
fix(pg_graphql): migration script from 1.5.1-mergeless to 1.5.4
Add special case handling for 1.5.1-mergeless to 1.5.4 upgrade path. Also replace CREATE FUNCTION with CREATE OR REPLACE FUNCTION to prevent conflicts in migration scripts and the same for event triggers.
1 parent 198eb88 commit de0039e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

nix/ext/pg_graphql/default.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,21 @@ buildEnv {
160160
VERSION="$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+' <<< $FILENAME)"
161161
if [[ "$PREVIOUS_VERSION" != "" ]]; then
162162
echo "Processing $i"
163+
sed -i 's/CREATE[[:space:]]*FUNCTION/CREATE OR REPLACE FUNCTION/Ig' "$i"
164+
{
165+
echo "DROP EVENT TRIGGER IF EXISTS graphql_watch_ddl CASCADE;"
166+
echo "DROP EVENT TRIGGER IF EXISTS graphql_watch_drop CASCADE;"
167+
cat "$i"
168+
} > "$i.tmp" && mv "$i.tmp" "$i"
163169
MIGRATION_FILENAME="$DIRNAME/''${FILENAME/$VERSION/$PREVIOUS_VERSION--$VERSION}"
164170
cp "$i" "$MIGRATION_FILENAME"
165171
fi
166172
PREVIOUS_VERSION="$VERSION"
167173
done < <(find $out -name '*.sql' | sort -V)
174+
# handle special case of mergeless upgrade from 1.5.1-mergeless to 1.5.4
175+
if [[ -f $out/share/postgresql/extension/pg_graphql--1.5.1--1.5.4.sql ]]; then
176+
cp $out/share/postgresql/extension/pg_graphql--1.5.1--1.5.4.sql $out/share/postgresql/extension/pg_graphql--1.5.1-mergeless--1.5.4.sql
177+
fi
168178
}
169179
170180
create_sql_files

0 commit comments

Comments
 (0)