Workflow·Databases

PocketBase Migrations & Schema Versioning

Schema migrations and versioning for PocketBase.

You say
Buy it · $99 Read it before you buy $99 Written by davila7 · unverified publisher
Context cost
2.3k tokensestimated from the bundle, loaded when it triggers
Bundle
1 file · 9.1 kBtext throughout, nothing executable
Licence
MITpaid listing
Last change
no release on file
Servers it uses
Noneruns standalone

What it does

Schema migrations and versioning for PocketBase. Use when creating migrations, managing schema versions, syncing collections between environments, using automigrate, or creating collections programmatically. Covers migrate commands, migration file format, snapshot imports, and the _migrations tracking table.

Installed, it changes the agent in these ways.

What this skill changes about the agent is not written down here yet. The listing was collected from its source, and the description is in its own SKILL.md.

Workflow

Runs a procedure end to end.

database
Filed under

Databases

The skill itself

This is the whole product. A skill is instructions the model reads, so there is nothing behind the listing you cannot see first — the front matter loads with every session, and the body below it loads when the skill triggers.

SKILL.md9.1 kB · 265 lines
--- name: "PocketBase Migrations" description: "Schema migrations and versioning for PocketBase. Use when creating migrations, managing schema versions, syncing collections between environments, using automigrate, or creating collections programmatically. Covers migrate commands, migration file format, snapshot imports, and the _migrations tracking table." ---
6# PocketBase Migrations & Schema Versioning
7
8## Overview
9
10PocketBase supports two approaches to schema management:
11
121. **Auto-migrate** (default in dev) — Dashboard changes auto-generate migration files in pb_migrations/
132. **Manual migrations** — write migration files by hand for full control
14
15## CLI Commands
16
17```bash
18# Create a new empty migration file
19./pocketbase migrate create "add_posts_collection"
20# Creates: pb_migrations/1234567890_add_posts_collection.js
21
22# Apply all pending migrations
23./pocketbase migrate up
24
25# Revert the last applied migration
26./pocketbase migrate down
27
28# Generate a full snapshot of all current collections
29./pocketbase migrate collections
30# Creates a migration file that recreates all collections from scratch
31
32# Sync migration history with actual DB state (mark all as applied)
33./pocketbase migrate history-sync
34```
35
36## Auto-migrate Mode
37
38Enabled by default. When you change collections in the Dashboard, PocketBase auto-generates migration files in pb_migrations/.
39
40```bash
41# Start with auto-migrate (default)
42./pocketbase serve
43
44# Disable auto-migrate (production)
45./pocketbase serve --automigrate=0
46```
47
48**Workflow**:
491. Develop with auto-migrate ON — use Dashboard to design schema
502. Migration files are auto-generated in pb_migrations/
513. Commit these files to git
524. Deploy: migrations run automatically on serve start
535. In production: use --automigrate=0 to prevent Dashboard changes from generating new migrations
54
55## Migration File Format
56
57```js
58// pb_migrations/1234567890_add_posts_collection.js
59
60migrate(
61 // UP — apply migration
62 function(app) {
63 var collection = new Collection({
64 name: "posts",
65 type: "base",
66 fields: [
67 { name: "title", type: "text", required: true },
68 { name: "body", type: "editor" },
69 { name: "author", type: "relation", collectionId: "USERS_COLLECTION_ID", cascadeDelete: false, maxSelect: 1, required: true },
70 { name: "status", type: "select", values: ["draft", "published", "archived"] },
71 { name: "published_at", type: "date" },
72 { name: "tags", type: "relation", collectionId: "TAGS_COLLECTION_ID", maxSelect: 0 }
73 ],
74 indexes: [
75 "CREATE INDEX idx_posts_author ON posts (author)",
76 "CREATE INDEX idx_posts_status ON posts (status)",
77 "CREATE UNIQUE INDEX idx_posts_title ON posts (title)"
78 ],
79 listRule: "", // WARNING: "" means public access — use a filter or null to restrict
80 viewRule: "", // WARNING: "" means public access — use a filter or null to restrict
81 createRule: "@request.auth.id != ''",
82 updateRule: "author = @request.auth.id",
83 deleteRule: "author = @request.auth.id"
84 })
85 app.save(collection)
86 },
87 // DOWN — revert migration
88 function(app) {
89 var collection = app.findCollectionByNameOrId("posts")
90 app.delete(collection)
91 }
92)
93```
94
95**Important**: the app inside migrations is a transactional instance. If any error occurs, the entire migration is rolled back.
96
97## Creating Collections Programmatically
98
99### Base collection
100
101```js
102var collection = new Collection({
103 name: "posts",
104 type: "base",
105 fields: [
106 { name: "title", type: "text", required: true, min: 3, max: 200 },
107 { name: "slug", type: "text", required: true, autogenerate: { pattern: "slugify(title)" } },
108 { name: "body", type: "editor" },
109 { name: "cover", type: "file", maxSelect: 1, maxSize: 5242880, mimeTypes: ["image/jpeg", "image/png", "image/webp"] },
110 { name: "views", type: "number", min: 0 },
111 { name: "metadata", type: "json", maxSize: 2000000 },
112 { name: "featured", type: "bool" },
113 { name: "published_at", type: "date" }
114 ]
115})
116app.save(collection)
117```
118
119### Auth collection
120
121```js
122var collection = new Collection({
123 name: "users",
124 type: "auth",
125 fields: [
126 { name: "name", type: "text", required: true },
127 { name: "avatar", type: "file", maxSelect: 1, maxSize: 5242880 },
128 { name: "role", type: "select", values: ["user", "editor", "admin"], required: true }
129 ],
130 passwordAuth: { enabled: true, identityFields: ["email", "username"] },
131 oauth2: { enabled: true },
132 otp: { enabled: false },
133 mfa: { enabled: false },
134 authToken: { duration: 604800 } // 7 days
135})
136app.save(collection)
137```
138
139### View collection
140
141```js
142var collection = new Collection({
143 name: "posts_stats",
144 type: "view",
145 viewQuery: "SELECT p.id, p.title, COUNT(c.id) as comments_count, p.views FROM posts p LEFT JOIN comments c ON c.post = p.id GROUP BY p.id",
146 listRule: "",
147 viewRule: ""
148})
149app.save(collection)
150```
151
152## Modifying Existing Collections
153
154```js
155migrate(function(app) {
156 var collection = app.findCollectionByNameOrId("posts")
157
158 // Add a new field
159 collection.fields.add({
160 name: "subtitle",
161 type: "text",
162 max: 500
163 })
164
165 // Remove a field
166 collection.fields.removeByName("old_field")
167
168 // Update API rules
169 collection.listRule = "@request.auth.id != ''"
170 collection.viewRule = ""
171
172 // Add index
173 collection.indexes.push("CREATE INDEX idx_posts_subtitle ON posts (subtitle)")
174
175 app.save(collection)
176}, function(app) {
177 var collection = app.findCollectionByNameOrId("posts")
178 collection.fields.removeByName("subtitle")
179 app.save(collection)
180})
181```
182
183## Raw SQL in Migrations
184
185```js
186migrate(function(app) {
187 app.db().newQuery("ALTER TABLE posts ADD COLUMN legacy_id TEXT DEFAULT ''").execute()
188 app.db().newQuery("UPDATE posts SET legacy_id = id WHERE legacy_id = ''").execute()
189}, function(app) {
190 app.db().newQuery("ALTER TABLE posts DROP COLUMN legacy_id").execute()
191})
192```
193
194**Warning**: raw SQL bypasses PocketBase's schema cache. Run migrate collections afterward to re-sync if needed.
195
196## Settings & Superuser in Migrations
197
198### Initialize app settings
199
200```js
201onBootstrap(function(e) {
202 var settings = e.app.settings()
203 settings.meta.appName = "My App"
204 settings.meta.appURL = "https://myapp.com"
205 settings.meta.senderName = "My App"
206 settings.meta.senderAddress = "noreply@myapp.com"
207 settings.smtp.enabled = true
208 settings.smtp.host = "smtp.example.com"
209 settings.smtp.port = 587
210 settings.smtp.username = $os.getenv("SMTP_USER")
211 settings.smtp.password = $os.getenv("SMTP_PASS")
212 e.app.save(settings)
213 return e.next()
214})
215```
216
217### Create superuser in migration
218
219```js
220migrate(function(app) {
221 var superusers = app.findCollectionByNameOrId("_superusers")
222 var record = new Record(superusers)
223 // IMPORTANT: always set PB_ADMIN_EMAIL and PB_ADMIN_PASSWORD env vars
224 var email = $os.getenv("PB_ADMIN_EMAIL")
225 var password = $os.getenv("PB_ADMIN_PASSWORD")
226 if (!email || !password) {
227 throw new Error("PB_ADMIN_EMAIL and PB_ADMIN_PASSWORD env vars are required")
228 }
229 record.set("email", email)
230 record.set("password", password)
231 app.save(record)
232})
233```
234
235## Snapshot Migrations
236
237./pocketbase migrate collections generates a complete snapshot — useful for:
238- Bootstrapping a new environment
239- Resetting migration history
240- Reviewing full schema in one file
241
242The generated file uses app.importCollections(collections) which supports two modes:
243- **Default (merge/extend)**: adds new collections and fields, updates existing ones, doesn't delete anything
244- **Delete missing**: app.importCollections(collections, true) — deletes collections/fields not in the snapshot
245
246## _migrations Table
247
248PocketBase tracks applied migrations in the internal _migrations table:
249- id — auto-generated
250- file — migration filename
251- applied — timestamp
252
253migrate history-sync marks all existing migration files as applied without running them — useful when importing an existing database.
254
255## Best Practices
256
2571. **Dev**: use auto-migrate + Dashboard for schema design, commit generated files
2582. **Staging/Prod**: deploy with --automigrate=0, migrations run on startup
2593. **Always write DOWN migrations** — reversibility saves you when things go wrong
2604. **One concern per migration** — don't mix unrelated schema changes
2615. **Test migrations**: apply on a copy of production data before deploying
2626. **Use migrate collections** periodically to snapshot current state for documentation
2637. **Never edit applied migrations** — create a new migration to fix issues
2648. **Seed data**: prefer a dedicated migration for one-time initial data; if using onBootstrap, make the seed logic idempotent (existence checks/upserts) because bootstrap runs on every app start
265
In the file
SKILL.md1,081 words
Files1
LicenceMIT
Why you can read it

