kanban-dev-webapp/pocketbase/pb_migrations/1789600400_created_columns.js
Dave ba990f0109 feat(schema): all collections + role-scoped API rules on remote PB
- migrations/ documented in pocketbase/pb_migrations/ for local PB
- scripts/setup-remote.ts applies them via admin API to remote PB
- collections: clients, projects, columns, cards, subtasks, comments, activity, settings
- user extension: role (owner|client_manager), client (relation)
- writes: owner only for app collections, superuser-only for activity and settings
2026-09-16 09:41:20 +02:00

52 lines
No EOL
1.7 KiB
JavaScript

/// <reference path="../pb_data/types.d.ts" />
/**
* `columns` — the vertical lanes of one project's board.
*
* Two flags carry behaviour rather than presentation:
* is_inbox — where client-created cards land. Exactly one per project.
* is_done — the terminal lane. Exactly one per project.
*
* "Exactly one" is enforced in application code (src/lib/columns/seed.ts and
* the admin flows in Plan 1b), not by the schema. PocketBase has no
* cross-record constraint that can express it.
*/
migrate(
(app) => {
const projects = app.findCollectionByNameOrId("projects");
const collection = new Collection({
name: "columns",
type: "base",
listRule: "@request.auth.id != ''",
viewRule: "@request.auth.id != ''",
createRule: null,
updateRule: null,
deleteRule: null,
fields: [
{
name: "project",
type: "relation",
required: true,
collectionId: projects.id,
cascadeDelete: true,
minSelect: 0,
maxSelect: 1,
},
{ name: "name", type: "text", required: true, max: 60, presentable: true },
{ name: "position", type: "number", required: true },
{ name: "is_inbox", type: "bool", required: false },
{ name: "is_done", type: "bool", required: false },
{ name: "created", type: "autodate", onCreate: true, onUpdate: false },
{ name: "updated", type: "autodate", onCreate: true, onUpdate: true },
],
indexes: [
"CREATE INDEX idx_columns_project ON columns (project, position)",
],
});
return app.save(collection);
},
(app) => {
return app.delete(app.findCollectionByNameOrId("columns"));
}
);