Create a new Supabase migration file with the correct next sequence number for today, avoiding timestamp collisions when multiple migrations are written on the same day.
Arguments: <name> (required) — a short snake_case description of what the migration does, e.g. add_quest_tags or drop_faction_color.
Migration files use the format YYYYMMDDNNNNNN_name.sql where NNNNNN is a 6-digit sequence padded to 6 digits. When multiple migrations are created on the same day, collisions happen if the sequence isn't incremented.
This skill:
YYYYMMDD formatsupabase/migrations/ for files matching today's date prefix000001)supabase/migrations/<timestamp>_<name>.sql with a standard templateCheck both local files and origin/main to avoid branch divergence collisions:
today=$(date +%Y%m%d)
# Local sequences for today
local_max=$(ls supabase/migrations/ | grep "^${today}" | sed "s/^${today}//" | cut -c1-6 | sort -n | tail -1)
# origin/main sequences for today (catches migrations merged to main while on a branch)
main_max=$(git ls-tree -r origin/main --name-only -- supabase/migrations/ 2>/dev/null | grep "^supabase/migrations/${today}" | sed "s|supabase/migrations/${today}||" | cut -c1-6 | sort -n | tail -1)
# Take the higher of the two
echo -e "${local_max}\n${main_max}" | sort -n | tail -1
If no files exist for today in either location, the sequence starts at 000001.
If the highest is e.g. 000003, use 000004.
<YYYYMMDD><NNNNNN>_<name>.sql
Example: if today is 2026-04-11, 3 migrations already exist for today, and name is add_quest_tags:
→ 20260411000004_add_quest_tags.sql
Create the file at supabase/migrations/<filename> with this content:
-- Migration: <name>
-- <one-line description of what this migration does>
Leave the body empty after the header comment — the user will fill in the SQL.
Tell the user the exact filename that was created so they can navigate to it and start writing.
Do NOT run supabase db push — that's the user's job after they've written the SQL.