Nothing in a skill executes. The client loads the text and the model follows it, so a skill can be audited the way a runbook is — by reading it.

What it costs in context

Skills are not billed by the call. They are paid for in context: every token the instructions occupy is a token your code, your diff and your conversation cannot use. Here is what this one takes and when it takes it.

≈90
always loaded
The name and description, so the model knows the skill exists and when to reach for it.
2,185
on trigger
The instruction body, read only when the skill fires.
1.1%
of a 200k window
Ten skills this size would take about 11% of the window before you open a file.
050k100k150k200k context window

2.3k tokens, estimated from the bundle at four bytes to the token, held for the rest of the session once it triggers. Middling. Fine to keep on in a project where you use it weekly, worth unloading in one where you never do.

Servers bill, skills cost

A server charges by the month. A skill charges once per session, in context, and then keeps charging it for as long as the session lives.

Before and after

The same question, put to the same model twice: once as it comes, and once with these instructions loaded.

No worked example has been published for this skill yet.

Adoption
Installsnone yet
Ratingno reviews yet

The procedure it runs

The procedure has not been published here. It is in the skill’s own SKILL.md, which its author has not sent to the marketplace yet.

Prose, not code

These steps are written for a model to follow, not executed by a runtime. It can still be told to skip one, and it will say so when it does.

