set -e
for v in SUPABASE_URL SUPABASE_PROJECT_REF SUPABASE_ANON_KEY SUPABASE_SERVICE_ROLE_KEY SUPABASE_DB_URL SUPABASE_DB_PASSWORD; do if [ -n "${!v:-}" ]; then echo "$v=set"; else echo "$v=missing"; fi; done
command -v psql || trueSUPABASE_URL=set SUPABASE_PROJECT_REF=set SUPABASE_ANON_KEY=set SUPABASE_SERVICE_ROLE_KEY=set SUPABASE_DB_URL=set SUPABASE_DB_PASSWORD=set /usr/bin/psql
set -e psql "$SUPABASE_DB_URL" -v ON_ERROR_STOP=1 -Atc "select tablename from pg_catalog.pg_tables where schemaname='public' order by 1;"
set -e
psql "$SUPABASE_DB_URL" -v ON_ERROR_STOP=1 <<'SQL'
BEGIN;
CREATE TABLE public.authors (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
name text NOT NULL,
email text NOT NULL UNIQUE
);
CREATE TABLE public.courses (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
author_id uuid NOT NULL REFERENCES public.authors(id),
title text NOT NULL,
price_cents integer NOT NULL CHECK (price_cents >= 0),
published boolean NOT NULL DEFAULT false,
created_at timestamptz NOT NULL DEFAULT now()
);
CREATE TABLE public.enrollments (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
course_id uuid NOT NULL REFERENCES public.courses(id) ON DELETE CASCADE,
student_email text NOT NULL,
enrolled_at timestamptz NOT NULL DEFAULT now(),
UNIQUE (course_id, student_email)
);
CREATE INDEX courses_author_id_idx ON public.courses (author_id);
CREATE INDEX enrollments_student_email_idx ON public.enrollments (student_email);
-- Ensure PostgREST roles can discover and read the resources. RLS keeps anonymous
-- requests empty unless policies are added later by the application.
GRANT USAGE ON SCHEMA public TO anon, authenticated, service_role;
GRANT SELECT ON public.authors, public.courses, public.enrollments TO anon, authenticated;
GRANT ALL ON public.authors, public.courses, public.enrollments TO service_role;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO service_role;
ALTER TABLE public.authors ENABLE ROW LEVEL SECURITY;
ALTER TABLE public.courses ENABLE ROW LEVEL SECURITY;
ALTER TABLE public.enrollments ENABLE ROW LEVEL SECURITY;
NOTIFY pgrst, 'reload schema';
COMMIT;
SQL
# Poll the REST endpoint briefly for PostgREST's schema reload.
code=""
body=""
for i in $(seq 1 12); do
tmp=$(mktemp)
code=$(curl -sS -o "$tmp" -w '%{http_code}' \
-H "apikey: $SUPABASE_ANON_KEY" \
"$SUPABASE_URL/rest/v1/courses?select=*&limit=1")
body=$(cat "$tmp"); rm -f "$tmp"
if [ "$code" = "200" ]; then break; fi
sleep 1
done
printf 'REST status: %s\nREST body: %s\n' "$code" "$body"
test "$code" = "200"BEGIN CREATE TABLE CREATE TABLE CREATE TABLE CREATE INDEX CREATE INDEX GRANT GRANT GRANT GRANT ALTER TABLE ALTER TABLE ALTER TABLE NOTIFY COMMIT REST status: 200 REST body: []
set -e psql "$SUPABASE_DB_URL" -v ON_ERROR_STOP=1 -P pager=off -c " SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_type='BASE TABLE' ORDER BY table_name; SELECT indexname, indexdef FROM pg_indexes WHERE schemaname='public' ORDER BY tablename,indexname; "
table_name
-------------
authors
courses
enrollments
(3 rows)
indexname | indexdef
-----------------------------------------+--------------------------------------------------------------------------------------------------------------------------
authors_email_key | CREATE UNIQUE INDEX authors_email_key ON public.authors USING btree (email)
authors_pkey | CREATE UNIQUE INDEX authors_pkey ON public.authors USING btree (id)
courses_author_id_idx | CREATE INDEX courses_author_id_idx ON public.courses USING btree (author_id)
courses_pkey | CREATE UNIQUE INDEX courses_pkey ON public.courses USING btree (id)
enrollments_course_id_student_email_key | CREATE UNIQUE INDEX enrollments_course_id_student_email_key ON public.enrollments USING btree (course_id, student_email)
enrollments_pkey | CREATE UNIQUE INDEX enrollments_pkey ON public.enrollments USING btree (id)
enrollments_student_email_idx | CREATE INDEX enrollments_student_email_idx ON public.enrollments USING btree (student_email)
(7 rows)
A shell script executed against the live project and asserted on the state the agent left behind. No model judged another model.
Raw transcript · Task definition and verifier · Every attempt