agentleFS
suxrobGMsuxrobGM/jobpilot/.claude/skills/db-migrate/SKILL.md

db-migrate

Skill113 starsChanged 9 days agoMITView on GitHub

Create and apply a Prisma migration safely against the remote (tunneled) PostgreSQL. Use for schema changes - "create a migration", "apply migrations", "add a column/table".

19 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use react-query-best-practices, you-might-not-need-a-callback and 6 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • bibektimilsina00Skill

    react-query-best-practices

    Audit and fix React Query usage in apps/web — enforce query key factories, signal forwarding, staleTime, and proper mutation patterns. Use when reviewing or fixing server-state code.

    Also in 3 projects that use this

  • bibektimilsina00Skill

    you-might-not-need-a-callback

    Analyze and fix useCallback anti-patterns in your code

    Also in 3 projects that use this

  • MicrosoftSkill

    cleanup

    Also in 3 projects that use this

  • AWSSkill

    ship

    Finalize dev work on an issue branch — update docs, push, and open a PR.

    Also in 7 projects that use this

  • VercelSkill

    deploy

    Deploy applications to Vercel. Use when the user says "deploy", "deploy to Vercel", "push to production", "deploy my app", or "go live".

    Also in 4 projects that use this

  • +3 more from bibektimilsina00

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 14 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Ask the user before touching production.

    line 27
  2. Very specific:

    Never run db:reset without explicit user confirmation - it wipes the database it points at.

    line 31

“Common” is measured: kept by at least 6 in 10 of the 14 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

DB migrate

The tunneled database (bun run db:tunnel, localhost:5433) is production. prisma migrate dev can demand a reset there, which wipes it, so never run it. All commands are bun --cwd=apps/api run ….

  1. Edit the schema - split by domain under apps/api/prisma/schema/*.prisma.
  2. Restore a throwaway copy: pg_dump prod through the tunnel, restore it into a local PostgreSQL on another port (e.g. 5434), and point DATABASE_URL at it for every step below until step 6. A local PostgreSQL and the tunnel both default to 5433 - check docker ps first.
  3. db:diff prints the SQL from the database to the schema (read-only). Save it as apps/api/prisma/migrations/<yyyymmddhhmmss>_<name>/migration.sql and edit it: Prisma turns renames into drop + add - hand-edit to ALTER ... RENAME when data must survive. Data fixes that need TS logic go in a one-off apps/api/scripts/<name>.ts with a --dry-run report. migrate deploy applies every pending migration at once, so a script can't run between two of them. When the migration needs the script's output, run the script first against the old schema, have it fill a staging table the migration joins on, and make the migration RAISE EXCEPTION before any change if rows are left unmapped (20261026070000_board_ids in git history). Partial unique indexes aren't in the Prisma schema; db:diff won't emit them, so write them by hand.
  4. db:migrate:apply against the copy, run the data script, spot-check counts and samples, and run the app against the copy. Then db:generate.
  5. Ask the user before touching production.
  6. Production: fresh pg_dump backup, db:migrate:apply through the tunnel, the data script, then deploy the matching images back to back. Never leave code that accepts both shapes.

Never run db:reset without explicit user confirmation - it wipes the database it points at.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.