Servers it uses

None. This skill calls no MCP servers at all.

Everything it needs is in the instructions, so it works in a project with nothing connected — the model reads the file and changes how it works with what it can already reach.

It writes no files and reaches no network. All it changes is how the model reasons and writes.

What it asks for
Writes filesno
Network accessno

Read from the allowed-tools line of this skill’s own SKILL.md. A skill grants no permissions of its own — it can only ask for tools your client already has.

What it will not do

Every skill is narrow, and the useful ones say where they stop. These are the jobs this one is the wrong tool for.

What this skill is not for has not been published here. Nothing is implied by that: it is a section the author has not filled in.

What is in the bundle

1 file, 9.1 kB on disk. A bundle is text throughout: the instructions the model reads, plus the templates it fills in.

  • SKILL.md9.1 kB
What is not in it

No dependencies and nothing executable: a skill is text the agent reads, so the bundle is 1 file you can review in full before installing. The MIT licence covers the templates and examples as well as the instructions.

Install

Installing copies the bundle into your project. Nothing runs at install time — the files sit on disk until the model reads them.

$99 once
PocketBase Migrations & Schema Versioning · MIT · davila7
one-time
Price$99 once
LicenceMIT — the author’s, unchanged by this purchase
Paid throughStripe, once, on the card you add at the checkout
Keeps workingfor good — the files are yours once they are on disk
Updatesevery update its author ships, delivered through this account

You can read the whole bundle before paying — the SKILL.md above is the product, not a preview of it. What the money buys is the delivery: the folder packaged and handed to your machine by key, every update its author ships, and our support if it does not do what this listing says. The terms of use are MIT, set by the author and unchanged by buying it here.

Payment runs through Stripe, on a page like this one rather than a redirect. Once there is an account it joins the same mcprush invoice as everything else you run, so there is never a second card to enter.

Which clients pick it up on their own

A skill is a folder of text. A client with a skills folder reads it without being told; everywhere else the same text works, it is just handed to the model rather than found.

Claude Code.claude/skills/
Claude Desktop
ChatGPT
Cursor.cursor/skills/
VS Code.github/skills/
Codex CLI.agents/skills/
Gemini CLI.gemini/skills/
Grok.grok/skills/
Zed.agents/skills/
Windsurf.windsurf/skills/
Agent SDK.claude/skills/
HTTP / API
This release
Versionnot versioned
Publishedno release date on file
Price$99
Referencedavila7/pocketbase-migrations-schema-versioning

Versions

Its author publishes no version number, so there is nothing here to pin to: what you install is the folder as it stands today. Instructions change more often than APIs do — a skill can be rewritten entirely without anything it depends on moving.

v
  • No earlier releases have been published to the marketplace.
Pinning

Nothing to pin to: this skill carries no version number of its own. What you install is what the folder holds on the day you install it.

Reviews

no reviews yet · no installs yet

Nobody has reviewed this skill yet. The rating is the mean of the reviews written here, so there is none until somebody writes the first.

Who can post

Only accounts that have had the skill installed for fourteen days, so a review is written after living with it rather than after reading it. Publishers may reply once.

Publisher
Servers0