← Back to list

create-collection
by levino
⭐ 1🍴 0📅 Jan 13, 2026
SKILL.md
name: create-collection description: Use this skill when you need to alter the PocketBase database schema - creating, updating, or deleting collections. Never write migration SQL by hand. allowed-tools: Read, Write, Bash
PocketBase Collection Management
Use this skill whenever you need to modify the database schema (create/update/delete collections).
Why This Approach
PocketBase automatically generates migration files when collections are created/modified via the SDK. This ensures:
- Correct internal IDs
- Proper migration format
- Automatic rollback functions
- No manual SQL errors
Instructions
1. Get the PocketBase URL
Find the container IP:
docker network inspect shipyard-pocketbase-template_default --format '{{range .Containers}}{{.IPv4Address}}{{end}}'
2. Write a Temporary Script
Create a temp JS file (e.g., temp-collection.js):
import PocketBase from 'pocketbase'
const pb = new PocketBase('http://<CONTAINER_IP>:8090')
await pb.collection('_superusers').authWithPassword('admin@test.local', 'testtest123')
// CREATE a collection
await pb.collections.create({
name: 'my_collection',
type: 'base', // or 'auth' for user collections
fields: [
{ name: 'title', type: 'text', required: true },
{ name: 'completed', type: 'bool' },
{ name: 'user_id', type: 'text', required: true },
],
listRule: '@request.auth.id != ""',
viewRule: '@request.auth.id != ""',
createRule: '@request.auth.id != ""',
updateRule: 'user_id = @request.auth.id',
deleteRule: 'user_id = @request.auth.id',
})
// UPDATE a collection
// const collection = await pb.collections.getOne('my_collection')
// await pb.collections.update(collection.id, { name: 'new_name' })
// DELETE a collection
// await pb.collections.delete('my_collection')
console.log('Done!')
3. Run the Script
node temp-collection.js
4. Verify Migration Was Created
ls -la pocketbase/pb_migrations/
You should see a new .js file with the timestamp and collection name.
5. Delete the Temp Script
rm temp-collection.js
Field Types
Common field types for pb.collections.create():
text- String fieldbool- Booleannumber- Numericemail- Email validationurl- URL validationdate- Date/datetimeselect- Enum (addvalues: ['a', 'b'])relation- Foreign key (addcollectionId: 'xxx')file- File uploadjson- JSON data
Rules
Access rules use PocketBase filter syntax:
null- Superusers only''(empty string) - Anyone'@request.auth.id != ""'- Authenticated users'user_id = @request.auth.id'- Owner only
Score
Total Score
50/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon