- 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
56 lines
No EOL
1.4 KiB
JavaScript
56 lines
No EOL
1.4 KiB
JavaScript
/// <reference path="../pb_data/types.d.ts" />
|
|
/**
|
|
* `clients` — the companies the developer works for.
|
|
*
|
|
* A client owns projects. Client-manager users are scoped to exactly one
|
|
* client, and that scoping is what stops one customer seeing another's work.
|
|
*/
|
|
migrate(
|
|
(app) => {
|
|
const collection = new Collection({
|
|
name: "clients",
|
|
type: "base",
|
|
listRule: "@request.auth.id != ''",
|
|
viewRule: "@request.auth.id != ''",
|
|
createRule: null,
|
|
updateRule: null,
|
|
deleteRule: null,
|
|
fields: [
|
|
{
|
|
name: "name",
|
|
type: "text",
|
|
required: true,
|
|
max: 120,
|
|
presentable: true,
|
|
},
|
|
{
|
|
name: "slug",
|
|
type: "text",
|
|
required: true,
|
|
max: 60,
|
|
pattern: "^[a-z0-9-]+$",
|
|
},
|
|
{ name: "brand_color", type: "text", required: false, max: 7 },
|
|
{ name: "active", type: "bool", required: false },
|
|
{
|
|
name: "created",
|
|
type: "autodate",
|
|
onCreate: true,
|
|
onUpdate: false,
|
|
},
|
|
{
|
|
name: "updated",
|
|
type: "autodate",
|
|
onCreate: true,
|
|
onUpdate: true,
|
|
},
|
|
],
|
|
indexes: ["CREATE UNIQUE INDEX idx_clients_slug ON clients (slug)"],
|
|
});
|
|
|
|
return app.save(collection);
|
|
},
|
|
(app) => {
|
|
return app.delete(app.findCollectionByNameOrId("clients"));
|
|
}
|
|
); |