AGENT SKILL

pocketbase-migrations

Schema migrations in PocketBase — generating, reviewing, and applying them safely across environments.

License 许可
MIT
所属仓库
TanNhatCMS/jarvis
最近更新
2026-11-07
Stars
★ 0
Forks
1

01 前言 Front Matter

name
pocketbase-migrations
category
pocketbase
description
Schema migrations in PocketBase — generating, reviewing, and applying them safely across environments.

03 SKILL.md 正文

Overview

PocketBase turns dashboard schema changes into Go/JavaScript migration files that apply in order — the mechanism that keeps dev, staging, and production schemas identical. This skill covers the migration workflow: generating migrations from changes, reviewing them, handling data migrations, and applying them safely.

When to use

  • Evolving collections (new fields, changed types, new indexes)
  • Syncing schema changes across environments
  • Writing data migrations (backfills, transformations)
  • Reviewing auto-generated migrations before applying
  • Recovering from failed or partial migrations

Core concepts

Migrations are the source of truth. The dashboard is a convenient editor, but the migration files in version control define the schema. Workflow: change in dev dashboard → export/generate migration → commit → apply to staging/prod via the migrate command. Dashboard edits in production without migrations are how environments diverge.

Auto-generated, human-reviewed. PocketBase can diff the current schema against the migration history and generate the migration code. Always read generated migrations before applying — especially destructive operations (dropped collections/fields, type changes that truncate data). The generator is faithful; it's your job to be careful.

Ordering and idempotency. Migrations apply sequentially, tracked in the _migrations table. Never edit an applied migration — write a new one. Keep migrations small and focused so failures are diagnosable and recovery is obvious.

Data migrations need batches. Backfilling a new field across millions of records in one migration can lock or OOM. Write data migrations that process in batches with progress logging, and test them against a production-sized snapshot before running for real.

Superuser-only operations. Applying migrations requires superuser/admin context — never expose migration endpoints to regular API traffic. In production, migrations run as part of the deploy process (or a controlled manual step), not on app boot by every instance.

Practical workflow

  1. Make schema changes in dev via the dashboard; generate the migration and inspect the code — confirm it does exactly what you intended.
  2. Commit the migration with the code that depends on it; the PR review covers both schema and usage together.
  3. Test the migration forward (and rollback if supported) against a staging database seeded with realistic data, including edge cases the change affects (nulls, type coercions, unique constraints on existing duplicates).
  4. For data migrations: write batch logic, dry-run on a snapshot, then run against production with monitoring; keep it resumable.
  5. Apply in deploy order: backup → apply migrations → deploy new code (expand-contract: migrations must be compatible with both old and new code during the transition).
  6. Verify post-apply: schema matches expectations, app health checks pass, and the migration history table shows the new entries.

Common pitfalls

  • Editing applied migrations — breaks the history chain for every other environment; always add a new migration.
  • Destructive changes without backup — dropping a field/collection is instant and irreversible; backup first, and prefer soft-deprecate (stop writing, then drop later) for critical data.
  • Type changes that silently coerce — text → number on dirty data loses or corrupts values; clean/validate data before the type migration.
  • Migration/code ordering bugs — deploying code that needs a column before the migration runs (or vice versa); sequence deploys explicitly.
  • Untested migrations on production-sized data — works on 100 dev rows, times out or locks on 10M prod rows; test at scale.
  • Dashboard drift — someone "quickly fixes" prod in the dashboard; institute a rule: all schema changes go through migrations, no exceptions.

04 同仓库更多 Skills

TanNhatCMS
TanNhatCMS/jarvis

web-scrape

Turn web pages into LLM-ready markdown via the Firecrawl API (renders JS, anti-bot handling). Use when browser_open/fetch fails on JS-heavy pages, or when you need clean markdown/structured extraction from a site. Requires FIRECRAWL_API_KEY.

★ 0
TanNhatCMS
TanNhatCMS/jarvis

design-taste-frontend

tasteskill v2, the anti-slop frontend skill. Art direction for websites, distilled from a study of 247 curated gallery sites (One Page Love, Awwwards Sites of the Day). Deals researched directions (idea, composition, type, palette, photographs, section blueprints) from a library, enforces a strict no-slop house style with a real-browser inspector, and runs a look-and-fix loop on screenshots. Use this whenever you build, design, redesign, restyle, polish or review a landing page, marketing site, portfolio, product page, one-pager, hero or any public-facing web page, in any stack (HTML/CSS, React, Next.js, Vue, Svelte, Astro, Tailwind) — also when the user says a page looks generic, templated, "AI-made", sloppy, or asks to make it look designed, premium, award-level or less like every other site. Not for dashboards or app screens.

★ 0
TanNhatCMS
TanNhatCMS/jarvis

test-driven-development

Use when implementing any feature or bugfix, before writing implementation code

★ 0
TanNhatCMS
TanNhatCMS/jarvis

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes

★ 0
TanNhatCMS
TanNhatCMS/jarvis

requesting-code-review

Use when completing tasks, implementing major features, or before merging to verify work meets requirements

★ 0
TanNhatCMS
TanNhatCMS/jarvis

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).

★ 0