{"id":48931,"library":"pocketbase-zod-schema","title":"pocketbase-zod-schema","description":"PocketBase migration generator using Zod schemas for type-safe database migrations. Current stable version is 0.7.1, released in early 2025. Release cadence is irregular; check GitHub for updates. Key differentiators: integrates Zod for schema validation, generates both migration files and TypeScript types with full PocketBase client support. Alternative to manual migration scripts or other migration tools.","status":"active","version":"0.7.1","language":"javascript","source_language":"en","source_url":"https://github.com/dastron/pocketbase-zod-schema","tags":["javascript","pocketbase","zod","migration","database","typescript","schema","sqlite","orm"],"install":[{"cmd":"npm install pocketbase-zod-schema","lang":"bash","label":"npm"},{"cmd":"yarn add pocketbase-zod-schema","lang":"bash","label":"yarn"},{"cmd":"pnpm add pocketbase-zod-schema","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for defining schema using Zod primitives","package":"zod","optional":false}],"imports":[{"note":"Must import from subpath 'pocketbase-zod-schema/schema', not the main package.","wrong":"import { defineCollection } from 'pocketbase-zod-schema'","symbol":"defineCollection","correct":"import { defineCollection } from 'pocketbase-zod-schema/schema'"},{"note":"Field types are exported from the same subpath. TypeScript typing relies on these.","wrong":"import { TextField } from 'pocketbase-zod-schema'","symbol":"TextField, BoolField, etc.","correct":"import { TextField, BoolField } from 'pocketbase-zod-schema/schema'"},{"note":"This type is generated by CLI; not part of the package itself. Common mistake: trying to import from package.","wrong":"import { TypedPocketBase } from 'pocketbase-zod-schema'","symbol":"TypedPocketBase","correct":"import { TypedPocketBase } from './pocketbase-types'; // generated file"}],"quickstart":{"code":"// Create src/schema/post.ts\nimport { z } from \"zod\";\nimport { defineCollection, TextField, EditorField, BoolField, RelationField } from \"pocketbase-zod-schema/schema\";\n\nexport const PostSchema = z.object({\n  title: TextField({ min: 1, max: 200 }),\n  content: EditorField(),\n  published: BoolField(),\n  author: RelationField({ collection: \"users\" }),\n});\n\nexport const PostCollection = defineCollection({\n  collectionName: \"posts\",\n  schema: PostSchema,\n  permissions: {\n    listRule: '@request.auth.id != \"\"',\n    viewRule: \"\",\n    createRule: '@request.auth.id != \"\"',\n    updateRule: \"author = @request.auth.id\",\n    deleteRule: \"author = @request.auth.id\",\n  },\n});\n\n// Then run: npx pocketbase-migrate generate\n// and: npx pocketbase-migrate generate-types","lang":"typescript","description":"Defines a PocketBase collection 'posts' using Zod schema with relations. Run commands to generate migrations and TypeScript types."},"warnings":[{"fix":"Upgrade Node.js to v20 or later.","message":"Requires Node.js >=20.0.0. Older versions will fail at runtime.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use: const pb = new PocketBase('url') as TypedPocketBase;","message":"Generate-types creates a TypedPocketBase interface. You must cast PocketBase instance manually.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Import from 'pocketbase-zod-schema/schema' specifically.","message":"Field types (TextField, BoolField, etc.) must be imported from 'pocketbase-zod-schema/schema', not the main package.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Run 'npx pocketbase-migrate generate-types' first.","message":"Generated types file (e.g., pocketbase-types.ts) is not part of the package; it must be generated with CLI.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.7.1':21 '2025':25 'altern':53 'cadenc':27 'check':30 'client':51 'current':17 'databas':15,66 'differenti':35 'earli':24 'file':44 'full':49 'generat':7,41 'github':31 'integr':36 'irregular':29 'javascript':62 'key':34 'manual':55 'migrat':6,16,43,56,60,65 'orm':70 'pocketbas':2,5,50,63 'pocketbase-zod-schema':1 'releas':22,26 'safe':14 'schema':4,10,39,68 'script':57 'sqlite':69 'stabl':18 'support':52 'tool':61 'type':13,47 'type-saf':12 'typescript':46,67 'updat':33 'use':8 'valid':40 'version':19 'zod':3,9,37,64","created_at":"2026-06-07T16:59:12.050991+00:00","updated_at":"2026-06-07T16:59:12.050991+00:00","problems":[{"fix":"Ensure you import from 'pocketbase-zod-schema/schema' and that package is installed.","cause":"Missing or incorrect import path in Node.js (CJS requires specific path resolution).","error":"Cannot find module 'pocketbase-zod-schema/schema'"},{"fix":"Run 'npx pocketbase-migrate generate-types' and import from the generated file.","cause":"Attempting to import TypedPocketBase directly from the package; it's generated by CLI.","error":"TypedPocketBase is not exported from 'pocketbase-zod-schema'"},{"fix":"Use 'import { defineCollection } from \"pocketbase-zod-schema/schema\";'.","cause":"Trying to import defineCollection from wrong path or version mismatch.","error":"TypeError: defineCollection is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/dastron/pocketbase-zod-schema#readme","github":"https://github.com/dastron/pocketbase-zod-schema","docs":null,"changelog":null,"pypi":null,"npm":"pocketbase-zod-schema","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}