Skip to content

Commit 6790d14

Browse files
committed
chore: attempt to wait for orioledb loaded
1 parent f927f62 commit 6790d14

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

nix/tools/dbmate-tool.sh.in

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,24 @@ wait_for_postgres() {
146146
return 1
147147
}
148148

149+
check_orioledb_ready() {
150+
local max_attempts=30
151+
local attempt=1
152+
153+
while [ $attempt -le $max_attempts ]; do
154+
if "${PSQLBIN}/psql" -v ON_ERROR_STOP=1 -U "$PGSQL_SUPERUSER" -p "$PORTNO" -h localhost -d postgres -c "SELECT * FROM pg_am WHERE amname = 'orioledb'" | grep -q orioledb; then
155+
echo "Orioledb extension is ready!"
156+
return 0
157+
fi
158+
echo "Waiting for orioledb to be ready (attempt $attempt/$max_attempts)..."
159+
sleep 2
160+
attempt=$((attempt + 1))
161+
done
162+
163+
echo "Orioledb failed to initialize after $max_attempts attempts"
164+
return 1
165+
}
166+
149167
trim_schema() {
150168
case "$CURRENT_SYSTEM" in
151169
"x86_64-darwin"|"aarch64-darwin")
@@ -215,6 +233,13 @@ migrate_version() {
215233
echo "Failed to connect to PostgreSQL server"
216234
exit 1
217235
fi
236+
237+
if [ "$PSQL_VERSION" = "orioledb-17" ]; then
238+
if ! check_orioledb_ready; then
239+
echo "Failed to initialize orioledb extension"
240+
exit 1
241+
fi
242+
fi
218243

219244
echo "PostgreSQL server is ready"
220245

0 commit comments

Comments
 (0)