database-migrations

database-migrations is a skill for Claude Code, Codex from ApexIQ/skillsmith. It costs 27 tokens per session (513 once invoked), scanned A, original, MIT.

Guidance for changing database structures safely, using SQLModel for Python data models and Alembic for versioned database changes.

In plain words
What is it for?
It is for designing tables, choosing nullable fields and indexes, defining relationships, and planning safe multi-step migrations with backups.
Why use it?
It helps prevent lost data, broken application code, and unsafe production changes when adding, changing, or removing database fields.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/apexiq/skillsmith/database_migrations
Any agent
npx skills add ApexIQ/skillsmith --skill database_migrations
Clone the repo
git clone --depth 1 https://github.com/ApexIQ/skillsmith

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for database-migrations

README.md
[![agentmods](https://agentmods.dev/badge/skills/apexiq/skillsmith/database_migrations.svg)](https://agentmods.dev/skills/apexiq/skillsmith/database_migrations)
Your own site
<a href="https://agentmods.dev/skills/apexiq/skillsmith/database_migrations"><img src="https://agentmods.dev/badge/skills/apexiq/skillsmith/database_migrations.svg" alt="Measured on agentmods" height="20"></a>
Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 513 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00027 $0.00513
Opus 5 $0.00014 $0.00257
Sonnet 5 $0.00005 $0.00103
Haiku 4.5 $0.00003 $0.00051

Measured 6d ago against content hash 210785bc8804, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

database-migrations scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agent/skills/database_migrations/SKILL.md · 65 lines

What it actually says

🗄️ Database & Migrations

Rule: Never modify production schema without a migration. Never run migrations without a backup.

1. Schema Design (SQLModel)

  • Nullable by Default: New columns should be Optional[T] = None to avoid breaking existing rows.
  • Indexes: Add indexes to columns used in WHERE clauses (index=True).
  • Foreign Keys: Always define relationships explicitly.
class Email(SQLModel, table=True):
    id: int | None = Field(default=None, primary_key=True)
    subject: str = Field(index=True)  # Indexed for search
    user_id: int = Field(foreign_key="user.id")  # FK defined
    archived_at: datetime | None = None  # Nullable for new column

2. Migration Strategy (Alembic)

Safe Migrations

Operation Safe? Notes
Add nullable column No data loss, backward compatible.
Add non-nullable column ⚠️ Needs default value OR multi-step migration.
Rename column Breaks existing queries. Use add/copy/drop.
Drop column ⚠️ Verify no code references it.

Multi-Step Migration (for risky changes)

  1. Deploy 1: Add new column (nullable).
  2. Backfill: Script to populate new column from old.
  3. Deploy 2: Make new column non-nullable, drop old column.

3. Running Migrations

# Generate migration
alembic revision --autogenerate -m "add archived_at column"

# Review the generated file!
# Then apply:
alembic upgrade head

Examples

  • Adding a feature flag column: Add nullable, deploy, backfill, make non-nullable.

Guidelines

  • Always backup before migrating production.
  • Test migrations on a copy of production data first.
  • Never use DROP in the same deploy as the code change.
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 65 lines · 27 tokens per session scan A 210785bc8804

Subscribe to this mod's changes

database-migrations is a skill published in the GitHub repository ApexIQ/skillsmith (5 stars, last pushed 5mo ago), licensed MIT. It adds 27 tokens to every session and 513 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

drizzle-orm

Use when modeling data or querying with Drizzle ORM in TypeScript — pgTable schema in .ts, type-safe select/insert/relational queries, drizzle-kit migrations. NOT Prisma Client or schema.prisma (that is prisma-orm), NOT ORM-agnostic migration strategy (that is db-migrations), NOT Postgres engine tuning or EXPLAIN…

ericrisco/rsc-harness · 96 tokens

postgresdb

Use when PostgreSQL engine behaviour decides the answer — schema and type design, index choice, reading EXPLAIN on a slow query, zero-downtime DDL and backfills, or ops (roles, RLS, pooling, vacuum, partitioning, PITR). PG16, ORM-agnostic. NOT portable query logic (that is sql), NOT a managed provider's platform…

ericrisco/rsc-harness · 91 tokens

database-migration-patterns

Manage database schema changes safely with migration tools, zero-downtime strategies, and rollback procedures. Covers Alembic, SQL migrations, data migrations, and testing strategies. Triggers on database migration, schema changes, or Alembic configuration requests.

organvm-iv-taxis/a-i--skills · 56 tokens

Database Patterns

Use this skill when designing schemas, writing queries, or shipping migrations—especially when correctness and safety matter more than clever SQL.

AmariahAK/atlarix-skills · 2 tokens

database-sql

Design database schemas, write efficient SQL queries, create migrations, and optimize database performance. Use when working with databases, writing queries, or designing data models.

asgarovf/locusai · 35 tokens

drizzle-orm

Drizzle ORM — TypeScript SQL ORM. Schema definition, queries, migrations, transactions, RQB, extensions.

pledgeandgrow/pledge-skills · 28 tokens