File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -189,6 +189,36 @@ jobs:
189189 find suprabase -maxdepth 2 -type f -print | sort || true
190190 echo "::endgroup::"
191191
192+ echo "::group::Supabase migrations catalog check"
193+ bash <<'BASH'
194+ set -euo pipefail
195+
196+ find_db_container() {
197+ docker ps --format '{{.ID}} {{.Names}} {{.Image}}' | awk '$3 ~ /^supabase\/postgres(:|$)/ {print $1" "$2; exit}'
198+ }
199+
200+ db_container_line=$(find_db_container)
201+ if [ -z "${db_container_line}" ]; then
202+ db_container_line=$(docker ps --format '{{.ID}} {{.Names}} {{.Image}}' | awk '$2 ~ /_db_/ {print $1" "$2; exit}')
203+ fi
204+
205+ if [ -z "${db_container_line}" ]; then
206+ echo "Supabase database container not found; cannot verify catalog" >&2
207+ exit 1
208+ fi
209+
210+ container_id=$(echo "${db_container_line}" | awk '{print $1}')
211+ catalog_present=$(docker exec -e PGPASSWORD=postgres "${container_id}" psql -U postgres -d postgres -At -c "select to_regclass('supabase_migrations.schema_migrations');" || true)
212+
213+ if [ -z "${catalog_present}" ] || [ "${catalog_present}" = "" ] || [ "${catalog_present}" = "NULL" ]; then
214+ echo "supabase_migrations.schema_migrations missing; running supabase db reset"
215+ FORCE_COLOR=1 npx dotenv-cli -e test/containers/.env -- bash -c 'npx supabase db reset --local --workdir suprabase --yes --debug'
216+ else
217+ echo "Catalog present: ${catalog_present}"
218+ fi
219+ BASH
220+ echo "::endgroup::"
221+
192222 echo "::group::Supabase migrations"
193223 npm run containers:supabase:db-push
194224 echo "::endgroup::"
You can’t perform that action at this time.
0 commit comments