Adamastor uses Supabase Postgres. Schema changes are version-controlled as SQL files in supabase/migrations/.
- Write a migration file in
supabase/migrations/namedYYYYMMDDHHMMSS_short_description.sql(e.g.20260524180000_add_event_submission_workflow.sql). Timestamps sort lexicographically; pick a value later than the most recent file. - Wrap in a transaction: start with
begin;, end withcommit;. If anything fails midway, the whole migration rolls back. - Apply manually by pasting the SQL into the Supabase dashboard's SQL editor and running it. The CLI's
supabase db pushis not used in this project today, and the Supabase MCPapply_migrationtool can't find the project from its dashboard listing. - Commit the file alongside the code change so peers and CI can see the schema delta.
Wrap DDL in if not exists / drop if exists so re-running the same migration is safe:
create table if not exists public.foo ( ... );
drop policy if exists "Public can read foo" on public.foo;
create policy "Public can read foo" on public.foo for select using (true);For constraints (which don't accept if not exists in Postgres 15), use a do $$ begin ... end $$ block:
do $$
begin
if not exists (select 1 from pg_constraint where conname = 'foo_status_check') then
alter table public.foo add constraint foo_status_check check (status in ('a', 'b'));
end if;
end $$;Every new table must:
alter table public.<name> enable row level security;- Ship at least one policy in the same migration.
If you intentionally want a public-readable table, write for select using (true) rather than leaving RLS off. Document the choice in a comment.
If you add a NOT NULL column to a populated table, you need either a default clause that satisfies existing rows, or a separate update step inside the same migration. See 20260524180000_add_event_submission_workflow.sql for the pattern (and why the where-clause reads as a no-op safety belt).
Whoever runs the migration in the Supabase dashboard reads the SQL once. Inline comments explaining why (not just what) save the next person from re-deriving the design.
supabase/config.toml ships a local stack config. To work against it: supabase start (CLI). Most contributors point straight at the shared Supabase project via NEXT_PUBLIC_SUPABASE_URL and don't run the local stack.
There's no automated rollback. Either:
- Write and run a reverse migration (
drop column ..., etc.) as a new dated file. - Or restore from a Supabase backup (project dashboard → Database → Backups).
Prefer forward fixes (new migration) over rollback when the change has already landed in shared environments.