ablevarghese/ios-claude-toolkit/atlas-database
Claude Code and agent skill by ablevarghese/ios-claude-toolkit
- community
Checking that the SKILL.md file is still in the repository.
Add a table, change the schema, database migration, Supabase schema. PostgreSQL/Supabase migration operations — creating, repairing, and pushing migrations, designing schemas, writing RLS policies, trigger functions. Trigger on: 'add a column', 'new database table', 'write a migration', 'fix migration history', 'RLS policy', 'enable row level security', 'trigger not working', or any hands-on schema change. For query optimization, indexing, and connection pooling, use supabase-postgres-best-practices instead.
Install
npx vskill@latest install ablevarghese/ios-claude-toolkit/atlas-databaseSKILL.md
The same SKILL.md was published earlier as ablevarghese/ios-claude-toolkit/atlas-database.
ATLAS - Database Migration & Schema
PostgreSQL/Supabase database skill covering migration creation and repair, schema design, Row Level Security policies, and trigger function development with proper column qualification.
Iron Law: "Never run a migration in production without testing it against a copy of production data first."
Project Discovery: Before executing, determine project-specific values (project name, scheme, bundle ID, target) from project configuration files (CLAUDE.md, project.yml, .xcodeproj, Package.swift). In particular, locate the Supabase project directory from the project structure (commonlybackend/supabase/,supabase/, orBackend/supabase/). This directory is referred to as{SUPABASE_DIR}throughout this skill.
Rationalizations (Do Not Skip)
| Rationalization | Why It's Wrong | Required Action | |
|---|---|---|---|
| "I'll just add the column directly in production" | Direct DDL changes bypass migration history, making environments impossible to reconcile. The next db push will fail or overwrite. | Always create a migration file, even for a single column addition. | |
| "This migration is simple enough to skip testing" | Simple migrations cause the worst outages because nobody expects them to fail. An ALTER COLUMN on a 10M row table locks the table for minutes. | Run against a copy of production data. Measure lock duration. | |
| "We can always rollback" | Not all migrations are reversible. Data type changes, column drops, and data backfills destroy data on rollback. | Write explicit rollback SQL. Test the rollback. Document what data is lost if rolled back. | |
| "RLS is too complex, we'll handle auth in the app" | Application-level auth is one bug away from exposing all data. RLS is the last line of defense — not the first. It catches the bugs your app layer misses. | Implement RLS policies for every table with user data. Test with both authenticated and anon roles. | |
| "Triggers are fine without NEW/OLD qualification" | Unqualified column references in triggers silently resolve to the wrong value or fail entirely. This is the #1 trigger bug in PostgreSQL. | Always use NEW.column_name or OLD.column_name. Never bare column_name. | |
| "I'll just use a text column for the status" | Text columns accept any value. Typos, casing differences, and invalid states propagate silently. Debugging "actve" vs "active" at 2am is not fun. | Use CHECK constraints, PostgreSQL ENUMs, or lookup tables with foreign keys. | |
| "We don't need indexes yet, the table is small" | Tables grow. By the time you notice the slow query, it's affecting users. Adding indexes to large tables locks them. | Add indexes at table creation time for columns used in WHERE, JOIN, and ORDER BY. | |
| "I'll store this as JSON, it's more flexible" | JSONB is untyped, unvalidated, and invisible to the schema. You lose constraint enforcement, foreign keys, and query planning. | Use JSONB only for genuinely unstructured data. If you query a field 3+ times, promote it to a column. |
Red Flags -- STOP
- ALTER COLUMN on a production table without testing lock duration --
ALTER TYPE,ALTER ... SET NOT NULL, andALTER ... SET DEFAULTcan lock large tables for minutes. Test against production-size data first. - UPDATE/DELETE without a WHERE clause -- This modifies or destroys every row. Always include WHERE. Always run SELECT with the same WHERE first to verify scope.
- Trigger function without NEW/OLD qualification on every column reference -- Bare column names cause silent resolution failures. Every. Single. Reference. Must. Be. Qualified.
- RLS policy with a correlated subquery per row -- This executes N subqueries for N rows. Use JOINs or
EXISTSinstead. If performance is unacceptable, consider a materialized security lookup table. - Migration that drops a column without a prior data migration -- Column drops are irreversible. First deploy code that stops reading the column. Then backfill data elsewhere. Then drop.
- Deploying migrations and application code simultaneously -- If the migration fails, the new app code talks to the old schema. Deploy migrations separately, verify, then deploy the app.
Behavioral Enforcement
Phase Gate: MIGRATION SAFETY
Cannot push migration to production until:
- [ ] Migration tested against copy of production data (not just empty schema)
- [ ] Rollback procedure documented and tested
- [ ] RLS policies tested with BOTH authenticated and service_role
- [ ] All triggers verified with proper NEW/OLD qualification
Hard Stop: Running untested migrations in production risks data loss. There is no undo for a bad migration that corrupts data. Test first. Always.
Phase Gate: SCHEMA CHANGE
Cannot create migration until:
- [ ] Existing schema reviewed (don't duplicate tables/columns that exist)
- [ ] Impact on existing RLS policies assessed
- [ ] Impact on existing triggers assessed
Fix Attempt Tracking
- Migration fails #1: Read the error. Fix the SQL.
- Migration fails #2: Check constraints, triggers, RLS. Something is blocking.
- Migration fails #3: STOP.
supabase db resetlocally, review the full migration chain. The issue is cumulative.
Self-Audit
- Did I test this migration on a copy before pushing to production?
- Can I rollback this migration if it breaks something?
- Did I verify RLS policies still work after the schema change?
- Are all trigger column references qualified with NEW/OLD?
Required Output Artifact
Every migration operation must produce:
- The migration SQL file with header comment (purpose, date, rollback procedure)
- Verification output from
supabase db reset(local) orsupabase db push --dry-run - RLS policy test results (authenticated role, anon role, service_role)
When NOT to Use This Skill
- Query optimization and performance tuning -- Use the
supabase-postgres-best-practicesskill. This skill creates schemas; that skill optimizes them. - Application-level data access patterns -- This skill handles database DDL and policies. For repository patterns, data access layers, and ORM configuration, work in the application codebase directly.
- One-off data analysis or reporting queries -- If you're exploring data (not changing schema), use the database client directly. Migrations are for schema changes, not ad-hoc queries.
- Supabase Edge Functions or API configuration -- Those are application-layer concerns, not database schema concerns.
Decision Framework
Standard Operating Procedures
SOP-1: Create Migration
Why each part matters:
- Schema changes without indexes = slow queries as data grows
- Missing RLS = data exposure vulnerability
- Missing grants = application cannot access the data
- Missing verification = silent failures discovered in production
SOP-2: Repair Migration History
Why repair is needed: Migration history is a linear sequence. When local and remote diverge (branch merges, manual changes, failed pushes), the history must be reconciled before any new migrations can be applied. Skipping repair leads to "migration already applied" errors or missed migrations.
SOP-3: Debug Trigger Issues
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/atlas-database/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/ablevarghese/ios-claude-toolkit/atlas-database)