- 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
71 lines
No EOL
2.1 KiB
JavaScript
71 lines
No EOL
2.1 KiB
JavaScript
/// <reference path="../pb_data/types.d.ts" />
|
|
/**
|
|
* `projects` — one project maps to exactly one git repository.
|
|
*
|
|
* The three repo_* fields are written now and read for the first time in
|
|
* Phase 2, when Forgejo commit ingestion is built. They are stored here so
|
|
* the owner can fill them in as projects are created, rather than needing a
|
|
* migration and a backfill later.
|
|
*/
|
|
migrate(
|
|
(app) => {
|
|
const clients = app.findCollectionByNameOrId("clients");
|
|
|
|
const collection = new Collection({
|
|
name: "projects",
|
|
type: "base",
|
|
listRule: "@request.auth.id != ''",
|
|
viewRule: "@request.auth.id != ''",
|
|
createRule: null,
|
|
updateRule: null,
|
|
deleteRule: null,
|
|
fields: [
|
|
{
|
|
name: "client",
|
|
type: "relation",
|
|
required: true,
|
|
collectionId: clients.id,
|
|
cascadeDelete: false,
|
|
minSelect: 0,
|
|
maxSelect: 1,
|
|
},
|
|
{
|
|
name: "name",
|
|
type: "text",
|
|
required: true,
|
|
max: 120,
|
|
presentable: true,
|
|
},
|
|
{
|
|
name: "slug",
|
|
type: "text",
|
|
required: true,
|
|
max: 60,
|
|
pattern: "^[a-z0-9-]+$",
|
|
},
|
|
{ name: "description", type: "text", required: false, max: 20000 },
|
|
{
|
|
name: "status",
|
|
type: "select",
|
|
required: true,
|
|
maxSelect: 1,
|
|
values: ["active", "paused", "completed", "archived"],
|
|
},
|
|
{ name: "color", type: "text", required: false, max: 7 },
|
|
{ name: "repo_owner", type: "text", required: false, max: 120 },
|
|
{ name: "repo_name", type: "text", required: false, max: 120 },
|
|
{ name: "repo_url", type: "url", required: false },
|
|
{ name: "created", type: "autodate", onCreate: true, onUpdate: false },
|
|
{ name: "updated", type: "autodate", onCreate: true, onUpdate: true },
|
|
],
|
|
indexes: [
|
|
"CREATE UNIQUE INDEX idx_projects_client_slug ON projects (client, slug)",
|
|
],
|
|
});
|
|
|
|
return app.save(collection);
|
|
},
|
|
(app) => {
|
|
return app.delete(app.findCollectionByNameOrId("projects"));
|
|
}
|
|
); |