Back to skills
SKILL.md
Database Migration Audit
ASecurityTitle: Database Migration Audit Keywords: database-audit, migrations, sqlite, supabase, postgres, sql-audit, indexing-check, data-integrity, rollback, dreambase Agents: database-administrator, backend, infrastructure When to use: When proposing or executing database schema migrations, SQLite store updates (`sqlite-store.ts`), Supabase hosted Postgres migrations (`supabase/migrations/`), or indexing adjustments. Version: 1.1.0 Last updated: 2026-12-05 Audit SQLite (`packages/lobby-server/src/s...
- 4 stars
- 0 votes
- 0 copies
- 2 views
- Added November 13, 2026
Works with
Security analysis
100/100npx -y skills add ronnikc/agent-os-protocol --skill database-migration-audit --agent claude-codeAre you the author of Database Migration Audit?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ronnikc-database-migration-audit)Title: Database Migration Audit
Keywords: database-audit, migrations, sqlite, supabase, postgres, sql-audit, indexing-check, data-integrity, rollback, dreambase
Agents: database-administrator, backend, infrastructure
When to use: When proposing or executing database schema migrations, SQLite store updates (`sqlite-store.ts`), Supabase hosted Postgres migrations (`supabase/migrations/`), or indexing adjustments.
Version: 1.1.0
Last updated: 2026-12-05
Audit SQLite (`packages/lobby-server/src/sqlite-store.ts`), Supabase hosted Postgres (`supabase/migrations/`), and general SQL/ORM schema migrations, indexes, query patterns, and rollback procedures to guarantee data integrity, zero secret leakage, and safe upgrades.
---
## Workflow
### Step 1 — Review migration script & transaction safety
Parse the proposed migration (`sqlite-store.ts` schema DDL, `supabase/migrations/*.sql`, or ORM migration). Verify:
- Forward (`up`) and rollback (`down`) or forward-compatible recovery steps are explicitly documented and safe to replay.
- DDL/DML runs inside transactions where supported so partial failures cannot corrupt state.
- For Supabase scaffolds (`scaffold-supabase`), confirm zero service keys or DB passwords are committed into `supabase/` or workflow files.
### Step 2 — Verify primary keys, indexes, and RLS / scoping
- Assert every table has a primary key, explicit foreign keys or unique constraints, and indexes covering `lobby_id`, lookup keys, and `WHERE`/`JOIN` filters.
- For Supabase hosted Postgres tables exposed to client apps or `dreambase.io` analytics views, verify Row Level Security (RLS) policies and least-privilege grants.
### Step 3 — Assess data safety & backward compatibility
- Flag destructive statements (`DROP TABLE`, `DROP COLUMN`, destructive `ALTER TYPE`) lacking an expand-and-contract migration (add → backfill → switch → drop).
- Require explicit defaults on new `NOT NULL` columns so existing rows migrate cleanly.
### Step 4 — Verify store persistence & report
Run relevant persistence verification (`npm run verify-lobby`, `npm run verify-hosted`) and compile index gaps, rollback risks, and data-safety findings.
---
## Input Schema
```yaml
input:
migration_file_path:
type: string
required: true
description: "Path to the SQLite store file or Supabase/SQL migration script to audit"
database_type:
type: string
enum: [sqlite, supabase_postgres, postgres, mysql]
required: true
description: "Target database engine"
```
## Output Schema
```yaml
output:
migration_verdict:
type: object
properties:
status: { type: string, enum: [Approved, Blocked] }
warnings_count: { type: integer }
checks:
type: array
items:
type: object
properties:
rule_name: { type: string }
outcome: { type: string, enum: [Passed, Failed, Warning] }
details: { type: string }
```
## Quality Gate
- Migration is idempotent or guarded with explicit schema version checks (`IF NOT EXISTS` / migration table).
- Indexes exist for `lobby_id`, foreign keys, and hot query filters.
- New `NOT NULL` columns declare explicit defaults.
- Supabase migrations enforce RLS and contain zero credentials or service keys.
- `npm run verify-lobby` passes cleanly for SQLite store changes.
## Chain Metadata
```yaml
chain_metadata:
skill_slug: "database-migration-audit"
stage: "S1"
suggested_next:
- slug: "hosted-app-integrations"
stage: "S1"
reason: "Verify Supabase owner-connected credential sealing and scaffold idempotency"
- slug: "verification-gate"
stage: "S3"
reason: "Verify fresh build and test evidence before committing schema changes"
```
## Error Handling
- Empty or syntactically invalid migration file → block approval and report parse error.
- Unapproved destructive `DROP TABLE` / `DROP COLUMN` without expand-and-contract plan → block migration.
- Plaintext Supabase service key or DB URL with embedded password found in migration/scaffold → fail immediately and remove before commit.
Attribution
Related skills
View all in ai-agents →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.