create-collection

PocketBase Collection Management

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "create-collection" with this command: npx skills add levino/shipyard-pocketbase-app-template/levino-shipyard-pocketbase-app-template-create-collection

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}}'

  1. 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!')

  1. Run the Script

node temp-collection.js

  1. Verify Migration Was Created

ls -la pocketbase/pb_migrations/

You should see a new .js file with the timestamp and collection name.

  1. Delete the Temp Script

rm temp-collection.js

Field Types

Common field types for pb.collections.create() :

  • text

  • String field

  • bool

  • Boolean

  • number

  • Numeric

  • email

  • Email validation

  • url

  • URL validation

  • date

  • Date/datetime

  • select

  • Enum (add values: ['a', 'b'] )

  • relation

  • Foreign key (add collectionId: 'xxx' )

  • file

  • File upload

  • json

  • 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

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

image-gen

Generate AI images from text prompts. Triggers on: "生成图片", "画一张", "AI图", "generate image", "配图", "create picture", "draw", "visualize", "generate an image".

Archived SourceRecently Updated
General

explainer

Create explainer videos with narration and AI-generated visuals. Triggers on: "解说视频", "explainer video", "explain this as a video", "tutorial video", "introduce X (video)", "解释一下XX(视频形式)".

Archived SourceRecently Updated
General

asr

Transcribe audio files to text using local speech recognition. Triggers on: "转录", "transcribe", "语音转文字", "ASR", "识别音频", "把这段音频转成文字".

Archived SourceRecently Updated