AGENT SKILL

review-database-migrations-in-pr

Use when a PR ships a schema change alongside code. Verifies the migration is backward-compatible with the running app and will not lock a large table.

License 许可
MIT
最近更新
2026-11-15
Stars
★ 81
Forks
17

01 前言 Front Matter

name
review-database-migrations-in-pr
description
Use when a PR ships a schema change alongside code. Verifies the migration is backward-compatible with the running app and will not lock a large table.

02 资源文件 3

03 SKILL.md 正文

Review database migrations in a PR

A migration that drops a column the old deploy still reads takes the site down for the length of a rollout. Review the migration for compatibility with both the old and new code, and for the lock it takes on a live table.

Procedure

  1. Locate the migration and read it as a sequence of DDL, not as an afterthought: gh pr diff 482 -- '*migrations*' or git diff origin/main...HEAD -- '**/migrations/**'.
  2. Require the expand/contract pattern for any rename or type change:
    • expand: add the new nullable column, backfill in batches, make the app write both,
    • contract: after the old code is gone, drop the old column in a later release.
  3. Reject a destructive change in the same PR as the code that stops using the field — those must be separate deploys.
  4. Check the lock each statement takes. On Postgres, ALTER TABLE ... ADD COLUMN ... DEFAULT x is fast since 11, but SET NOT NULL and ALTER COLUMN TYPE take an ACCESS EXCLUSIVE lock and rewrite the table; on a table over a few million rows that is a production stall.
  5. For indexes, require CREATE INDEX CONCURRENTLY on Postgres (outside a transaction) so writers are not blocked.
  6. Confirm the backfill is batched with a limit and a sleep, not a single UPDATE over the whole table.
  7. Verify the down migration exists and actually reverses the change, or document why forward-only is intended.

Pitfalls

  • Adding a NOT NULL column with no default to a populated table, which fails outright.
  • A migration that runs inside the same transaction as the index build, so CONCURRENTLY is rejected.
  • Renaming a column in place, breaking the previous app version mid-rollout.
  • A backfill that runs unbounded and holds row locks for minutes under load.

Verification

gh pr diff 482 -- '**/migrations/**'
# Dry-run against a production-sized copy:
alembic upgrade head --sql | grep -iE 'ACCESS EXCLUSIVE|NOT NULL|CONCURRENTLY'

Report the DDL statements, the lock level each takes, and whether the change is expand-only or contains a contract step. A contract step bundled with the consuming code is blocking.

Worked example

A PR renames users.name to users.full_name and updates the query in the same commit. Mid-rollout the old pods still read name, which no longer exists, and return 500s. The expand/contract fix: release 1 adds full_name nullable, backfills in batches of 1,000, and writes both columns; release 2 switches reads to full_name; release 3 drops name.

04 同仓库更多 Skills

jiayaoqijia
jiayaoqijia/cryptoskill

troves

Deposit and withdraw from Troves DeFi yield vault strategies on Starknet. View available strategies, check positions, and manage vault deposits. Use this skill when the user mentions Troves, vault, yield vault, DeFi vault, strategy, yield farming, vault deposit, vault withdraw, earning yield through vaults, passive yield strategies, or wants to deposit into or withdraw from a yield strategy — even if they don't say "Troves" explicitly.

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

trade

Swap tokens on Starknet via Fibrous DEX aggregator. Supports per-provider selection (avnu, ekubo, or auto to race all). Use this skill when the user wants to swap, exchange, trade, convert, buy, or sell one token for another on Starknet. Also use when the user asks about token prices, exchange rates, DEX routing, best swap route, or wants to check how much they would receive for a given amount — even if they don't explicitly say "swap".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

staking

Stake, unstake, claim, and compound rewards for STRK, WBTC, tBTC, SolvBTC, and LBTC on Starknet. View validators, pools, and staking positions. Use this skill when the user mentions staking, delegating, validators, staking pools, rewards, compounding, unstaking, earning yield, passive income on crypto, or wants to earn on their STRK or BTC tokens — even if they don't say "stake" explicitly.

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

send

Send STRK, ETH, or any ERC-20 token to a Starknet address. Supports simulation (dry-run) before execution. Use this skill when the user wants to send, transfer, pay, tip, or move tokens to another wallet address on Starknet. Also trigger when the user mentions sending funds to someone, making a payment, transferring assets, or moving crypto to a specific address — even if they just say "pay 10 STRK to 0x...".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

portfolio

View a comprehensive DeFi portfolio dashboard and optimize portfolio allocation via automated rebalancing. Use this skill when the user wants an overview, summary, dashboard, total value, net worth, portfolio rebalancing, target allocation, or wants to see all their DeFi positions across Starknet at once. Also trigger when the user asks "what do I have", "show me everything", "how much am I worth", "my positions", "my investments", "rebalance my portfolio", "I want 50% ETH", "optimize my holdings", or any request for a holistic view of their Starknet holdings — even if they don't explicitly say "portfolio".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

multi-swap

Execute multiple token swaps in a single Starknet transaction via Fibrous (default). Supports per-provider selection (avnu, ekubo, or auto to race all). Supports 2-3 swap pairs bundled into one multicall. Use this skill when the user wants to swap multiple token pairs at once, do batch swaps, execute several trades simultaneously, perform parallel swaps, or do bulk trading in one transaction. Also trigger when the user mentions "two swaps", "three swaps", "swap X and Y at the same time", or wants to convert multiple tokens in a single call.

★ 81