⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.
TypeScript agenticagileai-agentsbug-reportingbug-trackerganttissue-trackerjirajira-alternativekanbanlinearlinear-alternativeopen-sourceproduct-managementproject-managementroadmapself-hostedsprint-planningteam-collaborationtrello-alternative
feat: publish project templates to the gallery at itsaplan.dev (#796)
Croff77c7e35b0cde
diff --git a/apps/api/src/modules/agents/core/service.ts b/apps/api/src/modules/agents/core/service.tsindex 02e4fbb9..1d56bfd3 100644--- a/apps/api/src/modules/agents/core/service.ts+++ b/apps/api/src/modules/agents/core/service.ts@@ -571,9 +571,7 @@ async function resolveTeamProjectIds(teamId: number, projectIds: number[]): Promconst rows = await db.select({ id: project.id }).from(project)- .where(- and(eq(project.teamId, teamId), inArray(project.id, wanted), eq(project.isTemplate, false)),- );+ .where(and(eq(project.teamId, teamId), inArray(project.id, wanted)));if (rows.length !== wanted.length) throw new HttpError(400, 'Project not found in this team');return rows.map((row) => row.id);}diff --git a/apps/api/src/modules/columns/model.ts b/apps/api/src/modules/columns/model.tsindex babe5831..5dc7849c 100644--- a/apps/api/src/modules/columns/model.ts+++ b/apps/api/src/modules/columns/model.ts@@ -1,6 +1,6 @@import { t } from 'elysia';-const stateType = t.Union([+export const stateType = t.Union([t.Literal('backlog'),t.Literal('unstarted'),t.Literal('started'),diff --git a/apps/api/src/modules/custom-fields/model.ts b/apps/api/src/modules/custom-fields/model.tsindex 1b0837d4..d0134c34 100644--- a/apps/api/src/modules/custom-fields/model.ts+++ b/apps/api/src/modules/custom-fields/model.ts@@ -1,6 +1,6 @@import { t } from 'elysia';-const fieldType = t.Union([+export const fieldType = t.Union([t.Literal('text'),t.Literal('markdown'),t.Literal('url'),@@ -15,7 +15,7 @@ const fieldType = t.Union([]);// Who a member field may hold: every candidate, the people only, or the agents only.-const memberScope = t.Union([t.Literal('all'), t.Literal('humans'), t.Literal('agents')]);+export const memberScope = t.Union([t.Literal('all'), t.Literal('humans'), t.Literal('agents')]);export const fieldParams = t.Object({ projectKey: t.String(), fieldId: t.Numeric() });diff --git a/apps/api/src/modules/god/service.ts b/apps/api/src/modules/god/service.tsindex b7a04e2c..8544b208 100644--- a/apps/api/src/modules/god/service.ts+++ b/apps/api/src/modules/god/service.ts@@ -532,10 +532,9 @@ export async function listInstanceProjects(options: {offset: number;}): Promise<InstanceProjectPage> {const term = options.search?.trim();- const where = and(- eq(project.isTemplate, false),- term ? or(ilike(project.key, `%${term}%`), ilike(project.name, `%${term}%`)) : undefined,- );+ const where = term+ ? or(ilike(project.key, `%${term}%`), ilike(project.name, `%${term}%`))+ : undefined;const [rows, totals] = await Promise.all([db@@ -672,7 +671,7 @@ async function loadTeamCounts(teamIds: number[]): Promise<(id: number) => Instanconst [members, projects, issues, agents, skills, tools, roles] = await Promise.all([countByOwner(teamMember, teamMember.teamId, teamIds),- countByOwner(project, project.teamId, teamIds, eq(project.isTemplate, false)),+ countByOwner(project, project.teamId, teamIds),// Issues have no team column; they reach one through their project.db.select({ teamId: project.teamId, count: sql<number>`count(*)::int` })@@ -757,7 +756,6 @@ export async function listInstanceTeamProjects(const term = options.search?.trim();const where = and(eq(project.teamId, teamId),- eq(project.isTemplate, false),term ? or(ilike(project.key, `%${term}%`), ilike(project.name, `%${term}%`)) : undefined,);diff --git a/apps/api/src/modules/project-templates/__tests__/integration/project-templates.test.ts b/apps/api/src/modules/project-templates/__tests__/integration/project-templates.test.tsindex 04dcabf5..8cc975e9 100644--- a/apps/api/src/modules/project-templates/__tests__/integration/project-templates.test.ts+++ b/apps/api/src/modules/project-templates/__tests__/integration/project-templates.test.ts@@ -1,4 +1,4 @@-import { beforeEach, describe, expect, it } from 'bun:test';+import { afterEach, beforeEach, describe, expect, it } from 'bun:test';import { authedApi, type Api, createProject } from '#tests/helpers/app';import { signUpTestUser } from '#tests/helpers/auth';import { resetDb } from '#tests/helpers/db';@@ -19,62 +19,73 @@ async function addTeamMember(owner: Api, teamId: number, role: 'manager' | 'membconst created = await owner.teams({ teamId }).invites.post({ email: user.email, role });const api = authedApi(user.cookie);await api.invites({ token: created.data!.token }).accept.post();- return api;+ return { user, api };}-// A team with the project SRC, which has the label "bug", saved as the template "Kanban".+// A workspace whose team holds the project SRC, which has the label "bug", saved as the+// template "Kanban".async function setup() {- const { api } = await signUpClient();+ const { user, api } = await signUpClient();+ const workspaceId = user.workspaceId!;const teamId = await ownTeamId(api);const source = (await createProject(api, { key: 'SRC', name: 'Source' })).data!;await api.projects({ projectKey: 'SRC' }).labels.post({ name: 'bug', color: '#ff0000' });- const saved = await api- .teams({ teamId })- ['project-templates'].post({ projectId: source.id, name: 'Kanban', description: 'Our board' });+ const templates = api.workspaces({ workspaceId })['project-templates'];+ const saved = await templates.post({+ projectId: source.id,+ name: 'Kanban',+ description: 'Our board',+ });expect(saved.status).toBe(201);- return { api, teamId, source, template: saved.data! };+ return { user, api, workspaceId, teamId, source, templates, template: saved.data! };+}++async function secondTeam(api: Api, workspaceId: number, slug = 'second'): Promise<number> {+ const created = await api.teams.post({ name: 'Second', slug, workspaceId });+ return created.data!.id;}describe('project templates', () => {beforeEach(resetDb);describe('save', () => {- it('lists the template and leaves it out of every project list', async () => {- const { api, teamId, template } = await setup();- expect(template).toMatchObject({ name: 'Kanban', description: 'Our board' });+ it('lists the template in the workspace and to every team of it', async () => {+ const { api, workspaceId, teamId, templates, template } = await setup();+ const otherTeamId = await secondTeam(api, workspaceId);+ expect(template).toMatchObject({ name: 'Kanban', description: 'Our board', teamIds: null });- const list = await api.teams({ teamId })['project-templates'].get();+ const list = await templates.get();expect(list.status).toBe(200);- expect(list.data).toMatchObject([{ id: template.id, name: 'Kanban' }]);-- // The first account owns its workspace, so it reaches every project of it.- expect((await api.projects.get()).data?.map((p) => p.key)).toEqual(['SRC']);- expect((await api.projects.search.get({ query: {} })).data?.total).toBe(1);- const teamProjects = await api.teams({ teamId }).projects.get();- expect(teamProjects.data?.items.map((p) => p.key)).toEqual(['SRC']);- expect((await api.teams.get()).data![0]).toMatchObject({ projectCount: 1, templateCount: 1 });- const asProject = await api.teams({ teamId }).projects({ projectId: template.id }).get();- expect(asProject.status).toBe(404);+ expect(list.data).toMatchObject([{ id: template.id, name: 'Kanban', teamIds: null }]);+ for (const id of [teamId, otherTeamId]) {+ const forTeam = await api.teams({ teamId: id })['project-templates'].get();+ expect(forTeam.data?.map((t) => t.id)).toEqual([template.id]);+ }+ expect((await api.teams.get()).data?.find((t) => t.id === teamId)).toMatchObject({+ projectCount: 1,+ });});- it('keeps what was saved when the project changes later', async () => {- const { api, teamId, template } = await setup();+ it('keeps what was saved when the project changes or is deleted', async () => {+ const { api, teamId, source, template } = await setup();await api.projects({ projectKey: 'SRC' }).labels.post({ name: 'later', color: '#00ff00' });+ await api.teams({ teamId }).projects({ projectId: source.id }).delete();- await api+ const created = await api.teams({ teamId }).projects.post({ key: 'NEW', name: 'New', templateId: template.id });+ expect(created.status).toBe(201);const view = await api.projects({ projectKey: 'NEW' }).get();expect(view.data?.labels.map((l) => l.name)).toEqual(['bug']);});it('leaves out the docs and the webhooks', async () => {- const { api, teamId, source } = await setup();+ const { api, teamId, source, templates } = await setup();const sourceApi = api.projects({ projectKey: 'SRC' });await sourceApi.documents.post({ title: 'Runbook' });await sourceApi.webhooks.post({ url: 'https://example.com/hook', events: ['issue.created'] });- const saved = await api.teams({ teamId })['project-templates'].post({+ const saved = await templates.post({projectId: source.id,name: 'Everything',include: { documents: true, webhooks: true },@@ -90,8 +101,8 @@ describe('project templates', () => {});it('saves only the chosen sections', async () => {- const { api, teamId, source } = await setup();- const saved = await api.teams({ teamId })['project-templates'].post({+ const { api, teamId, source, templates } = await setup();+ const saved = await templates.post({projectId: source.id,name: 'States only',include: { states: true },@@ -103,83 +114,233 @@ describe('project templates', () => {const view = await api.projects({ projectKey: 'NEW' }).get();expect(view.data?.labels).toEqual([]);+ expect(view.data?.issueTypes).toEqual([]);});- it('rejects an empty name', async () => {- const { api, teamId, source } = await setup();- const saved = await api+ it('starts on the default columns when the states are left out', async () => {+ const { api, teamId, source, templates } = await setup();+ await api+ .projects({ projectKey: 'SRC' })+ .columns.post({ name: 'Review', stateType: 'started' });+ const saved = await templates.post({+ projectId: source.id,+ name: 'Labels only',+ include: { labels: true },+ });++ await api.teams({ teamId })- ['project-templates'].post({ projectId: source.id, name: '' });- expect(saved.status).toBe(400);+ .projects.post({ key: 'NEW', name: 'New', templateId: saved.data!.id });++ const view = await api.projects({ projectKey: 'NEW' }).get();+ expect(view.data?.columns.map((c) => c.name)).toEqual([+ 'Backlog',+ 'Todo',+ 'In Progress',+ 'Done',+ 'Canceled',+ ]);+ expect(view.data?.labels.map((l) => l.name)).toEqual(['bug']);});- it('404s for a project of another team and for a template', async () => {- const { api, teamId, template } = await setup();+ it('rejects an empty name and an empty team list', async () => {+ const { source, templates } = await setup();+ expect((await templates.post({ projectId: source.id, name: '' })).status).toBe(400);+ const noTeams = await templates.post({ projectId: source.id, name: 'None', teamIds: [] });+ expect(noTeams.status).toBe(400);+ });++ it('404s for a project of another workspace', async () => {+ const { templates } = await setup();const other = await signUpClient();const otherProject = (await createProject(other.api, { key: 'OTH', name: 'Other' })).data!;- const fromOther = await api- .teams({ teamId })- ['project-templates'].post({ projectId: otherProject.id, name: 'Theirs' });+ const fromOther = await templates.post({ projectId: otherProject.id, name: 'Theirs' });expect(fromOther.status).toBe(404);- const fromTemplate = await api+ });++ it('400s for a team of another workspace', async () => {+ const { source, templates } = await setup();+ const other = await signUpClient();++ const saved = await templates.post({+ projectId: source.id,+ name: 'Theirs',+ teamIds: [await ownTeamId(other.api)],+ });+ expect(saved.status).toBe(400);+ });++ it('refuses an MCP client a project closed to MCP', async () => {+ const { api, teamId, source, templates } = await setup();+ // The header the MCP endpoint sets on its tool calls.+ const asMcp = { headers: { 'x-mcp-loopback': '1' } };+ expect((await templates.post({ projectId: source.id, name: 'Open' }, asMcp)).status).toBe(+ 201,+ );++ await api.teams({ teamId })- ['project-templates'].post({ projectId: template.id, name: 'Again' });- expect(fromTemplate.status).toBe(404);+ .mcp.patch({ projects: [{ projectId: source.id, enabled: false }] });+ expect((await templates.post({ projectId: source.id, name: 'Closed' }, asMcp)).status).toBe(+ 403,+ );+ expect((await templates.post({ projectId: source.id, name: 'Web' })).status).toBe(201);});- it('is left to the owners and managers of the team', async () => {- const { api, teamId, source, template } = await setup();- const member = await addTeamMember(api, teamId, 'member');+ it('is left to the owner and the admins of the workspace', async () => {+ const { api, workspaceId, teamId, source, template } = await setup();const manager = await addTeamMember(api, teamId, 'manager');+ const admin = await addTeamMember(api, teamId, 'member');+ await api.workspaces({ workspaceId }).managers.post({ userId: admin.user.userId });- const templates = member.teams({ teamId })['project-templates'];- expect((await templates.get()).status).toBe(403);- expect((await templates({ templateId: template.id }).get()).status).toBe(403);- expect((await templates.post({ projectId: source.id, name: 'Mine' })).status).toBe(403);- expect((await templates({ templateId: template.id }).delete()).status).toBe(403);+ const asManager = manager.api.workspaces({ workspaceId })['project-templates'];+ expect((await asManager.get()).status).toBe(404);+ expect((await asManager({ templateId: template.id }).get()).status).toBe(404);+ expect((await asManager.post({ projectId: source.id, name: 'Mine' })).status).toBe(404);+ expect((await asManager({ templateId: template.id }).patch({ name: 'Mine' })).status).toBe(+ 404,+ );+ expect((await asManager({ templateId: template.id }).delete()).status).toBe(404);- const saved = await manager- .teams({ teamId })- ['project-templates'].post({ projectId: source.id, name: 'Manager' });+ const saved = await admin.api+ .workspaces({ workspaceId })+ ['project-templates'].post({ projectId: source.id, name: 'Admin' });expect(saved.status).toBe(201);});});- describe('detail', () => {- it('shows what the template holds', async () => {- const { api, teamId, template } = await setup();+ describe('preview', () => {+ it('shows what a template of the project would hold, saving nothing', async () => {+ const { source, templates } = await setup();- const detail = await api- .teams({ teamId })- ['project-templates']({ templateId: template.id })- .get();- expect(detail.status).toBe(200);- expect(detail.data).toMatchObject({- id: template.id,- name: 'Kanban',- description: 'Our board',+ const full = await templates.preview.post({ projectId: source.id });+ expect(full.status).toBe(200);+ expect(full.data).toMatchObject({labels: [{ name: 'bug' }],issueTypes: [{ name: 'Task' }],- estimates: { points: false, time: false, logging: false },- sections: [],});- expect(detail.data?.columns.map((c) => c.name)).toEqual([- 'Backlog',- 'Todo',- 'In Progress',- 'Done',- 'Canceled',- ]);+ const statesOnly = await templates.preview.post({+ projectId: source.id,+ include: { states: true },+ });+ expect(statesOnly.data?.labels).toEqual([]);+ expect(statesOnly.data?.columns.map((c) => c.name)).toContain('Done');+ expect((await templates.get()).data).toHaveLength(1);+ });++ it('404s for a project of another workspace and for someone who does not manage it', async () => {+ const { api, workspaceId, teamId, source, templates } = await setup();+ const other = await signUpClient();+ const otherProject = (await createProject(other.api, { key: 'OTH', name: 'Other' })).data!;+ expect((await templates.preview.post({ projectId: otherProject.id })).status).toBe(404);++ const manager = await addTeamMember(api, teamId, 'manager');+ const asManager = manager.api.workspaces({ workspaceId });+ expect(+ (await asManager['project-templates'].preview.post({ projectId: source.id })).status,+ ).toBe(404);+ });+ });++ describe('teams', () => {+ it('limits a template to the chosen teams', async () => {+ const { api, workspaceId, teamId, source, templates } = await setup();+ const otherTeamId = await secondTeam(api, workspaceId);+ const saved = await templates.post({+ projectId: source.id,+ name: 'First team',+ teamIds: [teamId],+ });+ expect(saved.data).toMatchObject({ teamIds: [teamId] });++ const forOther = await api.teams({ teamId: otherTeamId })['project-templates'].get();+ expect(forOther.data?.map((t) => t.name)).toEqual(['Kanban']);+ const detail = await api+ .teams({ teamId: otherTeamId })+ ['project-templates']({ templateId: saved.data!.id })+ .get();+ expect(detail.status).toBe(404);+ const created = await api+ .teams({ teamId: otherTeamId })+ .projects.post({ key: 'NEW', name: 'New', templateId: saved.data!.id });+ expect(created.status).toBe(404);++ const own = await api+ .teams({ teamId })+ .projects.post({ key: 'NEW', name: 'New', templateId: saved.data!.id });+ expect(own.status).toBe(201);+ });++ it('stays closed to the other teams once its teams are deleted', async () => {+ const { api, workspaceId, teamId, source, templates } = await setup();+ const otherTeamId = await secondTeam(api, workspaceId);+ const saved = await templates.post({+ projectId: source.id,+ name: 'Second team',+ teamIds: [otherTeamId],+ });+ expect((await api.teams({ teamId: otherTeamId }).delete()).status).toBe(204);++ const list = await templates.get();+ expect(list.data?.find((t) => t.id === saved.data!.id)).toMatchObject({ teamIds: [] });+ const forTeam = await api.teams({ teamId })['project-templates'].get();+ expect(forTeam.data?.map((t) => t.name)).toEqual(['Kanban']);+ });+ });++ describe('detail', () => {+ it('shows what the template holds', async () => {+ const { api, teamId, templates, template } = await setup();++ for (const detail of [+ await templates({ templateId: template.id }).get(),+ await api.teams({ teamId })['project-templates']({ templateId: template.id }).get(),+ ]) {+ expect(detail.status).toBe(200);+ expect(detail.data).toMatchObject({+ id: template.id,+ name: 'Kanban',+ description: 'Our board',+ teamIds: null,+ labels: [{ name: 'bug' }],+ issueTypes: [{ name: 'Task' }],+ estimates: { points: false, time: false, logging: false },+ sections: [],+ });+ expect(detail.data?.columns.map((c) => c.name)).toEqual([+ 'Backlog',+ 'Todo',+ 'In Progress',+ 'Done',+ 'Canceled',+ ]);+ }});- it('404s for a project and for a template of another team', async () => {- const { api, teamId, source } = await setup();+ it('404s for a template of another workspace', async () => {+ const { api, teamId, templates } = await setup();const other = await setup();- const templates = api.teams({ teamId })['project-templates'];- expect((await templates({ templateId: source.id }).get()).status).toBe(404);expect((await templates({ templateId: other.template.id }).get()).status).toBe(404);+ const forTeam = await api+ .teams({ teamId })+ ['project-templates']({ templateId: other.template.id })+ .get();+ expect(forTeam.status).toBe(404);+ });++ it('is read by the owners and managers of a team, not by its members', async () => {+ const { api, teamId, template } = await setup();+ const member = await addTeamMember(api, teamId, 'member');+ const manager = await addTeamMember(api, teamId, 'manager');++ const asMember = member.api.teams({ teamId })['project-templates'];+ expect((await asMember.get()).status).toBe(403);+ expect((await asMember({ templateId: template.id }).get()).status).toBe(403);++ const asManager = manager.api.teams({ teamId })['project-templates'];+ expect((await asManager.get()).data?.map((t) => t.id)).toEqual([template.id]);});});@@ -204,57 +365,752 @@ describe('project templates', () => {expect(members.data?.items.map((m) => m.userId)).toContain(agent.userId);});- it("404s for another team's template and for a project", async () => {- const { api, teamId, source } = await setup();+ it('creates the project in another team of the workspace', async () => {+ const { api, workspaceId, template } = await setup();+ const otherTeamId = await secondTeam(api, workspaceId);++ const created = await api+ .teams({ teamId: otherTeamId })+ .projects.post({ key: 'NEW', name: 'New', templateId: template.id });+ expect(created.status).toBe(201);+ expect(created.data).toMatchObject({ teamId: otherTeamId });++ const view = await api.projects({ projectKey: 'NEW' }).get();+ expect(view.data?.labels.map((l) => l.name)).toEqual(['bug']);+ });++ it('remaps what views and issue templates reference onto the new project', async () => {+ const { api, teamId, source, templates } = await setup();+ const sourceView = (await api.projects({ projectKey: 'SRC' }).get()).data!;+ const bug = sourceView.labels[0];+ const done = sourceView.columns.find((c) => c.name === 'Done')!;+ await api.projects({ projectKey: 'SRC' }).views.post({+ name: 'Bugs',+ filters: { conditions: [{ field: 'labels', op: 'any', values: [bug.id] }] },+ });+ await api.projects({ projectKey: 'SRC' })['issue-templates'].post({+ name: 'Bug report',+ columnId: done.id,+ labelIds: [bug.id],+ });+ const saved = await templates.post({ projectId: source.id, name: 'Views' });++ await api+ .teams({ teamId })+ .projects.post({ key: 'NEW', name: 'New', templateId: saved.data!.id });++ const created = (await api.projects({ projectKey: 'NEW' }).get()).data!;+ const newBug = created.labels.find((l) => l.name === 'bug')!;+ const newDone = created.columns.find((c) => c.name === 'Done')!;+ const views = (await api.projects({ projectKey: 'NEW' }).views.get()).data!;+ expect(views.find((v) => v.name === 'Bugs')?.filters).toEqual({+ conditions: [{ id: '1', field: 'labels', op: 'any', values: [newBug.id] }],+ });+ const issueTemplates = (await api.projects({ projectKey: 'NEW' })['issue-templates'].get())+ .data!;+ expect(issueTemplates).toMatchObject([+ { name: 'Bug report', columnId: newDone.id, labelIds: [newBug.id] },+ ]);+ });++ it('remaps the groups, the widgets and the actions onto the new project', async () => {+ const { api, teamId, source, templates } = await setup();+ const src = api.projects({ projectKey: 'SRC' });+ const done = (await src.get()).data!.columns.find((c) => c.name === 'Done')!;+ const size = (await src['custom-fields'].post({ name: 'Size', fieldType: 'select' })).data!;+ await src.views.post({+ name: 'Board',+ display: {+ group: `cf:${size.id}`,+ collapsedGroups: [`c${done.id}`, 'i7'],+ pinnedGroup: `c${done.id}`,+ },+ });+ const status = { conditions: [{ id: 'q', field: 'status', op: 'is', values: [done.id] }] };+ await src.dashboards.post({+ name: 'Overview',+ layout: [{ id: 'w', type: 'recent_issues', config: { filters: status, initiativeId: 7 } }],+ });+ await src.actions.post({ name: 'Close', effect: { columnId: done.id } });+ const saved = await templates.post({ projectId: source.id, name: 'Board' });++ await api+ .teams({ teamId })+ .projects.post({ key: 'NEW', name: 'New', templateId: saved.data!.id });++ const created = api.projects({ projectKey: 'NEW' });+ const project = (await created.get()).data!;+ const newDone = project.columns.find((c) => c.name === 'Done')!;+ const newSize = project.customFields.find((f) => f.name === 'Size')!;+ const view = (await created.views.get()).data!.find((v) => v.name === 'Board')!;+ expect(view.display).toMatchObject({+ group: `cf:${newSize.id}`,+ collapsedGroups: [`c${newDone.id}`, 'i7'],+ pinnedGroup: `c${newDone.id}`,+ });+ expect((await created.dashboards.get()).data![0].layout).toEqual([+ {+ id: '1',+ type: 'recent_issues',+ config: {+ filters: { conditions: [{ id: '1', field: 'status', op: 'is', values: [newDone.id] }] },+ initiativeId: 7,+ },+ },+ ]);+ expect((await created.actions.get()).data![0].effect).toEqual({ columnId: newDone.id });+ });++ it('404s for a template of another workspace', async () => {+ const { api, teamId } = await setup();const other = await setup();const fromOther = await api.teams({ teamId }).projects.post({ key: 'NEW', name: 'New', templateId: other.template.id });expect(fromOther.status).toBe(404);- const fromProject = await api+ });+ });++ describe('update', () => {+ it('renames the template and changes its description, keeping what it holds', async () => {+ const { api, teamId, templates, template } = await setup();++ const updated = await templates({ templateId: template.id }).patch({+ name: 'Board',+ description: 'Renamed',+ });+ expect(updated.status).toBe(200);+ expect(updated.data).toMatchObject({ name: 'Board', description: 'Renamed', teamIds: null });++ const detail = await templates({ templateId: template.id }).get();+ expect(detail.data).toMatchObject({ name: 'Board', labels: [{ name: 'bug' }] });+ const created = await api.teams({ teamId })- .projects.post({ key: 'NEW', name: 'New', templateId: source.id });- expect(fromProject.status).toBe(404);+ .projects.post({ key: 'NEW', name: 'New', templateId: template.id });+ expect(created.status).toBe(201);+ });++ it('limits the template to teams and opens it to every team again', async () => {+ const { api, workspaceId, teamId, templates, template } = await setup();+ const otherTeamId = await secondTeam(api, workspaceId);+ const forOther = () => api.teams({ teamId: otherTeamId })['project-templates'].get();++ const limited = await templates({ templateId: template.id }).patch({+ teamIds: [teamId, teamId],+ });+ expect(limited.data).toMatchObject({ name: 'Kanban', teamIds: [teamId] });+ expect((await forOther()).data).toEqual([]);++ const moved = await templates({ templateId: template.id }).patch({ teamIds: [otherTeamId] });+ expect(moved.data).toMatchObject({ teamIds: [otherTeamId] });+ expect((await api.teams({ teamId })['project-templates'].get()).data).toEqual([]);++ const opened = await templates({ templateId: template.id }).patch({ teamIds: null });+ expect(opened.data).toMatchObject({ teamIds: null });+ expect((await forOther()).data?.map((t) => t.id)).toEqual([template.id]);+ });++ it('rejects an empty name, an empty team list and an empty body', async () => {+ const { templates, template } = await setup();+ const one = templates({ templateId: template.id });+ expect((await one.patch({ name: '' })).status).toBe(400);+ expect((await one.patch({ teamIds: [] })).status).toBe(400);+ expect((await one.patch({})).status).toBe(400);+ expect((await one.get()).data).toMatchObject({ name: 'Kanban', teamIds: null });+ });++ it('400s for a team of another workspace', async () => {+ const { templates, template } = await setup();+ const other = await signUpClient();++ const updated = await templates({ templateId: template.id }).patch({+ teamIds: [await ownTeamId(other.api)],+ });+ expect(updated.status).toBe(400);+ expect((await templates({ templateId: template.id }).get()).data?.teamIds).toBeNull();+ });++ it('404s for a template of another workspace, leaving it as it was', async () => {+ const { templates } = await setup();+ const other = await setup();++ const updated = await templates({ templateId: other.template.id }).patch({ name: 'Mine' });+ expect(updated.status).toBe(404);+ expect((await other.templates.get()).data).toMatchObject([{ name: 'Kanban' }]);+ });+ });++ describe('share', () => {+ // A view and an action of SRC that name the user, saved with the label as "Shared".+ async function exported() {+ const ctx = await setup();+ const { user, api, source, templates } = ctx;+ const src = api.projects({ projectKey: 'SRC' });+ await src.views.post({+ name: 'Mine',+ filters: {+ conditions: [+ { id: 'c1', field: 'assignee', op: 'is', values: [user.userId, null] },+ { id: 'c2', field: 'delegate', op: 'is', values: [user.userId] },+ { id: 'c3', field: 'priority', op: 'is', values: ['high'] },+ ],+ },+ display: { hiddenGroups: [`a${user.userId}`, 'a-none', 'all'] },+ });+ await src.actions.post({+ name: 'Take',+ condition: {+ conditions: [{ id: 'c1', field: 'assignee', op: 'is', values: [user.userId] }],+ },+ effect: { assigneeUserId: user.userId, priority: 'high' },+ });+ const saved = await templates.post({ projectId: source.id, name: 'Shared' });+ const doc = await templates({ templateId: saved.data!.id }).export.get();+ expect(doc.status).toBe(200);+ return { ...ctx, doc: doc.data! };+ }++ it('exports the template without the people it names', async () => {+ const { user, doc } = await exported();++ expect(doc).toMatchObject({+ format: 'itsaplan.project-template',+ version: 1,+ name: 'Shared',+ });+ expect(doc.snapshot.labels.map((l) => l.name)).toEqual(['bug']);+ expect(doc.snapshot.views[0].filters.conditions).toEqual([+ { id: '1', field: 'assignee', op: 'is', values: [null] },+ { id: '2', field: 'priority', op: 'is', values: ['high'] },+ ]);+ expect(doc.snapshot.views[0].display.hiddenGroups).toEqual(['a-none', 'all']);+ expect(doc.snapshot.actions[0].condition.conditions).toEqual([]);+ expect(doc.snapshot.actions[0].effect).toEqual({ priority: 'high' });+ expect(JSON.stringify(doc)).not.toContain(user.userId);+ });++ it('numbers the parts from 1 and points every reference at those numbers', async () => {+ const { user, api, templates } = await setup();+ const src = api.projects({ projectKey: 'SRC' });+ await src['custom-fields'].post({ name: 'Other', fieldType: 'select', options: ['X'] });+ const numbered = (await createProject(api, { key: 'NUM', name: 'Numbered' })).data!;+ const project = api.projects({ projectKey: 'NUM' });+ const bug = (await project.labels.post({ name: 'bug', color: '#ff0000' })).data!;+ const size = (+ await project['custom-fields'].post({+ name: 'Size',+ fieldType: 'select',+ options: ['S', 'L'],+ })+ ).data!;+ const large = size.options.find((option) => option.value === 'L')!;+ const done = (await project.get()).data!.columns.find((c) => c.name === 'Done')!;+ await project.views.post({+ name: 'Large bugs',+ filters: {+ conditions: [+ { id: 'x', field: 'labels', op: 'is', values: [bug.id] },+ { id: 'y', field: `cf:${size.id}`, op: 'is', values: [large.id] },+ { id: 'z', field: 'initiative', op: 'is', values: [7, 'status:active'] },+ ],+ },+ display: {+ group: `cf:${size.id}`,+ subgroup: `cf:${size.id}`,+ properties: ['id', `cf:${size.id}`],+ calendarDateField: `cf:${size.id}`,+ hiddenGroups: [`c${done.id}`, 'i7'],+ collapsedGroups: [`c${done.id}`, `a${user.userId}`],+ pinnedGroup: `c${done.id}`,+ },+ });+ await project['issue-templates'].post({+ name: 'Bug report',+ columnId: done.id,+ labelIds: [bug.id],+ });+ await project.dashboards.post({+ name: 'Overview',+ layout: [+ {+ id: 'w-abc',+ type: 'recent_issues',+ config: {+ filters: { conditions: [{ id: 'q', field: 'status', op: 'is', values: [done.id] }] },+ actorUserId: user.userId,+ initiativeId: 7,+ },+ },+ ],+ });+ await project.actions.post({+ name: 'Close',+ effect: { columnId: done.id, labelIds: [bug.id] },+ });+ const saved = await templates.post({ projectId: numbered.id, name: 'Numbered' });++ const doc = (await templates({ templateId: saved.data!.id }).export.get()).data!;+ const { snapshot } = doc;+ const doneNumber = snapshot.columns.findIndex((c) => c.name === 'Done') + 1;+ // The rows' own ids differ from the numbers the file gives them.+ expect(done.id).not.toBe(doneNumber);+ expect(bug.id).not.toBe(1);+ expect(size.id).not.toBe(1);+ expect(large.id).not.toBe(2);+ expect(snapshot.columns.map((c) => c.id)).toEqual(snapshot.columns.map((_, i) => i + 1));+ expect(snapshot.labels).toMatchObject([{ id: 1, name: 'bug' }]);+ expect(snapshot.customFields).toMatchObject([+ {+ id: 1,+ name: 'Size',+ options: [+ { id: 1, value: 'S' },+ { id: 2, value: 'L' },+ ],+ },+ ]);+ expect(snapshot.views[0].filters.conditions).toEqual([+ { id: '1', field: 'labels', op: 'is', values: [1] },+ { id: '2', field: 'cf:1', op: 'is', values: [2] },+ { id: '3', field: 'initiative', op: 'is', values: ['status:active'] },+ ]);+ expect(snapshot.views[0].display).toEqual({+ group: 'cf:1',+ subgroup: 'cf:1',+ properties: ['id', 'cf:1'],+ calendarDateField: 'cf:1',+ hiddenGroups: [`c${doneNumber}`],+ collapsedGroups: [`c${doneNumber}`],+ pinnedGroup: `c${doneNumber}`,+ });+ expect(snapshot.issueTemplates).toMatchObject([{ columnId: doneNumber, labelIds: [1] }]);+ expect(snapshot.dashboards[0].layout).toEqual([+ {+ id: '1',+ type: 'recent_issues',+ config: {+ filters: { conditions: [{ id: '1', field: 'status', op: 'is', values: [doneNumber] }] },+ },+ },+ ]);+ expect(snapshot.actions[0].effect).toEqual({ columnId: doneNumber, labelIds: [1] });++ const other = await signUpClient();+ const theirs = other.api.workspaces({ workspaceId: other.user.workspaceId! })[+ 'project-templates'+ ];+ const imported = await theirs.import.post({ template: doc, name: 'Theirs' });+ await other.api+ .teams({ teamId: await ownTeamId(other.api) })+ .projects.post({ key: 'NEW', name: 'New', templateId: imported.data!.id });+ const created = other.api.projects({ projectKey: 'NEW' });+ const newProject = (await created.get()).data!;+ const newBug = newProject.labels.find((l) => l.name === 'bug')!;+ const newLarge = newProject.customFields[0].options.find((o) => o.value === 'L')!;+ const view = (await created.views.get()).data!.find((v) => v.name === 'Large bugs')!;+ expect(view.filters.conditions).toEqual([+ { id: '1', field: 'labels', op: 'is', values: [newBug.id] },+ { id: '2', field: `cf:${newProject.customFields[0].id}`, op: 'is', values: [newLarge.id] },+ { id: '3', field: 'initiative', op: 'is', values: ['status:active'] },+ ]);+ });++ it('refuses a template that names a part it does not hold', async () => {+ const { doc, templates } = await exported();+ const view = {+ ...doc.snapshot.views[0],+ filters: { conditions: [{ id: '1', field: 'status', op: 'is', values: [99] }] },+ };+ const label = { ...doc.snapshot.labels[0], groupId: 99 };+ const cases: [typeof doc.snapshot, string][] = [+ [{ ...doc.snapshot, views: [view] }, 'The template has no state 99'],+ [{ ...doc.snapshot, labels: [label] }, 'The template has no label group 99'],+ ];+ for (const [snapshot, error] of cases) {+ const imported = await templates.import.post({+ template: { ...doc, snapshot },+ name: 'Pasted',+ });+ expect(imported.status).toBe(400);+ expect(imported.error?.value).toMatchObject({ error });+ }+ expect((await templates.get()).data?.map((t) => t.name)).toEqual(['Kanban', 'Shared']);+ });++ it('imports an exported template into another workspace', async () => {+ const { doc } = await exported();+ const other = await signUpClient();+ const theirs = other.api.workspaces({ workspaceId: other.user.workspaceId! })[+ 'project-templates'+ ];++ const preview = await theirs.import.preview.post({ template: doc });+ expect(preview.status).toBe(200);+ expect(preview.data).toMatchObject({ labels: [{ name: 'bug' }], views: [{ name: 'Mine' }] });++ const imported = await theirs.import.post({ template: doc, name: 'Theirs' });+ expect(imported.status).toBe(201);+ expect(imported.data).toMatchObject({ name: 'Theirs', description: '', teamIds: null });+ const created = await other.api+ .teams({ teamId: await ownTeamId(other.api) })+ .projects.post({ key: 'NEW', name: 'New', templateId: imported.data!.id });+ expect(created.status).toBe(201);+ const view = await other.api.projects({ projectKey: 'NEW' }).get();+ expect(view.data?.labels.map((l) => l.name)).toEqual(['bug']);+ });++ it('drops the people a pasted template names', async () => {+ const { doc, templates } = await exported();+ const action = { ...doc.snapshot.actions[0], effect: { assigneeUserId: 'someone' } };+ const pasted = { ...doc, snapshot: { ...doc.snapshot, actions: [action] } };++ const imported = await templates.import.post({ template: pasted, name: 'Pasted' });+ expect(imported.status).toBe(201);+ const again = await templates({ templateId: imported.data!.id }).export.get();+ expect(again.data?.snapshot.actions[0].effect).toEqual({});+ });++ it('refuses a template that is not one or is damaged', async () => {+ const { doc, templates } = await exported();+ const { snapshot } = doc;+ const column = snapshot.columns[0];+ const damaged: unknown[] = [+ { ...doc, format: 'other' },+ { ...doc, version: 2 },+ { ...doc, snapshot: { ...snapshot, columns: [column, { ...column, id: column.id + 1 }] } },+ {+ ...doc,+ snapshot: {+ ...snapshot,+ issueTemplates: [+ {+ name: 'Bug report',+ description: '',+ titleTemplate: '',+ descriptionTemplate: '',+ typeId: null,+ columnId: null,+ priority: null,+ labelIds: [snapshot.labels[0].id, snapshot.labels[0].id],+ },+ ],+ },+ },+ {+ ...doc,+ snapshot: {+ ...snapshot,+ labels: [...snapshot.labels, { ...snapshot.labels[0], name: 'other' }],+ },+ },+ {+ ...doc,+ snapshot: {+ ...snapshot,+ settings: [{ key: 'auto_archive', value: { completedDays: 1e9, canceledDays: null } }],+ },+ },+ { ...doc, snapshot: { ...snapshot, settings: [{ key: 'git', value: {} }] } },+ {+ ...doc,+ snapshot: {+ ...snapshot,+ issueTypes: [+ { ...snapshot.issueTypes[0], isDefault: true },+ { ...snapshot.issueTypes[0], id: 1_000_000, name: 'Other', isDefault: true },+ ],+ },+ },+ ];+ for (const [index, template] of damaged.entries()) {+ const preview = await templates.import.preview.post({ template: template as typeof doc });+ const imported = await templates.import.post({+ template: template as typeof doc,+ name: 'Damaged',+ });+ expect({ index, preview: preview.status, imported: imported.status }).toEqual({+ index,+ preview: 400,+ imported: 400,+ });+ }+ expect((await templates.get()).data?.map((t) => t.name)).toEqual(['Kanban', 'Shared']);+ });++ it('drops a key the template does not list', async () => {+ const { api, teamId, source, doc, templates } = await exported();+ const other = await signUpClient();+ const pasted = {+ ...doc,+ snapshot: {+ ...doc.snapshot,+ flags: { ...doc.snapshot.flags, teamId: await ownTeamId(other.api) },+ columns: doc.snapshot.columns.map((column) => ({ ...column, projectId: source.id })),+ },+ };++ const imported = await templates.import.post({ template: pasted, name: 'Pasted' });+ expect(imported.status).toBe(201);+ const created = await api+ .teams({ teamId })+ .projects.post({ key: 'NEW', name: 'New', templateId: imported.data!.id });+ expect(created.data).toMatchObject({ teamId });+ const columns = (await api.projects({ projectKey: 'NEW' }).get()).data?.columns;+ expect(columns?.map((c) => c.name)).toEqual(doc.snapshot.columns.map((c) => c.name));+ const sourceColumns = (await api.projects({ projectKey: 'SRC' }).get()).data?.columns;+ expect(sourceColumns).toHaveLength(doc.snapshot.columns.length);+ });++ it('is left to the owner and the admins of the workspace', async () => {+ const { api, workspaceId, teamId, templates, doc } = await exported();+ const shared = (await templates.get()).data!.find((t) => t.name === 'Shared')!;+ const manager = await addTeamMember(api, teamId, 'manager');+ const asManager = manager.api.workspaces({ workspaceId })['project-templates'];++ expect((await asManager({ templateId: shared.id }).export.get()).status).toBe(404);+ expect((await asManager.import.preview.post({ template: doc })).status).toBe(404);+ expect((await asManager.import.post({ template: doc, name: 'Mine' })).status).toBe(404);+ });+ });++ describe('gallery', () => {+ // The gallery at itsaplan.dev, answered here: it emails 123456 as every code.+ const realFetch = globalThis.fetch;+ let gallery: {+ down: boolean;+ codes: string[];+ keys: Set<string>;+ author: { name: string; url: string | null };+ pages: Map<string, { template: { name: string } }>;+ };++ beforeEach(() => {+ gallery = {+ down: false,+ codes: [],+ keys: new Set(),+ author: { name: '', url: null },+ pages: new Map(),+ };+ let next = 0;+ globalThis.fetch = (async (input: string | URL | Request, init?: RequestInit) => {+ const url = new URL(input instanceof Request ? input.url : String(input));+ if (url.origin !== 'https://templates.itsaplan.dev') return realFetch(input, init);+ if (gallery.down) throw new TypeError('fetch failed');+ const body = init?.body ? JSON.parse(String(init.body)) : undefined;+ const key = String(new Headers(init?.headers).get('authorization')).slice(7);+ const route = `${init?.method} ${url.pathname.replace(/[A-Za-z0-9]{10}$/, ':id')}`;+ const id = url.pathname.split('/').pop()!;+ const refuse = (status: number, error: string) => Response.json({ error }, { status });+ switch (route) {+ case 'POST /v1/publishers/code':+ gallery.codes.push(body.email);+ return new Response(null, { status: 204 });+ case 'POST /v1/publishers/verify': {+ if (body.code !== '123456') return refuse(400, 'The code is wrong');+ const issued = `tpk_${++next}`;+ gallery.keys.add(issued);+ return Response.json({ key: issued, author: gallery.author });+ }+ }+ if (!gallery.keys.has(key)) return refuse(401, 'Unknown key');+ if (route === 'PUT /v1/publishers/me') {+ gallery.author = { name: body.name, url: body.url ?? null };+ return Response.json({ author: gallery.author });+ }+ if (!gallery.author.name) return refuse(400, 'Name the author before publishing');+ if (route === 'POST /v1/templates') {+ const page = `page${String(++next).padStart(6, '0')}`;+ gallery.pages.set(page, body);+ return Response.json(+ { id: page, url: `https://itsaplan.dev/templates/${page}` },+ { status: 201 },+ );+ }+ if (!gallery.pages.has(id)) return refuse(404, 'Not found');+ if (route === 'PUT /v1/templates/:id') {+ gallery.pages.set(id, body);+ return Response.json({ id, url: `https://itsaplan.dev/templates/${id}` });+ }+ gallery.pages.delete(id);+ return new Response(null, { status: 204 });+ }) as typeof fetch;+ });++ afterEach(() => {+ globalThis.fetch = realFetch;+ });++ // A workspace linked to an address whose author is Ann.+ async function linked() {+ const ctx = await setup();+ const publisher = ctx.api.workspaces({ workspaceId: ctx.workspaceId })['template-publisher'];+ await publisher.code.post({ email: '[email protected]' });+ const link = await publisher.post({ email: '[email protected]', code: '123456' });+ expect(link.status).toBe(200);+ expect((await publisher.author.put({ authorName: 'Ann' })).status).toBe(200);+ return { ...ctx, publisher, one: ctx.templates({ templateId: ctx.template.id }) };+ }++ it('links the workspace with the emailed code', async () => {+ const { api, workspaceId, templates, template } = await setup();+ const publisher = api.workspaces({ workspaceId })['template-publisher'];+ expect((await publisher.get()).data?.publisher).toBeNull();+ const one = templates({ templateId: template.id });+ expect((await one.publication.post()).status).toBe(409);+ expect((await publisher.author.put({ authorName: 'Ann' })).status).toBe(409);++ expect((await publisher.code.post({ email: '[email protected]' })).status).toBe(204);+ expect(gallery.codes).toEqual(['[email protected]']);+ expect((await publisher.code.post({ email: 'not an email' })).status).toBe(400);+ expect((await publisher.post({ email: '[email protected]', code: '000000' })).status).toBe(400);+ expect((await publisher.post({ email: '[email protected]', code: '12ab56' })).status).toBe(400);++ const link = await publisher.post({ email: '[email protected]', code: '123456' });+ expect(link.data).toEqual({ email: '[email protected]', authorName: '', authorUrl: null });+ expect((await publisher.get()).data?.publisher).toMatchObject({ email: '[email protected]' });++ expect((await publisher.delete()).status).toBe(204);+ expect((await publisher.get()).data?.publisher).toBeNull();+ });++ it('names one author for every template of the address', async () => {+ const { api, workspaceId, templates, template } = await setup();+ const publisher = api.workspaces({ workspaceId })['template-publisher'];+ await publisher.code.post({ email: '[email protected]' });+ await publisher.post({ email: '[email protected]', code: '123456' });+ const one = templates({ templateId: template.id });+ expect((await one.publication.post()).status).toBe(409);++ const named = await publisher.author.put({+ authorName: ' Ann ',+ authorUrl: 'https://x.com/ann',+ });+ expect(named.data).toEqual({+ email: '[email protected]',+ authorName: 'Ann',+ authorUrl: 'https://x.com/ann',+ });+ expect(gallery.author).toEqual({ name: 'Ann', url: 'https://x.com/ann' });+ expect((await one.publication.post()).status).toBe(200);++ // Linking the address again shows the author the gallery keeps.+ const relinked = await publisher.post({ email: '[email protected]', code: '123456' });+ expect(relinked.data).toMatchObject({ authorName: 'Ann', authorUrl: 'https://x.com/ann' });+ });++ it('publishes the template without the people it names, and updates its page', async () => {+ const { user, api, source, templates } = await linked();+ await api.projects({ projectKey: 'SRC' }).actions.post({+ name: 'Take',+ effect: { assigneeUserId: user.userId },+ });+ const saved = await templates.post({ projectId: source.id, name: 'Public' });+ const one = templates({ templateId: saved.data!.id });++ const published = await one.publication.post();+ expect(published.status).toBe(200);+ const url = published.data!.url;+ const [page] = [...gallery.pages.values()];+ expect(page).toEqual({+ template: expect.objectContaining({ format: 'itsaplan.project-template', name: 'Public' }),+ });+ expect(JSON.stringify(page)).not.toContain(user.userId);+ const list = (await templates.get()).data!;+ expect(list.find((t) => t.name === 'Public')?.publication).toMatchObject({ url });+ expect(list.find((t) => t.name === 'Kanban')?.publication).toBeNull();++ await one.patch({ name: 'Renamed' });+ const again = await one.publication.post();+ expect(again.data?.url).toBe(url);+ expect(gallery.pages.size).toBe(1);+ expect([...gallery.pages.values()][0]).toMatchObject({ template: { name: 'Renamed' } });+ });++ it('checks the author', async () => {+ const { publisher } = await linked();+ for (const body of [+ { authorName: '' },+ { authorName: ' ' },+ { authorName: 'x'.repeat(81) },+ { authorName: 'Ann', authorUrl: 'http://x.com/ann' },+ ]) {+ expect((await publisher.author.put(body)).status).toBe(400);+ }+ expect((await publisher.author.put({ authorName: 'x'.repeat(80) })).status).toBe(200);+ });++ it('unpublishes, and takes the page down before deleting the template', async () => {+ const { templates, one } = await linked();+ await one.publication.post();+ expect((await one.publication.delete()).status).toBe(204);+ expect(gallery.pages.size).toBe(0);+ expect((await templates.get()).data?.[0].publication).toBeNull();+ expect((await one.publication.delete()).status).toBe(204);++ await one.publication.post();+ gallery.down = true;+ expect((await one.delete()).status).toBe(502);+ expect((await templates.get()).data).toHaveLength(1);+ gallery.down = false;+ expect((await one.delete()).status).toBe(204);+ expect(gallery.pages.size).toBe(0);+ });++ it('publishes again when the gallery no longer holds the page', async () => {+ const { one } = await linked();+ const first = (await one.publication.post()).data!.url;+ gallery.pages.clear();+ const second = await one.publication.post();+ expect(second.data?.url).not.toBe(first);+ expect(gallery.pages.size).toBe(1);+ });++ it('asks to link again once the gallery refuses the key', async () => {+ const { one, publisher } = await linked();+ gallery.keys.clear();+ expect((await one.publication.post()).status).toBe(409);+ expect((await publisher.author.put({ authorName: 'Ann' })).status).toBe(409);+ });++ it('is left to the owner and the admins of the workspace', async () => {+ const { api, workspaceId, teamId, template } = await linked();+ const manager = await addTeamMember(api, teamId, 'manager');+ const theirs = manager.api.workspaces({ workspaceId });++ expect((await theirs['template-publisher'].get()).status).toBe(404);+ expect(+ (await theirs['template-publisher'].code.post({ email: '[email protected]' })).status,+ ).toBe(404);+ expect((await theirs['template-publisher'].delete()).status).toBe(404);+ expect((await theirs['template-publisher'].author.put({ authorName: 'M' })).status).toBe(404);+ const one = theirs['project-templates']({ templateId: template.id });+ expect((await one.publication.post()).status).toBe(404);+ expect((await one.publication.delete()).status).toBe(404);});});describe('delete', () => {it('deletes the template and keeps the projects created from it', async () => {- const { api, teamId, template } = await setup();+ const { api, teamId, templates, template } = await setup();await api.teams({ teamId }).projects.post({ key: 'NEW', name: 'New', templateId: template.id });- const deleted = await api- .teams({ teamId })- ['project-templates']({ templateId: template.id })- .delete();+ const deleted = await templates({ templateId: template.id }).delete();expect(deleted.status).toBe(204);- expect((await api.teams({ teamId })['project-templates'].get()).data).toEqual([]);+ expect((await templates.get()).data).toEqual([]);expect((await api.projects({ projectKey: 'NEW' }).get()).status).toBe(200);});- it('404s for a project, leaving it in place', async () => {- const { api, teamId, source } = await setup();+ it('404s for a template of another workspace, leaving it in place', async () => {+ const { templates } = await setup();+ const other = await setup();- const deleted = await api- .teams({ teamId })- ['project-templates']({ templateId: source.id })- .delete();+ const deleted = await templates({ templateId: other.template.id }).delete();expect(deleted.status).toBe(404);- expect((await api.projects({ projectKey: 'SRC' }).get()).status).toBe(200);- });-- it('goes with its team', async () => {- await signUpTestUser();- const { api } = await signUpClient();- const teamId = await ownTeamId(api);- const project = (await createProject(api, { key: 'OPS', name: 'Operations' })).data!;- await api.teams({ teamId })['project-templates'].post({ projectId: project.id, name: 'Ops' });- await api.teams({ teamId }).projects({ projectId: project.id }).delete();-- expect((await api.teams({ teamId }).delete()).status).toBe(204);+ expect((await other.templates.get()).data?.map((t) => t.id)).toEqual([other.template.id]);});});});diff --git a/apps/api/src/modules/project-templates/index.ts b/apps/api/src/modules/project-templates/index.tsindex 6499c48e..f2ce9437 100644--- a/apps/api/src/modules/project-templates/index.ts+++ b/apps/api/src/modules/project-templates/index.ts@@ -1,26 +1,56 @@import { Elysia, t } from 'elysia';import { noContent } from '#shared/http';-import { guards } from '#shared/guards';+import { assertMcpAllowed, guards } from '#shared/guards';import { errors } from '#shared/responses';import { mcpTool } from '#mcp/generate';import { teamParams } from '#modules/teams/model';+import { workspaceParams } from '#modules/workspaces/model';import {+ ProjectTemplateContentsResponse,ProjectTemplateDetailResponse,ProjectTemplateListResponse,+ TemplatePublicationResponse,+ TemplatePublisherResponse,+ WorkspaceProjectTemplateListResponse,+ previewProjectTemplateBody,ProjectTemplateResponse,- projectTemplateParams,+ importProjectTemplateBody,+ linkPublisherBody,+ publisherCodeBody,+ publisherAuthorBody,+ previewImportedTemplateBody,saveProjectTemplateBody,+ SharedProjectTemplate,+ teamTemplateParams,+ updateProjectTemplateBody,+ workspaceTemplateParams,} from './model';import {deleteProjectTemplate,- getProjectTemplate,- listProjectTemplates,+ getTeamTemplate,+ getWorkspaceTemplate,+ listTeamTemplates,+ listWorkspaceTemplates,+ previewProjectTemplate,+ requireWorkspaceProject,saveProjectTemplate,+ updateProjectTemplate,} from './service';+import {+ getTemplatePublisher,+ linkTemplatePublisher,+ publishTemplate,+ requestPublisherCode,+ setTemplatePublisherAuthor,+ unlinkTemplatePublisher,+ unpublishTemplate,+} from './publish';+import { exportProjectTemplate, importProjectTemplate, previewImportedTemplate } from './share';-// The project templates of a team: saved copies of a project's configuration that new-// projects are created from (POST /teams/:teamId/projects with templateId). They are-// run by the team's owners and managers, who create its projects.+// The project templates of a workspace: snapshots of a project's configuration that new+// projects are created from (POST /teams/:teamId/projects with templateId). The+// workspace's owner and its admins save, edit and delete them. A team's owners and managers,+// who create its projects, read the ones open to their team.export const projectTemplateRoutes = new Elysia({name: 'project-templates',detail: { tags: ['Project Templates'] },@@ -28,76 +58,341 @@ export const projectTemplateRoutes = new Elysia({.use(guards).get(- '/teams/:teamId/project-templates',- ({ membership }) => listProjectTemplates(membership.teamId),+ '/workspaces/:workspaceId/project-templates',+ ({ standing }) => listWorkspaceTemplates(standing.workspaceId),{- teamManager: true,- params: teamParams,- response: { 200: ProjectTemplateListResponse, ...errors(401, 403, 404) },+ workspaceManager: true,+ params: workspaceParams,+ response: { 200: WorkspaceProjectTemplateListResponse, ...errors(400, 401, 404) },detail: {- summary: 'List project templates',+ summary: 'List the project templates of a workspace',description:- 'Every project template of the team, by name. Pass its id as templateId to ' +- 'create_project to create a project from it.',- ...mcpTool('list_project_templates'),+ 'Every project template of the workspace, by name, with the teams it is limited to. ' ++ 'The workspaceId of a team comes from list_teams.',+ ...mcpTool('list_workspace_project_templates'),},},).get(- '/teams/:teamId/project-templates/:templateId',- ({ membership, params }) =>- getProjectTemplate(membership.teamId, params.templateId, membership.userId),+ '/workspaces/:workspaceId/project-templates/:templateId',+ ({ standing, params }) => getWorkspaceTemplate(standing.workspaceId, params.templateId),{- teamManager: true,- params: projectTemplateParams,- response: { 200: ProjectTemplateDetailResponse, ...errors(401, 403, 404) },+ workspaceManager: true,+ params: workspaceTemplateParams,+ response: { 200: ProjectTemplateDetailResponse, ...errors(400, 401, 404) },detail: {- summary: 'Get a project template',+ summary: 'Get a project template of a workspace',description:'What a project template holds: its states, issue types, labels, custom fields, ' +- 'issue templates, views, dashboards, actions, the sections it turns on and its ' +- 'estimates.',- ...mcpTool('get_project_template'),+ 'issue templates, views, dashboards, actions, settings, the sections it turns on ' ++ 'and its estimates.',},},).post(- '/teams/:teamId/project-templates',- async ({ body, membership, set }) => {+ '/workspaces/:workspaceId/project-templates/preview',+ ({ body, standing }) => previewProjectTemplate(standing.workspaceId, body),+ {+ workspaceManager: true,+ params: workspaceParams,+ body: previewProjectTemplateBody,+ response: { 200: ProjectTemplateContentsResponse, ...errors(400, 401, 404) },+ detail: {+ summary: 'Preview a project template',+ description:+ 'What a template saved from the project with this `include` would hold. Saves ' ++ 'nothing.',+ },+ },+ )++ .post(+ '/workspaces/:workspaceId/project-templates',+ async ({ body, standing, set, request }) => {+ await requireWorkspaceProject(standing.workspaceId, body.projectId);+ await assertMcpAllowed(body.projectId, request.headers);set.status = 201;- return saveProjectTemplate(membership.teamId, body, membership.userId);+ return saveProjectTemplate(standing.workspaceId, body);},{- teamManager: true,- params: teamParams,+ workspaceManager: true,+ params: workspaceParams,body: saveProjectTemplateBody,- response: { 201: ProjectTemplateResponse, ...errors(400, 401, 403, 404, 409) },+ response: { 201: ProjectTemplateResponse, ...errors(400, 401, 403, 404) },detail: {summary: 'Save a project as a template',description:- "Save a copy of a team project's configuration, without its issues, as a project " +- 'template. Later changes to the project do not change the template. `include` ' +- 'chooses the sections as for a copy; docs, webhooks, agents and schedules are ' +- 'never saved.',+ 'Save a snapshot of the configuration of a project of the workspace, without its ' ++ 'issues, as a project template. Later changes to the project do not change the ' ++ 'template. `include` chooses the sections as for a copy; docs, webhooks, agents ' ++ 'and schedules are never saved. `teamIds` limits the template to those teams.',+ ...mcpTool('create_project_template'),+ },+ },+ )++ .get(+ '/workspaces/:workspaceId/project-templates/:templateId/export',+ ({ standing, params }) => exportProjectTemplate(standing.workspaceId, params.templateId),+ {+ workspaceManager: true,+ params: workspaceTemplateParams,+ response: { 200: SharedProjectTemplate, ...errors(400, 401, 404) },+ detail: {+ summary: 'Export a project template',+ description:+ 'The template as a document another workspace imports, on this instance or ' ++ 'another one. The people, initiatives and cycles it names, the settings other ' ++ 'than auto-archive and the subtask automations, and the sections an extension ' ++ 'adds are left out. ' ++ 'import_project_template takes it as `template`.',+ ...mcpTool('export_project_template'),+ },+ },+ )++ .get(+ '/workspaces/:workspaceId/template-publisher',+ async ({ standing }) => ({ publisher: await getTemplatePublisher(standing.workspaceId) }),+ {+ workspaceManager: true,+ params: workspaceParams,+ response: {+ 200: t.Object({ publisher: t.Nullable(TemplatePublisherResponse) }),+ ...errors(400, 401, 404),+ },+ detail: {+ summary: 'Get the gallery publisher of a workspace',+ description:+ 'The address the workspace publishes its project templates to the gallery at ' ++ 'itsaplan.dev under, and the author the gallery shows for it. `publisher` is null ' ++ 'while the workspace is not linked.',+ },+ },+ )++ .post(+ '/workspaces/:workspaceId/template-publisher/code',+ async ({ body }) => {+ await requestPublisherCode(body.email);+ return noContent();+ },+ {+ workspaceManager: true,+ params: workspaceParams,+ body: publisherCodeBody,+ response: { 204: t.Void(), ...errors(400, 401, 403, 404, 429, 502) },+ detail: {+ summary: 'Email a gallery code',+ description:+ 'The gallery at itsaplan.dev emails a code to the address. Linking the workspace ' ++ 'with it confirms that the address is the caller’s.',+ },+ },+ )++ .post(+ '/workspaces/:workspaceId/template-publisher',+ ({ standing, body }) => linkTemplatePublisher(standing.workspaceId, body),+ {+ workspaceManager: true,+ params: workspaceParams,+ body: linkPublisherBody,+ response: { 200: TemplatePublisherResponse, ...errors(400, 401, 403, 404, 429, 502) },+ detail: {+ summary: 'Link a workspace to the gallery',+ description:+ 'Confirms the address with the code the gallery emailed and links the workspace to ' ++ 'it. Every manager of the workspace then publishes under that address.',+ },+ },+ )++ .put(+ '/workspaces/:workspaceId/template-publisher/author',+ ({ standing, body }) => setTemplatePublisherAuthor(standing.workspaceId, body),+ {+ workspaceManager: true,+ params: workspaceParams,+ body: publisherAuthorBody,+ response: { 200: TemplatePublisherResponse, ...errors(400, 401, 403, 404, 409, 429, 502) },+ detail: {+ summary: 'Set the gallery author of a workspace',+ description:+ 'The name and the profile link the gallery shows on every template published ' ++ 'from the linked address, including those already published.',},},).delete(- '/teams/:teamId/project-templates/:templateId',- async ({ membership, params }) => {- await deleteProjectTemplate(membership.teamId, params.templateId);+ '/workspaces/:workspaceId/template-publisher',+ async ({ standing }) => {+ await unlinkTemplatePublisher(standing.workspaceId);return noContent();},{- teamManager: true,- params: projectTemplateParams,- response: { 204: t.Void(), ...errors(401, 403, 404) },+ workspaceManager: true,+ params: workspaceParams,+ response: { 204: t.Void(), ...errors(400, 401, 404) },+ detail: {+ summary: 'Unlink a workspace from the gallery',+ description:+ 'The published templates stay in the gallery. Linking the same address again ' ++ 'manages them. Until then they cannot be unpublished, and the templates they ' ++ 'came from cannot be deleted.',+ },+ },+ )++ .post(+ '/workspaces/:workspaceId/project-templates/:templateId/publication',+ ({ standing, params }) => publishTemplate(standing.workspaceId, params.templateId),+ {+ workspaceManager: true,+ params: workspaceTemplateParams,+ response: {+ 200: TemplatePublicationResponse,+ ...errors(400, 401, 403, 404, 409, 413, 429, 502),+ },+ detail: {+ summary: 'Publish a project template',+ description:+ 'Publishes what an export of the template holds to the gallery at itsaplan.dev, ' ++ 'or updates the page it already has. Anyone can read and download it there. The ' ++ 'workspace must be linked to the gallery, with an author named.',+ },+ },+ )++ .delete(+ '/workspaces/:workspaceId/project-templates/:templateId/publication',+ async ({ standing, params }) => {+ await unpublishTemplate(standing.workspaceId, params.templateId);+ return noContent();+ },+ {+ workspaceManager: true,+ params: workspaceTemplateParams,+ response: { 204: t.Void(), ...errors(400, 401, 403, 404, 409, 429, 502) },+ detail: { summary: 'Unpublish a project template' },+ },+ )++ .post(+ '/workspaces/:workspaceId/project-templates/import/preview',+ ({ body }) => previewImportedTemplate(body.template),+ {+ workspaceManager: true,+ params: workspaceParams,+ body: previewImportedTemplateBody,+ response: { 200: ProjectTemplateContentsResponse, ...errors(400, 401, 404) },+ detail: {+ summary: 'Preview an exported project template',+ description:+ 'Checks an exported template and answers with what it would hold once imported. ' ++ 'Saves nothing.',+ },+ },+ )++ .post(+ '/workspaces/:workspaceId/project-templates/import',+ async ({ body, standing, set }) => {+ set.status = 201;+ return importProjectTemplate(standing.workspaceId, body);+ },+ {+ workspaceManager: true,+ params: workspaceParams,+ body: importProjectTemplateBody,+ response: { 201: ProjectTemplateResponse, ...errors(400, 401, 404) },+ detail: {+ summary: 'Import a project template',+ description:+ 'Save an exported template as a template of the workspace, under the `name` and ' ++ '`description` given here. `teamIds` limits it to those teams. The people, ' ++ 'initiatives and cycles it names are dropped.',+ ...mcpTool('import_project_template'),+ },+ },+ )++ .patch(+ '/workspaces/:workspaceId/project-templates/:templateId',+ ({ body, standing, params }) =>+ updateProjectTemplate(standing.workspaceId, params.templateId, body),+ {+ workspaceManager: true,+ params: workspaceTemplateParams,+ body: updateProjectTemplateBody,+ response: { 200: ProjectTemplateResponse, ...errors(400, 401, 404) },+ detail: {+ summary: 'Update a project template',+ description:+ 'Rename a project template, change its description or the teams it is open to. ' ++ 'What it holds stays as saved. `teamIds` null opens it to every team of the ' ++ 'workspace.',+ ...mcpTool('update_project_template'),+ },+ },+ )++ .delete(+ '/workspaces/:workspaceId/project-templates/:templateId',+ async ({ standing, params }) => {+ await unpublishTemplate(standing.workspaceId, params.templateId);+ await deleteProjectTemplate(standing.workspaceId, params.templateId);+ return noContent();+ },+ {+ workspaceManager: true,+ params: workspaceTemplateParams,+ response: { 204: t.Void(), ...errors(400, 401, 403, 404, 409, 429, 502) },detail: {summary: 'Delete a project template',- description: 'Delete a project template. Projects created from it are not changed.',+ description:+ 'Delete a project template, after taking its page in the gallery down. Projects ' ++ 'created from it are not changed. A published template is deleted only while the ' ++ 'workspace is linked to the gallery and the gallery answers.',+ ...mcpTool('delete_project_template', { openWorldHint: true }),+ },+ },+ )++ .get(+ '/teams/:teamId/project-templates',+ ({ membership }) => listTeamTemplates(membership.teamId),+ {+ teamManager: true,+ params: teamParams,+ response: { 200: ProjectTemplateListResponse, ...errors(401, 403, 404) },+ detail: {+ summary: 'List the project templates of a team',+ description:+ "The project templates of the team's workspace open to the team, by name. Pass " ++ 'its id as templateId to create_project to create a project from it.',+ ...mcpTool('list_project_templates'),+ },+ },+ )++ .get(+ '/teams/:teamId/project-templates/:templateId',+ ({ membership, params }) => getTeamTemplate(membership.teamId, params.templateId),+ {+ teamManager: true,+ params: teamTemplateParams,+ response: { 200: ProjectTemplateDetailResponse, ...errors(400, 401, 403, 404) },+ detail: {+ summary: 'Get a project template',+ description:+ 'What a project template open to the team holds: its states, issue types, labels, ' ++ 'custom fields, issue templates, views, dashboards, actions, settings, the ' ++ 'sections it turns on and its estimates.',+ ...mcpTool('get_project_template'),},},);diff --git a/apps/api/src/modules/project-templates/model.ts b/apps/api/src/modules/project-templates/model.tsindex 7e8b5980..8d9a7660 100644--- a/apps/api/src/modules/project-templates/model.ts+++ b/apps/api/src/modules/project-templates/model.ts@@ -1,56 +1,350 @@import { t } from 'elysia';+import { stateType } from '#modules/columns/model';+import { fieldType, memberScope } from '#modules/custom-fields/model';import {copyInclude,EstimatesResponse,FeaturesResponse,PROJECT_DESCRIPTION_LIMIT,+ updateAutoArchiveBody,+ updateSubtaskAutomationBody,} from '#modules/projects/model';-import { ColumnResponse } from '#modules/columns/model';-import { IssueTypeResponse } from '#modules/issue-types/model';-import { LabelGroupResponse, LabelResponse } from '#modules/labels/model';-import { CustomFieldResponse } from '#modules/custom-fields/model';-import { IssueTemplateListResponse } from '#modules/issue-templates/model';-import { ViewResponse } from '#modules/views/model';-import { DashboardListResponse } from '#modules/dashboards/model';-import { ActionListResponse } from '#modules/actions/model';-export const projectTemplateParams = t.Object({ teamId: t.Numeric(), templateId: t.Numeric() });+export const workspaceTemplateParams = t.Object({+ workspaceId: t.Numeric(),+ templateId: t.Numeric(),+});++export const teamTemplateParams = t.Object({ teamId: t.Numeric(), templateId: t.Numeric() });export const saveProjectTemplateBody = t.Object({- projectId: t.Integer({ description: 'The project of the team to save as a template.' }),+ projectId: t.Integer({+ description: 'A project of a team of the workspace to save as a template.',+ }),name: t.String({ minLength: 1 }),description: t.Optional(t.String({ maxLength: PROJECT_DESCRIPTION_LIMIT })),include: copyInclude,+ teamIds: t.Optional(+ t.Array(t.Integer(), {+ minItems: 1,+ description:+ 'The teams of the workspace the template is limited to. Omitted, every team of the ' ++ 'workspace sees it.',+ }),+ ),});+export const previewProjectTemplateBody = t.Pick(saveProjectTemplateBody, ['projectId', 'include']);++export const updateProjectTemplateBody = t.Partial(+ t.Object({+ name: t.String({ minLength: 1 }),+ description: t.String({ maxLength: PROJECT_DESCRIPTION_LIMIT }),+ teamIds: t.Nullable(+ t.Array(t.Integer(), {+ minItems: 1,+ description:+ 'The teams of the workspace the template is limited to, or null to open it to ' ++ 'every team of the workspace.',+ }),+ ),+ }),+ { minProperties: 1 },+);+export const ProjectTemplateResponse = t.Object({id: t.Number(),name: t.String(),description: t.String(),+ teamIds: t.Nullable(+ t.Array(t.Number(), {+ description:+ 'The teams the template is limited to, null when every team of the workspace sees it.',+ }),+ ),createdAt: t.String(),});export const ProjectTemplateListResponse = t.Array(ProjectTemplateResponse);-export const ProjectTemplateDetailResponse = t.Composite([- ProjectTemplateResponse,- t.Object({- columns: t.Array(ColumnResponse),- issueTypes: t.Array(IssueTypeResponse),- labels: t.Array(LabelResponse),- labelGroups: t.Array(LabelGroupResponse),- customFields: t.Array(CustomFieldResponse),- issueTemplates: IssueTemplateListResponse,- views: t.Array(ViewResponse),- dashboards: DashboardListResponse,- actions: ActionListResponse,- features: FeaturesResponse,- estimates: EstimatesResponse,- sections: t.Array(- t.Object(- { key: t.String(), items: t.Array(t.String()) },- { description: 'What a section an extension of the api added holds, by name.' },+export const TemplatePublicationResponse = t.Object({+ url: t.String(),+ publishedAt: t.String({ format: 'date-time' }),+});++export const WorkspaceProjectTemplateListResponse = t.Array(+ t.Composite([+ ProjectTemplateResponse,+ t.Object({+ publication: t.Nullable(TemplatePublicationResponse, {+ description: 'The page of the template in the gallery, null while it is not published.',+ }),+ }),+ ]),+);++// What a template holds. The states, issue types, label groups, labels, fields and options+// carry an id, which the other parts reference them by: the row id in the project the+// template was saved from, or the number an imported template gave them.+export const ProjectTemplateContentsResponse = t.Object({+ columns: t.Array(+ t.Object({+ id: t.Number(),+ name: t.String(),+ stateType: t.String(),+ color: t.String(),+ position: t.Number(),+ wipLimit: t.Nullable(t.Number()),+ wipMode: t.String(),+ }),+ ),+ issueTypes: t.Array(+ t.Object({+ id: t.Number(),+ name: t.String(),+ icon: t.String(),+ color: t.String(),+ isDefault: t.Boolean(),+ position: t.Number(),+ }),+ ),+ labelGroups: t.Array(t.Object({ id: t.Number(), name: t.String(), color: t.String() })),+ labels: t.Array(+ t.Object({+ id: t.Number(),+ groupId: t.Nullable(t.Number()),+ name: t.String(),+ color: t.String(),+ }),+ ),+ customFields: t.Array(+ t.Object({+ id: t.Number(),+ issueTypeId: t.Nullable(t.Number()),+ name: t.String(),+ fieldType: t.String(),+ memberScope: t.Nullable(t.String()),+ showInBody: t.Boolean(),+ position: t.Number(),+ options: t.Array(+ t.Object({ id: t.Number(), value: t.String(), color: t.String(), position: t.Number() }),),+ }),+ ),+ issueTemplates: t.Array(+ t.Object({+ name: t.String(),+ description: t.String(),+ titleTemplate: t.String(),+ descriptionTemplate: t.String(),+ typeId: t.Nullable(t.Number()),+ columnId: t.Nullable(t.Number()),+ priority: t.Nullable(t.String()),+ labelIds: t.Array(t.Number()),+ }),+ ),+ views: t.Array(+ t.Object({+ name: t.String(),+ icon: t.Nullable(t.String()),+ filters: t.Any(),+ display: t.Any(),+ position: t.Number(),+ }),+ ),+ dashboards: t.Array(+ t.Object({+ name: t.String(),+ icon: t.Nullable(t.String()),+ layout: t.Any(),+ position: t.Number(),+ }),+ ),+ actions: t.Array(+ t.Object({+ name: t.String(),+ icon: t.String(),+ condition: t.Any(),+ effect: t.Any(),+ position: t.Number(),+ }),+ ),+ settings: t.Array(t.Object({ key: t.String(), value: t.Any() })),+ features: FeaturesResponse,+ estimates: EstimatesResponse,+ sections: t.Array(+ t.Object(+ { key: t.String(), items: t.Array(t.String()) },+ { description: 'What a section an extension of the api added holds, by name.' },),+ ),+});++export const ProjectTemplateDetailResponse = t.Composite([+ ProjectTemplateResponse,+ ProjectTemplateContentsResponse,+]);++// A shared template is pasted from outside, so every object is closed: a key it does not+// list is dropped and never reaches the insert of the row it sits in.+const strict = <T extends Parameters<typeof t.Object>[0]>(properties: T) =>+ t.Object(properties, { additionalProperties: false });++const entityId = t.Integer();+const entityName = t.String({ minLength: 1 });++// The settings a shared template carries, each checked as its own route checks it.+const sharedSetting = t.Union([+ strict({ key: t.Literal('auto_archive'), value: strict(updateAutoArchiveBody.properties) }),+ strict({+ key: t.Literal('subtask_automation'),+ value: strict(updateSubtaskAutomationBody.properties),}),]);++const sharedSnapshot = strict({+ flags: strict({+ initiativesEnabled: t.Boolean(),+ dashboardsEnabled: t.Boolean(),+ documentsEnabled: t.Boolean(),+ notesEnabled: t.Boolean(),+ cyclesEnabled: t.Boolean(),+ subtasksEnabled: t.Boolean(),+ checklistsEnabled: t.Boolean(),+ issueStatsEnabled: t.Boolean(),+ pointsEstimateEnabled: t.Boolean(),+ timeEstimateEnabled: t.Boolean(),+ timeLoggingEnabled: t.Boolean(),+ }),+ columns: t.Array(+ strict({+ id: entityId,+ name: entityName,+ stateType,+ color: t.String(),+ position: t.Integer(),+ wipLimit: t.Nullable(t.Integer({ minimum: 1 })),+ wipMode: t.Union([t.Literal('soft'), t.Literal('hard')]),+ }),+ ),+ issueTypes: t.Array(+ strict({+ id: entityId,+ name: entityName,+ icon: t.String(),+ color: t.String(),+ isDefault: t.Boolean(),+ position: t.Integer(),+ }),+ ),+ labelGroups: t.Array(strict({ id: entityId, name: entityName, color: t.String() })),+ labels: t.Array(+ strict({ id: entityId, groupId: t.Nullable(entityId), name: entityName, color: t.String() }),+ ),+ customFields: t.Array(+ strict({+ id: entityId,+ issueTypeId: t.Nullable(entityId),+ name: entityName,+ fieldType,+ memberScope: t.Nullable(memberScope),+ showInBody: t.Boolean(),+ position: t.Integer(),+ options: t.Array(+ strict({ id: entityId, value: entityName, color: t.String(), position: t.Integer() }),+ ),+ }),+ ),+ issueTemplates: t.Array(+ strict({+ name: entityName,+ description: t.String(),+ titleTemplate: t.String(),+ descriptionTemplate: t.String(),+ typeId: t.Nullable(entityId),+ columnId: t.Nullable(entityId),+ priority: t.Nullable(t.String()),+ labelIds: t.Array(entityId),+ }),+ ),+ // The filter, display, layout, condition and effect blobs are the UI's, stored as the+ // view, dashboard and action routes store them.+ views: t.Array(+ strict({+ name: entityName,+ icon: t.Nullable(t.String()),+ filters: t.Any(),+ display: t.Any(),+ position: t.Number(),+ }),+ ),+ dashboards: t.Array(+ strict({+ name: entityName,+ icon: t.Nullable(t.String()),+ layout: t.Array(t.Unknown()),+ position: t.Number(),+ }),+ ),+ actions: t.Array(+ strict({+ name: entityName,+ icon: t.String(),+ condition: t.Any(),+ effect: t.Any(),+ position: t.Number(),+ }),+ ),+ settings: t.Array(sharedSetting),+});++export const SharedProjectTemplate = strict({+ format: t.Literal('itsaplan.project-template'),+ version: t.Literal(1),+ name: t.String(),+ description: t.String(),+ snapshot: sharedSnapshot,+});++export const previewImportedTemplateBody = t.Object({ template: SharedProjectTemplate });++export const importProjectTemplateBody = t.Object({+ template: SharedProjectTemplate,+ name: saveProjectTemplateBody.properties.name,+ description: saveProjectTemplateBody.properties.description,+ teamIds: saveProjectTemplateBody.properties.teamIds,+});++const publisherEmail = t.String({ format: 'email', maxLength: 200 });++export const publisherCodeBody = t.Object({ email: publisherEmail });++export const linkPublisherBody = t.Object({+ email: publisherEmail,+ code: t.String({ pattern: '^[0-9]{6}$', description: 'The code the gallery emailed.' }),+});++export const TemplatePublisherResponse = t.Object({+ email: t.String(),+ authorName: t.String(),+ authorUrl: t.Nullable(t.String()),+});++export const publisherAuthorBody = t.Object({+ authorName: t.String({+ minLength: 1,+ maxLength: 80,+ pattern: '\\S',+ description: 'Shown as the author of every template the address publishes.',+ }),+ authorUrl: t.Optional(+ t.Nullable(+ t.String({+ format: 'uri',+ pattern: '^https://',+ maxLength: 200,+ description: "A link to the author's profile, shown beside the name.",+ }),+ ),+ ),+});diff --git a/apps/api/src/modules/project-templates/publish.ts b/apps/api/src/modules/project-templates/publish.tsnew file mode 100644index 00000000..78ab66c4--- /dev/null+++ b/apps/api/src/modules/project-templates/publish.ts@@ -0,0 +1,220 @@+import { db, projectTemplate, templatePublisher } from '@repo/db';+import { decryptSecret, encryptSecret } from '@repo/crypto';+import { eq } from 'drizzle-orm';+import { HttpError, iso } from '#shared/lib';+import { requireWorkspaceTemplate } from './service';+import { sharedTemplate } from './share';++// The gallery at itsaplan.dev that a workspace publishes its project templates to. A+// workspace links to it once, with a code the gallery emails to the address it names;+// after that every manager of the workspace publishes with the key the link stored. The+// gallery keeps one author per address and shows it on every template from it; the+// workspace keeps a copy to show in its dialogs.+// Fixed, like the telemetry endpoint: every instance publishes to the one gallery.+const GALLERY_URL = 'https://templates.itsaplan.dev';+const TIMEOUT_MS = 10_000;++export interface TemplatePublisher {+ email: string;+ authorName: string;+ authorUrl: string | null;+}++export interface TemplatePublication {+ url: string;+ publishedAt: string;+}++class GalleryRefusal extends Error {+ constructor(+ readonly status: number,+ message: string,+ ) {+ super(message);+ }+}++async function gallery<T>(+ method: string,+ path: string,+ options: { body?: unknown; key?: string } = {},+): Promise<T> {+ let response: Response;+ try {+ response = await fetch(`${GALLERY_URL}${path}`, {+ method,+ headers: {+ 'content-type': 'application/json',+ ...(options.key && { authorization: `Bearer ${options.key}` }),+ },+ body: options.body === undefined ? undefined : JSON.stringify(options.body),+ signal: AbortSignal.timeout(TIMEOUT_MS),+ });+ } catch {+ throw new HttpError(502, 'The template gallery did not answer. Try again later.');+ }+ if (response.ok) {+ return (response.status === 204 ? undefined : await response.json()) as T;+ }+ const body = (await response.json().catch(() => null)) as { error?: unknown } | null;+ const message =+ typeof body?.error === 'string' ? body.error : 'The template gallery refused the request';+ throw new GalleryRefusal(response.status, message);+}++// What the gallery refused, as this api answers it: a wrong code, a blocked address, too+// many tries or a template too large are the caller's to fix; a key it no longer takes+// means linking again; anything else is the gallery's failure.+function answer(refusal: unknown): never {+ if (!(refusal instanceof GalleryRefusal)) throw refusal;+ switch (refusal.status) {+ case 400:+ case 403:+ case 429:+ throw new HttpError(refusal.status, refusal.message);+ case 413:+ throw new HttpError(413, 'The template is too large for the gallery');+ case 401:+ throw new HttpError(+ 409,+ 'The gallery no longer accepts the key of this workspace. Link the workspace again.',+ );+ default:+ throw new HttpError(502, `The template gallery failed: ${refusal.message}`);+ }+}++async function readPublisher(workspaceId: number) {+ const [row] = await db+ .select()+ .from(templatePublisher)+ .where(eq(templatePublisher.workspaceId, workspaceId));+ return row ?? null;+}++function publisherKey(row: typeof templatePublisher.$inferSelect): string {+ return decryptSecret({ ciphertext: row.keyCiphertext, iv: row.keyIv, authTag: row.keyAuthTag });+}++function publisherDto(row: typeof templatePublisher.$inferSelect): TemplatePublisher {+ return { email: row.email, authorName: row.authorName, authorUrl: row.authorUrl };+}++export async function getTemplatePublisher(workspaceId: number): Promise<TemplatePublisher | null> {+ const row = await readPublisher(workspaceId);+ return row && publisherDto(row);+}++export async function requestPublisherCode(email: string): Promise<void> {+ await gallery<void>('POST', '/v1/publishers/code', { body: { email } }).catch(answer);+}++type GalleryAuthor = { name: string; url: string | null };++// Links the workspace to the gallery publisher of the address the code confirms. A+// workspace already linked moves to the new address.+export async function linkTemplatePublisher(+ workspaceId: number,+ input: { email: string; code: string },+): Promise<TemplatePublisher> {+ const { key, author } = await gallery<{ key: string; author: GalleryAuthor }>(+ 'POST',+ '/v1/publishers/verify',+ { body: input },+ ).catch(answer);+ const enc = encryptSecret(key);+ const values = {+ email: input.email.trim().toLowerCase(),+ keyCiphertext: enc.ciphertext,+ keyIv: enc.iv,+ keyAuthTag: enc.authTag,+ authorName: author.name,+ authorUrl: author.url,+ };+ const [row] = await db+ .insert(templatePublisher)+ .values({ workspaceId, ...values })+ .onConflictDoUpdate({ target: templatePublisher.workspaceId, set: values })+ .returning();+ return publisherDto(row);+}++// Forgets the link. The templates it published stay in the gallery; linking the same+// address again manages them.+export async function unlinkTemplatePublisher(workspaceId: number): Promise<void> {+ await db.delete(templatePublisher).where(eq(templatePublisher.workspaceId, workspaceId));+}++async function requireKey(workspaceId: number) {+ const publisher = await readPublisher(workspaceId);+ if (!publisher) throw new HttpError(409, 'Link the workspace to the template gallery first');+ return { publisher, key: publisherKey(publisher) };+}++// Sets the author every template of the linked address shows in the gallery.+export async function setTemplatePublisherAuthor(+ workspaceId: number,+ input: { authorName: string; authorUrl?: string | null },+): Promise<TemplatePublisher> {+ const { key } = await requireKey(workspaceId);+ const url = input.authorUrl?.trim();+ const { author } = await gallery<{ author: GalleryAuthor }>('PUT', '/v1/publishers/me', {+ body: { name: input.authorName.trim(), ...(url && { url }) },+ key,+ }).catch(answer);+ const [row] = await db+ .update(templatePublisher)+ .set({ authorName: author.name, authorUrl: author.url })+ .where(eq(templatePublisher.workspaceId, workspaceId))+ .returning();+ if (!row) throw new HttpError(409, 'Link the workspace to the template gallery first');+ return publisherDto(row);+}++// Publishes the template as an export holds it, or updates the page it already has.+// A page the gallery no longer holds is published again under a new address.+export async function publishTemplate(+ workspaceId: number,+ templateId: number,+): Promise<TemplatePublication> {+ const row = await requireWorkspaceTemplate(workspaceId, templateId);+ const { publisher, key } = await requireKey(workspaceId);+ if (!publisher.authorName) {+ throw new HttpError(409, 'Name the author of the gallery address first');+ }+ const body = { template: sharedTemplate(row) };+ type Published = { id: string; url: string };+ const update = row.publicationId+ ? await gallery<Published>('PUT', `/v1/templates/${row.publicationId}`, { body, key }).catch(+ (refusal: unknown) => {+ if (refusal instanceof GalleryRefusal && refusal.status === 404) return null;+ return answer(refusal);+ },+ )+ : null;+ const published =+ update ?? (await gallery<Published>('POST', '/v1/templates', { body, key }).catch(answer));+ const publishedAt = new Date();+ await db+ .update(projectTemplate)+ .set({ publicationId: published.id, publicationUrl: published.url, publishedAt })+ .where(eq(projectTemplate.id, templateId));+ return { url: published.url, publishedAt: iso(publishedAt) };+}++// Takes the template's page down. A page the gallery no longer holds counts as taken down.+export async function unpublishTemplate(workspaceId: number, templateId: number): Promise<void> {+ const row = await requireWorkspaceTemplate(workspaceId, templateId);+ if (!row.publicationId) return;+ const { key } = await requireKey(workspaceId);+ await gallery<void>('DELETE', `/v1/templates/${row.publicationId}`, { key }).catch(+ (refusal: unknown) => {+ if (refusal instanceof GalleryRefusal && refusal.status === 404) return;+ answer(refusal);+ },+ );+ await db+ .update(projectTemplate)+ .set({ publicationId: null, publicationUrl: null, publishedAt: null })+ .where(eq(projectTemplate.id, templateId));+}diff --git a/apps/api/src/modules/project-templates/service.ts b/apps/api/src/modules/project-templates/service.tsindex 5a0d6b3a..23a4a101 100644--- a/apps/api/src/modules/project-templates/service.ts+++ b/apps/api/src/modules/project-templates/service.ts@@ -1,190 +1,300 @@-import { db, project } from '@repo/db';-import { and, asc, eq } from 'drizzle-orm';+import { db, project, projectTemplate, projectTemplateTeam, team, teamWorkspaceId } from '@repo/db';+import { and, asc, eq, inArray, or, sql, type SQL } from 'drizzle-orm';import { HttpError, iso } from '#shared/lib';-import { copyIncludeKeys, copyProject } from '#modules/projects/copy';+import { getProjectDefaults } from '#modules/settings/service';+import {+ insertSnapshotProject,+ readTemplateSnapshot,+ type ProjectSnapshot,+} from '#modules/projects/copy';import { copySections } from '#modules/projects/copy-extension';import {- deleteProject,- getProjectById,+ defaultAgentMembers,projectFeatures,+ targetTeam,+ type EstimateSettings,type ProjectFeatures,type ProjectRow,} from '#modules/projects/service';-import { teamOwnsProject } from '#modules/teams/service';-import { listColumns, type ColumnRow } from '#modules/columns/service';-import { listIssueTypes, type IssueTypeRow } from '#modules/issue-types/service';-import {- listLabelGroups,- listLabels,- type LabelGroupRow,- type LabelRow,-} from '#modules/labels/service';-import { listCustomFields, type CustomFieldRow } from '#modules/custom-fields/service';-import { listIssueTemplates, type IssueTemplateRow } from '#modules/issue-templates/service';-import { listViews, type UserViewRow } from '#modules/views/service';-import { listDashboards, type DashboardRow } from '#modules/dashboards/service';-import { listActions, type ActionRow } from '#modules/actions/service';export interface ProjectTemplate {id: number;name: string;description: string;+ // Null when every team of the workspace sees it.+ teamIds: number[] | null;createdAt: string;}-export async function listProjectTemplates(teamId: number): Promise<ProjectTemplate[]> {- const rows = await db- .select({- id: project.id,- name: project.name,- description: project.description,- createdAt: project.createdAt,- })+type TemplateRow = typeof projectTemplate.$inferSelect;++async function withTeams(rows: TemplateRow[]): Promise<ProjectTemplate[]> {+ const limited = rows.filter((row) => !row.allTeams).map((row) => row.id);+ const links = limited.length+ ? await db+ .select()+ .from(projectTemplateTeam)+ .where(inArray(projectTemplateTeam.templateId, limited))+ : [];+ return rows.map((row) => ({+ id: row.id,+ name: row.name,+ description: row.description,+ teamIds: row.allTeams+ ? null+ : links.filter((link) => link.templateId === row.id).map((link) => link.teamId),+ createdAt: iso(row.createdAt),+ }));+}++// The templates of the team's workspace that the team sees.+async function teamTemplatesWhere(teamId: number): Promise<SQL> {+ return and(+ eq(projectTemplate.workspaceId, await teamWorkspaceId(teamId, db)),+ or(+ eq(projectTemplate.allTeams, true),+ sql`exists (select 1 from ${projectTemplateTeam} where ${projectTemplateTeam.templateId} = ${projectTemplate.id} and ${projectTemplateTeam.teamId} = ${teamId})`,+ ),+ )!;+}++async function readTemplates(where: SQL): Promise<TemplateRow[]> {+ return db+ .select()+ .from(projectTemplate)+ .where(where)+ .orderBy(asc(projectTemplate.name), asc(projectTemplate.id));+}++// A template of the workspace with its page in the gallery, null while it is not published.+export interface WorkspaceProjectTemplate extends ProjectTemplate {+ publication: { url: string; publishedAt: string } | null;+}++export async function listWorkspaceTemplates(+ workspaceId: number,+): Promise<WorkspaceProjectTemplate[]> {+ const rows = await readTemplates(eq(projectTemplate.workspaceId, workspaceId));+ const templates = await withTeams(rows);+ return templates.map((template, index) => {+ const { publicationUrl, publishedAt } = rows[index];+ return {+ ...template,+ publication:+ publicationUrl && publishedAt+ ? { url: publicationUrl, publishedAt: iso(publishedAt) }+ : null,+ };+ });+}++export async function listTeamTemplates(teamId: number): Promise<ProjectTemplate[]> {+ return withTeams(await readTemplates(await teamTemplatesWhere(teamId)));+}++async function requireTemplate(where: SQL, templateId: number): Promise<TemplateRow> {+ const [row] = await readTemplates(and(where, eq(projectTemplate.id, templateId))!);+ if (!row) throw new HttpError(404, 'Project template not found');+ return row;+}++export function requireWorkspaceTemplate(+ workspaceId: number,+ templateId: number,+): Promise<TemplateRow> {+ return requireTemplate(eq(projectTemplate.workspaceId, workspaceId), templateId);+}++// What a template holds: the project sections and the estimates its flags turn on, and what+// each extension section holds.+export interface ProjectTemplateContents extends Omit<ProjectSnapshot, 'flags' | 'sections'> {+ features: ProjectFeatures;+ estimates: EstimateSettings;+ sections: { key: string; items: string[] }[];+}++export type ProjectTemplateDetail = ProjectTemplate & ProjectTemplateContents;++export function templateContents(snapshot: ProjectSnapshot): ProjectTemplateContents {+ const { flags, sections, ...parts } = snapshot;+ return {+ ...parts,+ features: projectFeatures(flags),+ estimates: {+ points: flags.pointsEstimateEnabled,+ time: flags.timeEstimateEnabled,+ logging: flags.timeLoggingEnabled,+ },+ sections: copySections()+ .filter((section) => section.key in sections)+ .map((section) => ({ key: section.key, items: section.contents(sections[section.key]) })),+ };+}++async function templateDetail(row: TemplateRow): Promise<ProjectTemplateDetail> {+ const [template] = await withTeams([row]);+ return { ...template, ...templateContents(row.snapshot as ProjectSnapshot) };+}++export async function getWorkspaceTemplate(+ workspaceId: number,+ templateId: number,+): Promise<ProjectTemplateDetail> {+ return templateDetail(await requireWorkspaceTemplate(workspaceId, templateId));+}++export async function getTeamTemplate(+ teamId: number,+ templateId: number,+): Promise<ProjectTemplateDetail> {+ return templateDetail(await requireTemplate(await teamTemplatesWhere(teamId), templateId));+}++async function assertWorkspaceTeams(workspaceId: number, teamIds: number[]): Promise<void> {+ const teams = await db+ .select({ id: team.id })+ .from(team)+ .where(and(eq(team.workspaceId, workspaceId), inArray(team.id, teamIds)));+ if (teams.length !== teamIds.length) {+ throw new HttpError(400, 'Team not found in this workspace');+ }+}++export async function requireWorkspaceProject(+ workspaceId: number,+ projectId: number,+): Promise<void> {+ const [source] = await db+ .select({ workspaceId: team.workspaceId }).from(project)- .where(and(eq(project.teamId, teamId), eq(project.isTemplate, true)))- .orderBy(asc(project.name), asc(project.id));- return rows.map((row) => ({ ...row, createdAt: iso(row.createdAt) }));+ .innerJoin(team, eq(team.id, project.teamId))+ .where(eq(project.id, projectId));+ if (source?.workspaceId !== workspaceId) throw new HttpError(404, 'Project not found');}-// A template is a project, so it takes a key unique in its team. Nobody sees the key,-// so it is random; the leading letter keeps it a valid project key.-function templateKey(): string {- return `T${crypto.randomUUID().replaceAll('-', '').slice(0, 9).toUpperCase()}`;+// What a template saved from the project with this selection would hold.+export async function previewProjectTemplate(+ workspaceId: number,+ input: { projectId: number; include?: Record<string, boolean | undefined> },+): Promise<ProjectTemplateContents> {+ await requireWorkspaceProject(workspaceId, input.projectId);+ return templateContents(await readTemplateSnapshot(input.projectId, input.include));}-// Saves a copy of the project's configuration as a template. Later changes to the-// project do not reach the template.+// Saves a snapshot of the project's configuration as a template of the workspace. Later+// changes to the project do not reach the template.export async function saveProjectTemplate(- teamId: number,+ workspaceId: number,input: {projectId: number;name: string;description?: string;include?: Record<string, boolean | undefined>;+ teamIds?: number[];},- userId: string,): Promise<ProjectTemplate> {- if (!(await teamOwnsProject(teamId, input.projectId))) {- throw new HttpError(404, 'Project not found');- }- const saved = await copyProject(- input.projectId,- { key: templateKey(), name: input.name, description: input.description },- userId,- teamId,- input.include,- { template: true },+ await requireWorkspaceProject(workspaceId, input.projectId);+ return createTemplate(+ workspaceId,+ input,+ await readTemplateSnapshot(input.projectId, input.include),);- return {- id: saved.id,- name: saved.name,- description: saved.description,- createdAt: saved.createdAt,- };}-// What a template holds, read the way a project's own settings read it.-export interface ProjectTemplateDetail extends ProjectTemplate {- columns: ColumnRow[];- issueTypes: IssueTypeRow[];- labels: LabelRow[];- labelGroups: LabelGroupRow[];- customFields: CustomFieldRow[];- issueTemplates: IssueTemplateRow[];- views: UserViewRow[];- dashboards: DashboardRow[];- actions: ActionRow[];- features: ProjectFeatures;- estimates: { points: boolean; time: boolean; logging: boolean };- sections: { key: string; items: string[] }[];+// Stores the snapshot as a template of the workspace, open to the teams named or, without+// them, to every team of it.+export async function createTemplate(+ workspaceId: number,+ input: { name: string; description?: string; teamIds?: number[] },+ snapshot: ProjectSnapshot,+): Promise<ProjectTemplate> {+ const teamIds = input.teamIds && [...new Set(input.teamIds)];+ if (teamIds) await assertWorkspaceTeams(workspaceId, teamIds);+ const row = await db.transaction(async (tx) => {+ const [created] = await tx+ .insert(projectTemplate)+ .values({+ workspaceId,+ name: input.name,+ description: input.description ?? '',+ snapshot,+ allTeams: !teamIds,+ })+ .returning();+ if (teamIds) {+ await tx+ .insert(projectTemplateTeam)+ .values(teamIds.map((teamId) => ({ templateId: created.id, teamId })));+ }+ return created;+ });+ const [template] = await withTeams([row]);+ return template;}-export async function getProjectTemplate(- teamId: number,+// Changes the name, the description and the teams of a template. What it holds stays as+// saved. `teamIds` null opens it to every team of the workspace.+export async function updateProjectTemplate(+ workspaceId: number,templateId: number,- userId: string,-): Promise<ProjectTemplateDetail> {- await requireTemplate(teamId, templateId);- const [- found,- columns,- issueTypes,- labels,- labelGroups,- customFields,- issueTemplates,- views,- dashboards,- actions,- sections,- ] = await Promise.all([- getProjectById(templateId),- listColumns(templateId),- listIssueTypes(templateId),- listLabels(templateId),- listLabelGroups(templateId),- listCustomFields(templateId, { allTypes: true }),- listIssueTemplates(templateId),- listViews(templateId, userId),- listDashboards(templateId),- listActions(templateId),- Promise.all(- copySections()- .filter((section) => section.template)- .map(async (section) => ({- key: section.key,- items: await section.contents(templateId),- })),- ),- ]);- const template = found!;- return {- id: template.id,- name: template.name,- description: template.description,- createdAt: template.createdAt,- columns,- issueTypes,- labels,- labelGroups,- customFields,- issueTemplates,- views,- dashboards,- actions,- features: projectFeatures(template),- estimates: {- points: template.pointsEstimateEnabled,- time: template.timeEstimateEnabled,- logging: template.timeLoggingEnabled,- },- sections,- };+ input: { name?: string; description?: string; teamIds?: number[] | null },+): Promise<ProjectTemplate> {+ await requireWorkspaceTemplate(workspaceId, templateId);+ const teamIds = input.teamIds && [...new Set(input.teamIds)];+ if (teamIds) await assertWorkspaceTeams(workspaceId, teamIds);+ const row = await db.transaction(async (tx) => {+ const [updated] = await tx+ .update(projectTemplate)+ .set({+ name: input.name,+ description: input.description,+ ...(teamIds !== undefined && { allTeams: teamIds === null }),+ })+ .where(eq(projectTemplate.id, templateId))+ .returning();+ if (teamIds !== undefined) {+ await tx.delete(projectTemplateTeam).where(eq(projectTemplateTeam.templateId, templateId));+ if (teamIds) {+ await tx+ .insert(projectTemplateTeam)+ .values(teamIds.map((teamId) => ({ templateId, teamId })));+ }+ }+ return updated;+ });+ const [template] = await withTeams([row]);+ return template;}-async function requireTemplate(teamId: number, templateId: number): Promise<void> {- const [row] = await db- .select({ id: project.id })- .from(project)- .where(- and(eq(project.id, templateId), eq(project.teamId, teamId), eq(project.isTemplate, true)),- );- if (!row) throw new HttpError(404, 'Project template not found');+export async function deleteProjectTemplate(+ workspaceId: number,+ templateId: number,+): Promise<void> {+ await requireWorkspaceTemplate(workspaceId, templateId);+ await db.delete(projectTemplate).where(eq(projectTemplate.id, templateId));}+// A project of the team that starts with what the template holds and with the team's+// default agents, as a created project does.export async function createProjectFromTemplate(teamId: number,templateId: number,input: { key: string; name: string; description?: string },userId: string,): Promise<ProjectRow> {- await requireTemplate(teamId, templateId);- // A template holds only what was chosen when it was saved, so the project takes all of it.- const everything = Object.fromEntries(copyIncludeKeys().map((key) => [key, true]));- return copyProject(templateId, input, userId, teamId, everything, { defaultAgents: true });-}--export async function deleteProjectTemplate(teamId: number, templateId: number): Promise<void> {- await requireTemplate(teamId, templateId);- await deleteProject(templateId);+ const row = await requireTemplate(await teamTemplatesWhere(teamId), templateId);+ const ownerTeam = await targetTeam(userId, teamId);+ const defaults = await getProjectDefaults();+ const agentMembers = await defaultAgentMembers(ownerTeam);+ const { project } = await db.transaction((tx) =>+ insertSnapshotProject(tx, row.snapshot as ProjectSnapshot, {+ team: ownerTeam,+ input,+ ownerId: userId,+ mcpEnabled: defaults.mcpEnabled,+ agentMembers,+ sameTeam: false,+ }),+ );+ return project;}diff --git a/apps/api/src/modules/project-templates/share.ts b/apps/api/src/modules/project-templates/share.tsnew file mode 100644index 00000000..262455a4--- /dev/null+++ b/apps/api/src/modules/project-templates/share.ts@@ -0,0 +1,214 @@+import type { projectTemplate } from '@repo/db';+import { HttpError } from '#shared/lib';+import type { CopyIdMaps, ProjectSnapshot } from '#modules/projects/copy';+import {+ mapDisplay,+ mapEffect,+ mapFilters,+ mapLayout,+ type References,+} from '#modules/projects/references';+import type { SharedProjectTemplate as SharedProjectTemplateSchema } from './model';+import {+ createTemplate,+ requireWorkspaceTemplate,+ templateContents,+ type ProjectTemplate,+ type ProjectTemplateContents,+} from './service';++// A template copied out of one workspace to be imported into another, on this instance or+// another one. Its parts are numbered 1, 2, 3 in each kind, so the ids of the rows they+// were read from stay behind. So do the people, the initiatives and the cycles a project+// names: the project made from it has none of them. It carries no section an extension+// adds either, since nothing here checks what such a section holds.+export type SharedProjectTemplate = typeof SharedProjectTemplateSchema.static;+type SharedSnapshot = SharedProjectTemplate['snapshot'];++const SHARED_SETTING_KEYS = new Set(['auto_archive', 'subtask_automation']);++type Kind = Exclude<keyof CopyIdMaps, 'fieldType'>;++const KIND_NAMES: Record<Kind, string> = {+ column: 'state',+ type: 'issue type',+ labelGroup: 'label group',+ label: 'label',+ field: 'field',+ option: 'field option',+};++// An option's id is unique among the options of every field.+function partIds(snapshot: SharedSnapshot): Record<Kind, number[]> {+ const ids = (rows: { id: number }[]) => rows.map((row) => row.id);+ return {+ column: ids(snapshot.columns),+ type: ids(snapshot.issueTypes),+ labelGroup: ids(snapshot.labelGroups),+ label: ids(snapshot.labels),+ field: ids(snapshot.customFields),+ option: ids(snapshot.customFields.flatMap((field) => field.options)),+ };+}++// Gives every part of the snapshot the id resolve returns for it, and every reference+// between them too, or drops a reference resolve returns undefined for.+function relink(+ snapshot: SharedSnapshot,+ resolve: (kind: Kind, id: number) => number | undefined,+): SharedSnapshot {+ const own = (kind: Kind, id: number) => resolve(kind, id)!;+ const ref = (kind: Kind, id: number | null) => (id == null ? null : (resolve(kind, id) ?? null));+ const fieldTypes = new Map(snapshot.customFields.map((field) => [field.id, field.fieldType]));+ const refs: References = {+ map: (kind, id) =>+ kind === 'person' || kind === 'initiative' || kind === 'cycle'+ ? undefined+ : resolve(kind, id as number),+ fieldType: (id) => fieldTypes.get(id),+ };+ return {+ ...snapshot,+ columns: snapshot.columns.map((column) => ({ ...column, id: own('column', column.id) })),+ issueTypes: snapshot.issueTypes.map((type) => ({ ...type, id: own('type', type.id) })),+ labelGroups: snapshot.labelGroups.map((group) => ({+ ...group,+ id: own('labelGroup', group.id),+ })),+ labels: snapshot.labels.map((label) => ({+ ...label,+ id: own('label', label.id),+ groupId: ref('labelGroup', label.groupId),+ })),+ customFields: snapshot.customFields.map((field) => ({+ ...field,+ id: own('field', field.id),+ issueTypeId: ref('type', field.issueTypeId),+ options: field.options.map((option) => ({ ...option, id: own('option', option.id) })),+ })),+ issueTemplates: snapshot.issueTemplates.map((tpl) => ({+ ...tpl,+ typeId: ref('type', tpl.typeId),+ columnId: ref('column', tpl.columnId),+ labelIds: tpl.labelIds.flatMap((id) => resolve('label', id) ?? []),+ })),+ views: snapshot.views.map((view) => ({+ ...view,+ filters: mapFilters(view.filters, refs),+ display: mapDisplay(view.display, refs),+ })),+ dashboards: snapshot.dashboards.map((dashboard) => ({+ ...dashboard,+ layout: mapLayout(dashboard.layout, refs),+ })),+ actions: snapshot.actions.map((action) => ({+ ...action,+ condition: mapFilters(action.condition, refs),+ effect: mapEffect(action.effect, refs),+ })),+ };+}++export async function exportProjectTemplate(+ workspaceId: number,+ templateId: number,+): Promise<SharedProjectTemplate> {+ return sharedTemplate(await requireWorkspaceTemplate(workspaceId, templateId));+}++export function sharedTemplate(row: typeof projectTemplate.$inferSelect): SharedProjectTemplate {+ const { sections: _, settings, ...snapshot } = row.snapshot as ProjectSnapshot;+ // Read back as readProjectSnapshot wrote it, which the shared schema describes.+ const read = {+ ...snapshot,+ settings: settings.filter((setting) => SHARED_SETTING_KEYS.has(setting.key)),+ } as SharedSnapshot;+ // A part's number is its place in its kind.+ const numbers = Object.fromEntries(+ Object.entries(partIds(read)).map(([kind, ids]) => [+ kind,+ new Map(ids.map((id, index) => [id, index + 1])),+ ]),+ ) as Record<Kind, Map<number, number>>;+ return {+ format: 'itsaplan.project-template',+ version: 1,+ name: row.name,+ description: row.description,+ snapshot: relink(read, (kind, id) => numbers[kind].get(id)),+ };+}++function assertUnique(values: unknown[], what: string): void {+ if (new Set(values).size !== values.length) throw new HttpError(400, `${what} must be unique`);+}++// The schema checks each value; this checks what the rows of one project must hold+// together, before the template is stored and projects are created from it.+function importedSnapshot(template: SharedProjectTemplate): ProjectSnapshot {+ const { snapshot } = template;+ assertUnique(+ snapshot.columns.map((column) => column.position),+ 'Column positions',+ );+ assertUnique(+ snapshot.issueTypes.map((type) => type.name),+ 'Issue type names',+ );+ assertUnique(+ snapshot.labelGroups.map((group) => group.name),+ 'Label group names',+ );+ assertUnique(+ snapshot.labels.map((label) => label.name),+ 'Label names',+ );+ assertUnique(+ snapshot.issueTemplates.map((tpl) => tpl.name),+ 'Issue template names',+ );+ for (const tpl of snapshot.issueTemplates) assertUnique(tpl.labelIds, 'Issue template labels');+ assertUnique(+ snapshot.settings.map((setting) => setting.key),+ 'Setting keys',+ );+ for (const field of snapshot.customFields) {+ if ((field.fieldType === 'member') !== (field.memberScope !== null)) {+ throw new HttpError(400, 'Only a member field has a member scope');+ }+ assertUnique(+ field.options.map((option) => option.value),+ 'Option values',+ );+ }+ if (snapshot.issueTypes.filter((type) => type.isDefault).length > 1) {+ throw new HttpError(400, 'Only one issue type can be the default');+ }+ const ids = partIds(snapshot);+ const known = {} as Record<Kind, Set<number>>;+ for (const kind of Object.keys(ids) as Kind[]) {+ assertUnique(ids[kind], `The ${KIND_NAMES[kind]} ids`);+ known[kind] = new Set(ids[kind]);+ }+ const relinked = relink(snapshot, (kind, id) => {+ if (known[kind].has(id)) return id;+ throw new HttpError(400, `The template has no ${KIND_NAMES[kind]} ${id}`);+ });+ return { ...relinked, sections: {} };+}++export function previewImportedTemplate(template: SharedProjectTemplate): ProjectTemplateContents {+ return templateContents(importedSnapshot(template));+}++export function importProjectTemplate(+ workspaceId: number,+ input: {+ template: SharedProjectTemplate;+ name: string;+ description?: string;+ teamIds?: number[];+ },+): Promise<ProjectTemplate> {+ return createTemplate(workspaceId, input, importedSnapshot(input.template));+}diff --git a/apps/api/src/modules/projects/__tests__/integration/copy-extension.test.ts b/apps/api/src/modules/projects/__tests__/integration/copy-extension.test.tsindex 031b26cc..ed067ca8 100644--- a/apps/api/src/modules/projects/__tests__/integration/copy-extension.test.ts+++ b/apps/api/src/modules/projects/__tests__/integration/copy-extension.test.ts@@ -9,33 +9,43 @@ import {type CopySectionContext,} from '#modules/projects/copy-extension';-let calls: CopySectionContext[] = [];+let reads: number[] = [];+let applies: { context: CopySectionContext; data: unknown }[] = [];-// A section that records each run and adds a label to the copy inside its transaction,-// named after how many labels the copy re-created before it.+// A section that holds the id of the project it was read from, and adds a label to the new+// project inside its transaction, named after how many labels were re-created before it.function section(overrides: Partial<CopySection> = {}): CopySection {return {key: 'extra',requires: ['labels'],template: true,- copy: async (context) => {- calls.push(context);+ read: async (projectId) => {+ reads.push(projectId);+ return { from: projectId };+ },+ apply: async (context, data) => {+ applies.push({ context, data });await context.tx.insert(label).values({ projectId: context.projectId, name: `extra ${context.maps.label.size}` });},- contents: async (projectId) => [`held by ${projectId}`],+ contents: (data) => [`held from ${(data as { from: number }).from}`],...overrides,};}// The project SRC with the label "bug".-async function setup(): Promise<{ api: Api; teamId: number; sourceId: number }> {+async function setup(): Promise<{+ api: Api;+ teamId: number;+ workspaceId: number;+ sourceId: number;+}> {const user = await signUpTestUser();const api = authedApi(user.cookie);const source = (await createProject(api, { key: 'SRC', name: 'Source' })).data!;await api.projects({ projectKey: 'SRC' }).labels.post({ name: 'bug', color: '#ff0000' });- return { api, teamId: source.teamId, sourceId: source.id };+ return { api, teamId: source.teamId, workspaceId: user.workspaceId!, sourceId: source.id };}async function labelNames(api: Api, projectKey: string) {@@ -45,12 +55,13 @@ async function labelNames(api: Api, projectKey: string) {describe('copy sections of an extension', () => {beforeEach(async () => {await resetDb();- calls = [];+ reads = [];+ applies = [];});afterEach(() => setCopySections());it('copies a selected section with what it requires', async () => {- const { api } = await setup();+ const { api, sourceId } = await setup();setCopySections([section()]);const copied = await api@@ -59,7 +70,9 @@ describe('copy sections of an extension', () => {expect(copied.status).toBe(201);expect(await labelNames(api, 'DST')).toEqual(['bug', 'extra 1']);- expect(calls).toMatchObject([{ template: false, sameTeam: true }]);+ expect(applies).toMatchObject([+ { context: { projectId: copied.data!.id, sameTeam: true }, data: { from: sourceId } },+ ]);});it('leaves a section out unless it is selected', async () => {@@ -71,37 +84,42 @@ describe('copy sections of an extension', () => {.copy.post({ key: 'DST', name: 'Destination', include: { labels: true } });expect(await labelNames(api, 'DST')).toEqual(['bug']);- expect(calls).toHaveLength(0);+ expect(reads).toHaveLength(0);+ expect(applies).toHaveLength(0);});- it('saves a section into a template and copies it into a project made from it', async () => {- const { api, teamId, sourceId } = await setup();+ it('saves a section into a template and applies it to a project made from it', async () => {+ const { api, teamId, workspaceId, sourceId } = await setup();setCopySections([section()]);const saved = await api- .teams({ teamId })+ .workspaces({ workspaceId })['project-templates'].post({ projectId: sourceId, name: 'Kanban', include: { extra: true } });- await api+ const created = await api.teams({ teamId }).projects.post({ key: 'NEW', name: 'New', templateId: saved.data!.id });- expect(calls.map((call) => call.template)).toEqual([true, false]);+ expect(reads).toEqual([sourceId]);+ expect(applies).toMatchObject([+ { context: { projectId: created.data!.id, sameTeam: false }, data: { from: sourceId } },+ ]);+ expect(await labelNames(api, 'NEW')).toEqual(['bug', 'extra 1']);const detail = await api.teams({ teamId })['project-templates']({ templateId: saved.data!.id }).get();- expect(detail.data?.sections).toEqual([{ key: 'extra', items: [`held by ${saved.data!.id}`] }]);+ expect(detail.data?.sections).toEqual([{ key: 'extra', items: [`held from ${sourceId}`] }]);});it('leaves a section a template does not carry out of the template', async () => {- const { api, teamId, sourceId } = await setup();+ const { api, workspaceId, sourceId } = await setup();setCopySections([section({ template: false })]);await api- .teams({ teamId })+ .workspaces({ workspaceId })['project-templates'].post({ projectId: sourceId, name: 'Kanban', include: { extra: true } });- expect(calls).toHaveLength(0);+ expect(reads).toHaveLength(0);});it('refuses a key the core or another section uses', () => {diff --git a/apps/api/src/modules/projects/copy-extension.ts b/apps/api/src/modules/projects/copy-extension.tsindex 10b2d99b..92cbb647 100644--- a/apps/api/src/modules/projects/copy-extension.ts+++ b/apps/api/src/modules/projects/copy-extension.ts@@ -3,27 +3,27 @@ import { COPY_INCLUDE_KEYS, type CopyIdMaps } from './copy';export interface CopySectionContext {tx: DbExecutor;- sourceProjectId: number;projectId: number;ownerId: string;- // Old → new ids of what the copy re-created before the section runs.+ // Old → new ids of what the snapshot re-created before the section runs.maps: CopyIdMaps;- // The copy is a project template.- template: boolean;- // The copy stays in the source project's team.+ // The new project is in the team of the project the snapshot was read from. Always+ // false for a project template, which belongs to the workspace.sameTeam: boolean;}// A part of a project an extension of the api adds to a project copy and to a project// template: the include key that selects it, the keys it needs copied with it, whether a-// template carries it, the copy itself, run inside the copy's transaction, and the names-// of what it holds in a project, which a template's detail lists.+// template carries it, what it holds in a project (stored in the snapshot as JSON), how+// that is written into a new project inside the transaction that creates it, and the names of+// what it holds, which a template's detail lists.export interface CopySection {key: string;requires: string[];template: boolean;- copy(context: CopySectionContext): Promise<void>;- contents(projectId: number): Promise<string[]>;+ read(projectId: number): Promise<unknown>;+ apply(context: CopySectionContext, data: unknown): Promise<void>;+ contents(data: unknown): string[];}let sections: CopySection[] = [];diff --git a/apps/api/src/modules/projects/copy.ts b/apps/api/src/modules/projects/copy.tsindex aee11c01..4789e555 100644--- a/apps/api/src/modules/projects/copy.ts+++ b/apps/api/src/modules/projects/copy.ts@@ -17,17 +17,18 @@ import {projectAction,webhook,projectSetting,+ type DbExecutor,} from '@repo/db';-import { and, eq, inArray, or } from 'drizzle-orm';+import { and, eq, inArray, ne, or } from 'drizzle-orm';import { HttpError } from '#shared/lib';import {DEFAULT_COLUMNS,- defaultAgentMembers,getProjectById,joinTeamAsCreator,mapProject,targetTeam,type ProjectRow,+ type TargetTeam,} from './service';import { GIT_SETTING_KEY } from '#modules/git/service';import { getProjectDefaults } from '#modules/settings/service';@@ -45,6 +46,7 @@ import {} from '#modules/attachments/storage';import { assertValidDocumentContentJson, replaceAssetReferences } from '#modules/documents/service';import { copySections } from './copy-extension';+import { mapDisplay, mapEffect, mapFilters, mapLayout, type References } from './references';// Which parts of a source project the copy carries over. A key set false skips that// entity, and a section an extension adds (copy-extension.ts) has a key of its own.@@ -87,11 +89,6 @@ export const COPY_INCLUDE_KEYS: (keyof CopyProjectInclude)[] = [type Include = CopyProjectInclude & Record<string, boolean>;-// The core's keys and those of the sections an extension added.-export function copyIncludeKeys(): string[] {- return [...COPY_INCLUDE_KEYS, ...copySections().map((section) => section.key)];-}-// What a project template never carries: the agents and their schedules work in a// project, a webhook delivers one project's events, and docs are its content.const NOT_IN_TEMPLATE: (keyof CopyProjectInclude)[] = [@@ -155,7 +152,8 @@ function normalizeInclude(}// Old id → new id maps built while copying, used to rewrite the id references that-// views and actions hold in their filters.+// views, actions and dashboards hold. fieldType is the type of each field of the+// snapshot, by its old id.export interface CopyIdMaps {column: Map<number, number>;labelGroup: Map<number, number>;@@ -163,117 +161,302 @@ export interface CopyIdMaps {type: Map<number, number>;field: Map<number, number>;option: Map<number, number>;+ fieldType: Map<number, string>;}-// Returns the mapped id for a numeric value present in the map; any other value-// passes through unchanged.-function remapId(map: Map<number, number>, v: unknown): unknown {- return typeof v === 'number' && map.has(v) ? map.get(v) : v;+// People stay, since the copy is on the same instance. A reference the copy has no new+// row for (an initiative, a cycle, a deleted state) keeps its old id, which no row of the+// new project has, so a condition on it still matches no issue rather than every one.+function copyReferences(maps: CopyIdMaps): References {+ return {+ map: (kind, id) => {+ if (kind === 'person' || kind === 'initiative' || kind === 'cycle') return id;+ return maps[kind].get(id as number) ?? id;+ },+ fieldType: (id) => maps.fieldType.get(id),+ };}-// Rewrites the entity ids a view's filter set references so they point at the copied-// project's entities. The display blob's ids (hiddenGroups) are remapped separately-// by remapViewDisplay.-//-// The filter shape is owned by the UI: a FilterSet is { conditions: [{ field, op,-// values }] }. Which map a condition's numeric values use is decided by its field:-// status → column, type → type, labels → label, cf:<fieldId> → the field id is-// remapped in the key, and select values are option ids, so they use the option map.-// Non-numeric values (priority/statusType strings, assignee user ids, dates,-// custom-field text) are left as-is. Values whose id is absent from the map are kept-// unchanged.+// A filter set an extension copies with the project, such as a schedule's conditions.export function remapViewFilters(filters: unknown, maps: CopyIdMaps): unknown {- if (!filters || typeof filters !== 'object') return filters;- const conditions = (filters as { conditions?: unknown }).conditions;- if (!Array.isArray(conditions)) return filters;-- const newConditions = conditions.map((cond: Record<string, unknown>) => {- if (!cond || typeof cond !== 'object') return cond;- const field: unknown = cond.field;- let newField = field;- let valueMap: Map<number, number> | null = null;-- if (field === 'status') valueMap = maps.column;- else if (field === 'type') valueMap = maps.type;- else if (field === 'labels') valueMap = maps.label;- else if (typeof field === 'string' && field.startsWith('cf:')) {- const newFieldId = maps.field.get(Number(field.slice(3)));- if (newFieldId != null) newField = `cf:${newFieldId}`;- valueMap = maps.option;- }+ return mapFilters(filters, copyReferences(maps));+}- const values =- valueMap && Array.isArray(cond.values)- ? cond.values.map((v: unknown) => remapId(valueMap!, v))- : cond.values;- return { ...cond, field: newField, values };- });+// The project flags a copy carries: the optional sections the project shows, the+// estimate kinds its issues carry and whether time is logged. mcpEnabled is not among+// them: a new project enters its team's MCP reach on the instance default, the same way a+// created one does.+const PROJECT_FLAGS = {+ initiativesEnabled: project.initiativesEnabled,+ dashboardsEnabled: project.dashboardsEnabled,+ documentsEnabled: project.documentsEnabled,+ notesEnabled: project.notesEnabled,+ cyclesEnabled: project.cyclesEnabled,+ subtasksEnabled: project.subtasksEnabled,+ checklistsEnabled: project.checklistsEnabled,+ issueStatsEnabled: project.issueStatsEnabled,+ pointsEstimateEnabled: project.pointsEstimateEnabled,+ timeEstimateEnabled: project.timeEstimateEnabled,+ timeLoggingEnabled: project.timeLoggingEnabled,+};- return { ...(filters as object), conditions: newConditions };+type Row<T extends { $inferSelect: object }, K extends keyof T['$inferSelect']> = Pick<+ T['$inferSelect'],+ K+>;++// A project's configuration without its issues: what a copy carries over and what a+// project template stores as jsonb. The states, types, label groups, labels, fields and+// options keep the id they were read with, the row's own or the number an imported+// template gives them, because the other parts reference them by it (a field's issue type,+// a view's filters, an action's effect). applyProjectSnapshot maps the ids to the new rows.+// A part the selection left out is empty.+export interface ProjectSnapshot {+ flags: { [K in keyof typeof PROJECT_FLAGS]: boolean };+ columns: Row<+ typeof projectColumn,+ 'id' | 'name' | 'stateType' | 'color' | 'position' | 'wipLimit' | 'wipMode'+ >[];+ issueTypes: Row<typeof issueType, 'id' | 'name' | 'icon' | 'color' | 'isDefault' | 'position'>[];+ labelGroups: Row<typeof labelGroup, 'id' | 'name' | 'color'>[];+ labels: Row<typeof label, 'id' | 'groupId' | 'name' | 'color'>[];+ customFields: (Row<+ typeof customField,+ 'id' | 'issueTypeId' | 'name' | 'fieldType' | 'memberScope' | 'showInBody' | 'position'+ > & { options: Row<typeof customFieldOption, 'id' | 'value' | 'color' | 'position'>[] })[];+ issueTemplates: (Row<+ typeof issueTemplate,+ | 'name'+ | 'description'+ | 'titleTemplate'+ | 'descriptionTemplate'+ | 'typeId'+ | 'columnId'+ | 'priority'+ > & { labelIds: number[] })[];+ views: Row<typeof projectView, 'name' | 'icon' | 'filters' | 'display' | 'position'>[];+ dashboards: Row<typeof projectDashboard, 'name' | 'icon' | 'layout' | 'position'>[];+ actions: Row<typeof projectAction, 'name' | 'icon' | 'condition' | 'effect' | 'position'>[];+ settings: Row<typeof projectSetting, 'key' | 'value'>[];+ // What each section an extension adds holds, by its key.+ sections: Record<string, unknown>;}-// Remaps one work items group key to the copied project's entities. Group keys are-// namespaced by grouping field: c<columnId> and t<typeId> carry a numeric id and are-// remapped; a<userId> (assignee), p<priority>, the *-none buckets and 'all' carry no-// project-scoped numeric id and pass through.-function remapGroupKey(key: string, maps: CopyIdMaps): string {- const m = /^([ct])(\d+)$/.exec(key);- if (!m) return key;- const id = Number(m[2]);- const map = m[1] === 'c' ? maps.column : maps.type;- const newId = map.get(id);- return newId != null ? `${m[1]}${newId}` : key;-}+async function readProjectSnapshot(projectId: number, inc: Include): Promise<ProjectSnapshot> {+ const [+ [flags],+ columns,+ issueTypes,+ labelGroups,+ labels,+ fields,+ issueTemplates,+ views,+ dashboards,+ actions,+ settings,+ ] = await Promise.all([+ db.select(PROJECT_FLAGS).from(project).where(eq(project.id, projectId)),+ // autoAssignUserId is left out: a member of the source project need not be a member+ // of the new one.+ inc.states+ ? db+ .select({+ id: projectColumn.id,+ name: projectColumn.name,+ stateType: projectColumn.stateType,+ color: projectColumn.color,+ position: projectColumn.position,+ wipLimit: projectColumn.wipLimit,+ wipMode: projectColumn.wipMode,+ })+ .from(projectColumn)+ .where(eq(projectColumn.projectId, projectId))+ .orderBy(projectColumn.position)+ : [],+ inc.issueTypes+ ? db+ .select({+ id: issueType.id,+ name: issueType.name,+ icon: issueType.icon,+ color: issueType.color,+ isDefault: issueType.isDefault,+ position: issueType.position,+ })+ .from(issueType)+ .where(eq(issueType.projectId, projectId))+ .orderBy(issueType.position)+ : [],+ inc.labels+ ? db+ .select({ id: labelGroup.id, name: labelGroup.name, color: labelGroup.color })+ .from(labelGroup)+ .where(eq(labelGroup.projectId, projectId))+ : [],+ inc.labels+ ? db+ .select({ id: label.id, groupId: label.groupId, name: label.name, color: label.color })+ .from(label)+ .where(eq(label.projectId, projectId))+ : [],+ inc.customFields+ ? db+ .select({+ id: customField.id,+ issueTypeId: customField.issueTypeId,+ name: customField.name,+ fieldType: customField.fieldType,+ memberScope: customField.memberScope,+ showInBody: customField.showInBody,+ position: customField.position,+ })+ .from(customField)+ .where(eq(customField.projectId, projectId))+ .orderBy(customField.position)+ : [],+ // The assignee is left out, as a column's auto-assignee is.+ inc.issueTemplates+ ? db+ .select({+ id: issueTemplate.id,+ name: issueTemplate.name,+ description: issueTemplate.description,+ titleTemplate: issueTemplate.titleTemplate,+ descriptionTemplate: issueTemplate.descriptionTemplate,+ typeId: issueTemplate.typeId,+ columnId: issueTemplate.columnId,+ priority: issueTemplate.priority,+ })+ .from(issueTemplate)+ .where(eq(issueTemplate.projectId, projectId))+ .orderBy(issueTemplate.id)+ : [],+ // A private view is its owner's alone and stays behind.+ inc.views+ ? db+ .select({+ name: projectView.name,+ icon: projectView.icon,+ filters: projectView.filters,+ display: projectView.display,+ position: projectView.position,+ })+ .from(projectView)+ .where(and(eq(projectView.projectId, projectId), eq(projectView.isPrivate, false)))+ .orderBy(projectView.position, projectView.id)+ : [],+ inc.dashboards+ ? db+ .select({+ name: projectDashboard.name,+ icon: projectDashboard.icon,+ layout: projectDashboard.layout,+ position: projectDashboard.position,+ })+ .from(projectDashboard)+ .where(eq(projectDashboard.projectId, projectId))+ .orderBy(projectDashboard.position, projectDashboard.id)+ : [],+ inc.actions+ ? db+ .select({+ name: projectAction.name,+ icon: projectAction.icon,+ condition: projectAction.condition,+ effect: projectAction.effect,+ position: projectAction.position,+ })+ .from(projectAction)+ .where(eq(projectAction.projectId, projectId))+ .orderBy(projectAction.position, projectAction.id)+ : [],+ // The repository integration is left out: its value holds the webhook secret and+ // routing id (the copy's owner must not receive the source's credential, and a+ // duplicated id would make inbound routing ambiguous) plus column ids of the source+ // project. The copy starts unconfigured instead.+ inc.configuration+ ? db+ .select({ key: projectSetting.key, value: projectSetting.value })+ .from(projectSetting)+ .where(+ and(eq(projectSetting.projectId, projectId), ne(projectSetting.key, GIT_SETTING_KEY)),+ )+ : [],+ ]);+ if (!flags) throw new HttpError(404, 'Project not found');++ const fieldIds = fields.map((field) => field.id);+ const options = fieldIds.length+ ? await db+ .select({+ id: customFieldOption.id,+ fieldId: customFieldOption.fieldId,+ value: customFieldOption.value,+ color: customFieldOption.color,+ position: customFieldOption.position,+ })+ .from(customFieldOption)+ .where(inArray(customFieldOption.fieldId, fieldIds))+ .orderBy(customFieldOption.position)+ : [];+ const templateIds = issueTemplates.map((tpl) => tpl.id);+ const templateLabels = templateIds.length+ ? await db+ .select({ templateId: issueTemplateLabel.templateId, labelId: issueTemplateLabel.labelId })+ .from(issueTemplateLabel)+ .where(inArray(issueTemplateLabel.templateId, templateIds))+ : [];++ const sections = await Promise.all(+ copySections()+ .filter((section) => inc[section.key])+ .map(async (section) => [section.key, await section.read(projectId)] as const),+ );-// Rewrites the id-bearing parts of a view's display blob. Only hiddenGroups holds ids-// (group keys of the flat work items view's hidden columns); the rest of the display-// (layout, sort, group/subgroup, properties) is field-kind enums, copied as-is.-function remapViewDisplay(display: unknown, maps: CopyIdMaps): unknown {- if (!display || typeof display !== 'object') return display;- const hidden = (display as { hiddenGroups?: unknown }).hiddenGroups;- if (!Array.isArray(hidden)) return display;return {- ...(display as object),- hiddenGroups: hidden.map((k: unknown) => (typeof k === 'string' ? remapGroupKey(k, maps) : k)),+ flags,+ columns,+ issueTypes,+ labelGroups,+ labels,+ customFields: fields.map((field) => ({+ ...field,+ options: options+ .filter((option) => option.fieldId === field.id)+ .map(({ fieldId: _, ...option }) => option),+ })),+ issueTemplates: issueTemplates.map(({ id, ...tpl }) => ({+ ...tpl,+ labelIds: templateLabels.filter((row) => row.templateId === id).map((row) => row.labelId),+ })),+ views,+ dashboards,+ actions,+ settings,+ sections: Object.fromEntries(sections),};}-// Rewrites the entity ids an action's effect holds so they point at the copied-// project's entities. The effect is a partial issue patch; columnId/typeId and each-// labelId are remapped, while assigneeUserId (a global user id), priority and dates-// are left as-is.-function remapActionEffect(effect: unknown, maps: CopyIdMaps): unknown {- if (!effect || typeof effect !== 'object') return effect;- const src = effect as Record<string, unknown>;- const out: Record<string, unknown> = { ...src };- if ('columnId' in src) out.columnId = remapId(maps.column, src.columnId);- if ('typeId' in src) out.typeId = remapId(maps.type, src.typeId);- if (Array.isArray(src.labelIds)) out.labelIds = src.labelIds.map((v) => remapId(maps.label, v));- return out;-}--// Creates a new project that copies the selected parts of the source project's-// configuration, but none of its issues. The creator becomes the new project's owner.-// With `template` the copy is a project template instead: it has no members, and it-// leaves out what a template never carries. With `defaultAgents` the copy starts with the-// team's default agents, as a created project does.-//-// Pure-database entities (states, types, labels, custom fields, views, dashboards,-// documents, actions, settings, webhooks) are copied in one transaction, recording-// old id → new id so the ids that views and actions reference are remapped to the-// copied entities. A document's assets are cloned in the object store inside that-// transaction and removed again if it rolls back. The team's agents are attached to-// the new project after it commits, through the same service function the UI uses.-export async function copyProject(- sourceProjectId: number,- input: { key: string; name: string; description?: string },- ownerId: string,- teamId: number,+// The configuration a project template stores: the selected parts of the project, less+// what a template never carries.+export function readTemplateSnapshot(+ projectId: number,rawInclude?: Record<string, boolean | undefined>,- { template = false, defaultAgents = false }: { template?: boolean; defaultAgents?: boolean } = {},-): Promise<ProjectRow> {- const inc = normalizeInclude(rawInclude, template);+): Promise<ProjectSnapshot> {+ return readProjectSnapshot(projectId, normalizeInclude(rawInclude, true));+}+// Writes what the snapshot holds into the project and returns the old id -> new id maps.+// Without states the project starts on the default columns, so it has somewhere to put an+// issue. Each insert sets the new project's ids after the snapshot's fields, so a field an+// imported snapshot carries never points a row at another project.+async function applyProjectSnapshot(+ tx: DbExecutor,+ projectId: number,+ snapshot: ProjectSnapshot,+ context: { ownerId: string; sameTeam: boolean },+): Promise<CopyIdMaps> {const maps: CopyIdMaps = {column: new Map(),labelGroup: new Map(),@@ -281,276 +464,203 @@ export async function copyProject(type: new Map(),field: new Map(),option: new Map(),+ fieldType: new Map(snapshot.customFields.map((field) => [field.id, field.fieldType])),};+ const mapped = (map: Map<number, number>, id: number | null) =>+ id == null ? null : (map.get(id) ?? null);++ const columns = snapshot.columns.length+ ? snapshot.columns+ : DEFAULT_COLUMNS.map((column, position) => ({ ...column, id: null, position }));+ for (const { id, ...column } of columns) {+ const [created] = await tx+ .insert(projectColumn)+ .values({ ...column, projectId })+ .returning({ id: projectColumn.id });+ if (id != null) maps.column.set(id, created.id);+ }- const copiedDocumentAssetKeys: string[] = [];+ for (const { id, ...type } of snapshot.issueTypes) {+ const [created] = await tx+ .insert(issueType)+ .values({ ...type, projectId })+ .returning({ id: issueType.id });+ maps.type.set(id, created.id);+ }- const source = await getProjectById(sourceProjectId);- if (!source) throw new HttpError(404, 'Project not found');- const ownerTeam = await targetTeam(ownerId, teamId);- // What a new project starts with, set instance-wide in god mode. Read before the- // transaction opens so the settings lookup is not part of it.- const defaults = await getProjectDefaults();- const agentMembers = defaultAgents ? await defaultAgentMembers(ownerTeam) : [];- // Agents, integration credentials and roles belong to the team, so what references- // them survives the copy only when it stays in the same team.- const sameTeam = ownerTeam.id === source.teamId;- const copyTransaction = db.transaction(async (tx) => {- // The optional sections the source project shows and the estimate kinds it- // carries are part of its configuration, so the copy starts with the same ones.- // mcpEnabled is not carried: a new project enters its team's MCP reach on the- // instance default, the same way a created one does.- const [sourceFeatures] = await tx- .select({- initiativesEnabled: project.initiativesEnabled,- dashboardsEnabled: project.dashboardsEnabled,- documentsEnabled: project.documentsEnabled,- notesEnabled: project.notesEnabled,- cyclesEnabled: project.cyclesEnabled,- subtasksEnabled: project.subtasksEnabled,- checklistsEnabled: project.checklistsEnabled,- issueStatsEnabled: project.issueStatsEnabled,- pointsEstimateEnabled: project.pointsEstimateEnabled,- timeEstimateEnabled: project.timeEstimateEnabled,- timeLoggingEnabled: project.timeLoggingEnabled,- })- .from(project)- .where(eq(project.id, sourceProjectId));+ // Label groups go first so each label's group maps to the new one.+ for (const { id, ...group } of snapshot.labelGroups) {+ const [created] = await tx+ .insert(labelGroup)+ .values({ ...group, projectId })+ .returning({ id: labelGroup.id });+ maps.labelGroup.set(id, created.id);+ }+ for (const { id, groupId, ...rest } of snapshot.labels) {+ const [created] = await tx+ .insert(label)+ .values({ ...rest, projectId, groupId: mapped(maps.labelGroup, groupId) })+ .returning({ id: label.id });+ maps.label.set(id, created.id);+ }- const [row] = await tx- .insert(project)+ for (const { id, issueTypeId, options, ...field } of snapshot.customFields) {+ const [created] = await tx+ .insert(customField)+ .values({ ...field, projectId, issueTypeId: mapped(maps.type, issueTypeId) })+ .returning({ id: customField.id });+ maps.field.set(id, created.id);+ for (const { id: optionId, ...option } of options) {+ const [newOption] = await tx+ .insert(customFieldOption)+ .values({ ...option, fieldId: created.id })+ .returning({ id: customFieldOption.id });+ maps.option.set(optionId, newOption.id);+ }+ }++ for (const { typeId, columnId, labelIds, ...tpl } of snapshot.issueTemplates) {+ const [created] = await tx+ .insert(issueTemplate).values({- teamId: ownerTeam.id,- key: input.key,- name: input.name,- description: input.description ?? '',- mcpEnabled: defaults.mcpEnabled,- isTemplate: template,- ...sourceFeatures,+ ...tpl,+ projectId,+ typeId: mapped(maps.type, typeId),+ columnId: mapped(maps.column, columnId),})- .returning();- const proj = await mapProject({- ...row,- teamName: ownerTeam.name,- teamSlug: ownerTeam.slug,- teamMcpEnabled: ownerTeam.mcpEnabled,- workspaceId: ownerTeam.workspaceId,- });- if (!template) {- await joinTeamAsCreator(tx, ownerTeam.id, ownerId);- await tx.insert(projectMember).values({ projectId: proj.id, userId: ownerId, role: 'owner' });- }- if (agentMembers.length > 0) {+ .returning({ id: issueTemplate.id });+ const newLabelIds = labelIds.flatMap((labelId) => maps.label.get(labelId) ?? []);+ if (newLabelIds.length > 0) {await tx- .insert(projectMember)- .values(agentMembers.map((member) => ({ projectId: proj.id, ...member })));- }-- // States (columns). When copied, every source column is carried over so views,- // actions and issues have somewhere to map to. When not copied, the project is- // seeded with the default columns instead, so it is still usable (a project with- // no state has nowhere to put an issue).- if (inc.states) {- const columnRows = await tx- .select()- .from(projectColumn)- .where(eq(projectColumn.projectId, sourceProjectId))- .orderBy(projectColumn.position);- // autoAssignUserId is left unset: the copy starts with only its owner as a- // member, so a carried-over member would not be one there.- for (const col of columnRows) {- const [created] = await tx- .insert(projectColumn)- .values({- projectId: proj.id,- name: col.name,- stateType: col.stateType,- color: col.color,- position: col.position,- wipLimit: col.wipLimit,- wipMode: col.wipMode,- })- .returning({ id: projectColumn.id });- maps.column.set(col.id, created.id);- }- } else {- for (const [position, column] of DEFAULT_COLUMNS.entries()) {- await tx.insert(projectColumn).values({- projectId: proj.id,- name: column.name,- stateType: column.stateType,- color: column.color,- position,- });- }+ .insert(issueTemplateLabel)+ .values(newLabelIds.map((labelId) => ({ templateId: created.id, labelId })));}+ }- if (inc.issueTypes) {- const typeRows = await tx- .select()- .from(issueType)- .where(eq(issueType.projectId, sourceProjectId))- .orderBy(issueType.position);- for (const t of typeRows) {- const [created] = await tx- .insert(issueType)- .values({- projectId: proj.id,- name: t.name,- icon: t.icon,- color: t.color,- isDefault: t.isDefault,- position: t.position,- })- .returning({ id: issueType.id });- maps.type.set(t.id, created.id);- }- }+ const refs = copyReferences(maps);+ for (const view of snapshot.views) {+ await tx.insert(projectView).values({+ ...view,+ projectId,+ filters: mapFilters(view.filters, refs) ?? {},+ display: mapDisplay(view.display, refs) ?? {},+ });+ }- if (inc.labels) {- // Label groups are copied before labels so each copied label's group_id can be- // remapped to the new group.- const labelGroupRows = await tx- .select()- .from(labelGroup)- .where(eq(labelGroup.projectId, sourceProjectId));- for (const g of labelGroupRows) {- const [created] = await tx- .insert(labelGroup)- .values({ projectId: proj.id, name: g.name, color: g.color })- .returning({ id: labelGroup.id });- maps.labelGroup.set(g.id, created.id);- }+ for (const dashboard of snapshot.dashboards) {+ await tx+ .insert(projectDashboard)+ .values({ ...dashboard, projectId, layout: mapLayout(dashboard.layout, refs) });+ }- const labelRows = await tx.select().from(label).where(eq(label.projectId, sourceProjectId));- for (const l of labelRows) {- const [created] = await tx- .insert(label)- .values({- projectId: proj.id,- groupId: l.groupId != null ? (maps.labelGroup.get(l.groupId) ?? null) : null,- name: l.name,- color: l.color,- })- .returning({ id: label.id });- maps.label.set(l.id, created.id);- }- }+ for (const action of snapshot.actions) {+ await tx.insert(projectAction).values({+ ...action,+ projectId,+ condition: mapFilters(action.condition, refs) ?? {},+ effect: mapEffect(action.effect, refs) ?? {},+ });+ }- // Custom fields with their options. Every issue type is copied with them, so a- // type-scoped field keeps its type.- if (inc.customFields) {- const fieldRows = await tx- .select()- .from(customField)- .where(eq(customField.projectId, sourceProjectId))- .orderBy(customField.position);- for (const f of fieldRows) {- const [created] = await tx- .insert(customField)- .values({- projectId: proj.id,- issueTypeId: f.issueTypeId != null ? (maps.type.get(f.issueTypeId) ?? null) : null,- name: f.name,- fieldType: f.fieldType,- memberScope: f.memberScope,- showInBody: f.showInBody,- position: f.position,- })- .returning({ id: customField.id });- maps.field.set(f.id, created.id);+ if (snapshot.settings.length > 0) {+ await tx+ .insert(projectSetting)+ .values(snapshot.settings.map((setting) => ({ ...setting, projectId })));+ }- const optionRows = await tx- .select()- .from(customFieldOption)- .where(eq(customFieldOption.fieldId, f.id))- .orderBy(customFieldOption.position);- for (const o of optionRows) {- const [newOption] = await tx- .insert(customFieldOption)- .values({ fieldId: created.id, value: o.value, color: o.color, position: o.position })- .returning({ id: customFieldOption.id });- maps.option.set(o.id, newOption.id);- }- }- }+ for (const section of copySections()) {+ if (!(section.key in snapshot.sections)) continue;+ await section.apply({ tx, projectId, maps, ...context }, snapshot.sections[section.key]);+ }- // Issue templates: their type, state and labels point at the copies. The assignee is- // left unset, as a column's auto-assignee is.- if (inc.issueTemplates) {- const templateRows = await tx- .select()- .from(issueTemplate)- .where(eq(issueTemplate.projectId, sourceProjectId))- .orderBy(issueTemplate.id);- for (const tpl of templateRows) {- const [created] = await tx- .insert(issueTemplate)- .values({- projectId: proj.id,- name: tpl.name,- description: tpl.description,- titleTemplate: tpl.titleTemplate,- descriptionTemplate: tpl.descriptionTemplate,- typeId: tpl.typeId != null ? (maps.type.get(tpl.typeId) ?? null) : null,- columnId: tpl.columnId != null ? (maps.column.get(tpl.columnId) ?? null) : null,- priority: tpl.priority,- })- .returning({ id: issueTemplate.id });- const labelRows = await tx- .select({ labelId: issueTemplateLabel.labelId })- .from(issueTemplateLabel)- .where(eq(issueTemplateLabel.templateId, tpl.id));- const labelIds = labelRows.flatMap((row) => maps.label.get(row.labelId) ?? []);- if (labelIds.length > 0) {- await tx- .insert(issueTemplateLabel)- .values(labelIds.map((labelId) => ({ templateId: created.id, labelId })));- }- }- }+ return maps;+}- // Views: their filters reference the ids captured above.- if (inc.views) {- const viewRows = await tx- .select()- .from(projectView)- // A private view is its owner's alone and stays behind.- .where(and(eq(projectView.projectId, sourceProjectId), eq(projectView.isPrivate, false)))- .orderBy(projectView.position, projectView.id);- for (const v of viewRows) {- await tx.insert(projectView).values({- projectId: proj.id,- name: v.name,- icon: v.icon,- filters: remapViewFilters(v.filters, maps) ?? {},- display: remapViewDisplay(v.display, maps) ?? {},- position: v.position,- });- }- }+// Creates a project in the team that starts with what the snapshot holds, inside the+// caller's transaction. The creator becomes its owner and joins the team with it.+export async function insertSnapshotProject(+ tx: DbExecutor,+ snapshot: ProjectSnapshot,+ options: {+ team: TargetTeam;+ input: { key: string; name: string; description?: string };+ ownerId: string;+ // From getProjectDefaults, read before the transaction opens.+ mcpEnabled: boolean;+ agentMembers: { userId: string; role: 'member'; roleId: number | null }[];+ // The snapshot was read from a project of the same team.+ sameTeam: boolean;+ },+): Promise<{ project: ProjectRow; maps: CopyIdMaps }> {+ const { team, input, ownerId } = options;+ const [row] = await tx+ .insert(project)+ .values({+ ...snapshot.flags,+ teamId: team.id,+ key: input.key,+ name: input.name,+ description: input.description ?? '',+ mcpEnabled: options.mcpEnabled,+ })+ .returning();+ await joinTeamAsCreator(tx, team.id, ownerId);+ await tx.insert(projectMember).values({ projectId: row.id, userId: ownerId, role: 'owner' });+ if (options.agentMembers.length > 0) {+ await tx+ .insert(projectMember)+ .values(options.agentMembers.map((member) => ({ projectId: row.id, ...member })));+ }+ const maps = await applyProjectSnapshot(tx, row.id, snapshot, {+ ownerId,+ sameTeam: options.sameTeam,+ });+ const created = await mapProject({+ ...row,+ teamName: team.name,+ teamSlug: team.slug,+ teamMcpEnabled: team.mcpEnabled,+ workspaceId: team.workspaceId,+ });+ return { project: created, maps };+}- // Dashboards: the layout blob is copied verbatim. Widget filters that reference- // assignee/type/label ids are not remapped (those filters just match nothing until- // re-set); the metric widgets, which are project-scoped and id-agnostic, work- // unchanged.- if (inc.dashboards) {- const dashboardRows = await tx- .select()- .from(projectDashboard)- .where(eq(projectDashboard.projectId, sourceProjectId))- .orderBy(projectDashboard.position, projectDashboard.id);- for (const d of dashboardRows) {- await tx.insert(projectDashboard).values({- projectId: proj.id,- name: d.name,- icon: d.icon,- layout: d.layout ?? [],- position: d.position,- });- }- }+// Creates a new project that copies the selected parts of the source project's+// configuration, but none of its issues. The creator becomes the new project's owner.+//+// The configuration is read into a snapshot and written in one transaction, with the+// documents and webhooks, which only a copy carries. A document's assets are cloned in+// the object store inside that transaction and removed again if it rolls back. The+// team's agents are attached to the new project after it commits, through the same+// service function the UI uses.+export async function copyProject(+ sourceProjectId: number,+ input: { key: string; name: string; description?: string },+ ownerId: string,+ teamId: number,+ rawInclude?: Record<string, boolean | undefined>,+): Promise<ProjectRow> {+ const inc = normalizeInclude(rawInclude, false);+ const source = await getProjectById(sourceProjectId);+ if (!source) throw new HttpError(404, 'Project not found');+ const ownerTeam = await targetTeam(ownerId, teamId);+ // Agents, integration credentials and roles belong to the team, so what references+ // them survives the copy only when it stays in the same team.+ const sameTeam = ownerTeam.id === source.teamId;+ const snapshot = await readProjectSnapshot(sourceProjectId, inc);+ const defaults = await getProjectDefaults();+ const copiedDocumentAssetKeys: string[] = [];+ const copyTransaction = db.transaction(async (tx) => {+ const inserted = await insertSnapshotProject(tx, snapshot, {+ team: ownerTeam,+ input,+ ownerId,+ mcpEnabled: defaults.mcpEnabled,+ agentMembers: [],+ sameTeam,+ });+ const proj = inserted.project;if (inc.documents) {const documentRows = await tx.select()@@ -657,44 +767,6 @@ export async function copyProject(}}- // Actions: their condition (a FilterSet) and effect (a partial patch) hold ids- // captured above, so they are remapped to the copied entities.- if (inc.actions) {- const actionRows = await tx- .select()- .from(projectAction)- .where(eq(projectAction.projectId, sourceProjectId))- .orderBy(projectAction.position, projectAction.id);- for (const a of actionRows) {- await tx.insert(projectAction).values({- projectId: proj.id,- name: a.name,- icon: a.icon,- condition: remapViewFilters(a.condition, maps) ?? {},- effect: remapActionEffect(a.effect, maps) ?? {},- position: a.position,- });- }- }-- // Project settings key/value rows (the Configuration section's subtask- // automations and auto-archive thresholds, and any other project-scoped- // setting). Copied verbatim, except the repository integration: its value holds- // the webhook secret and routing id (the copy's owner must not receive the- // source's credential, and a duplicated id would make inbound routing- // ambiguous) plus column ids of the source project. The copy starts- // unconfigured instead.- if (inc.configuration) {- const settingRows = await tx- .select()- .from(projectSetting)- .where(eq(projectSetting.projectId, sourceProjectId));- for (const s of settingRows) {- if (s.key === GIT_SETTING_KEY) continue;- await tx.insert(projectSetting).values({ projectId: proj.id, key: s.key, value: s.value });- }- }-// Webhook subscriptions: the URL and the event selection, with a signing secret of// their own — the copy's owner must not receive the source's. The receiver cannot// verify that signature until it is given the new secret, so the copy starts@@ -716,28 +788,16 @@ export async function copyProject(}}- for (const section of copySections()) {- if (!inc[section.key]) continue;- await section.copy({- tx,- sourceProjectId,- projectId: proj.id,- ownerId,- maps,- template,- sameTeam,- });- }-- return proj;+ return inserted;});- let newProject: ProjectRow;+ let created: Awaited<typeof copyTransaction>;try {- newProject = await copyTransaction;+ created = await copyTransaction;} catch (error) {await Promise.all(copiedDocumentAssetKeys.map(deleteAttachmentObject));throw error;}+ const { project: newProject, maps } = created;// Agents: the ones working in the source project, attached to the new one as well.// The team owns them and one handle is unique in it, so a second copy of the samediff --git a/apps/api/src/modules/projects/model.ts b/apps/api/src/modules/projects/model.tsindex fcb21dd0..8172e6e8 100644--- a/apps/api/src/modules/projects/model.ts+++ b/apps/api/src/modules/projects/model.ts@@ -43,8 +43,9 @@ export const createProjectBody = t.Composite([templateId: t.Optional(t.Integer({description:- 'A project template of the team (list_project_templates) to create the project ' +- 'from. The project then starts with what the template holds, and preset is not used.',+ 'A project template open to the team (list_project_templates) to create the ' ++ 'project from. The project then starts with what the template holds, and preset ' ++ 'is not used.',}),),}),diff --git a/apps/api/src/modules/projects/references.ts b/apps/api/src/modules/projects/references.tsnew file mode 100644index 00000000..88028bc8--- /dev/null+++ b/apps/api/src/modules/projects/references.ts@@ -0,0 +1,188 @@+// The references to other parts of a project that views, actions and dashboard widgets+// hold inside the jsonb the web app writes (utils/filters.ts, utils/viewSettings.ts and+// utils/dashboardWidgets.ts there). A project copy points them at the rows of the new+// project, and a shared template at the numbers its file gives them.++export type ReferenceKind =+ 'column' | 'type' | 'label' | 'field' | 'option' | 'person' | 'initiative' | 'cycle';++export interface References {+ // What the reference becomes, or undefined when it is dropped.+ map(kind: ReferenceKind, id: number | string): number | string | undefined;+ // The type of the field a `cf:<id>` key names, by the id the key holds.+ fieldType(id: number): string | undefined;+}++type Blob = Record<string, unknown>;++const isBlob = (value: unknown): value is Blob =>+ typeof value === 'object' && value !== null && !Array.isArray(value);++const isReference = (kind: ReferenceKind, value: unknown): value is number | string =>+ kind === 'person' ? typeof value === 'string' : typeof value === 'number';++const kept = (values: unknown[], map: (value: unknown) => unknown) =>+ values.flatMap((value) => {+ const mapped = map(value);+ return mapped === undefined ? [] : [mapped];+ });++function fieldIdOf(key: unknown): number | null {+ return typeof key === 'string' && /^cf:\d+$/.test(key) ? Number(key.slice(3)) : null;+}++function mapFieldKey(key: unknown, refs: References): unknown {+ const id = fieldIdOf(key);+ if (id == null) return key;+ const mapped = refs.map('field', id);+ return mapped === undefined ? undefined : `cf:${mapped}`;+}++// What the values of a condition on the field name. Null for values that name nothing: a+// priority, a state type, a date, text, or a whole status of the cycles or initiatives+// (`status:<status>`, which is not a number).+function valueKind(field: unknown, refs: References): ReferenceKind | null {+ switch (field) {+ case 'status':+ return 'column';+ case 'type':+ return 'type';+ case 'labels':+ return 'label';+ case 'assignee':+ case 'delegate':+ return 'person';+ case 'initiative':+ return 'initiative';+ case 'cycle':+ return 'cycle';+ }+ const fieldId = fieldIdOf(field);+ if (fieldId == null) return null;+ const type = refs.fieldType(fieldId);+ if (type === 'select' || type === 'multi_select') return 'option';+ return type === 'member' ? 'person' : null;+}++// A condition on a dropped field goes, and so does one that loses every value it had. A+// condition's id only tells it from the others of its set, so the set numbers them.+export function mapFilters(filters: unknown, refs: References): unknown {+ if (!isBlob(filters) || !Array.isArray(filters.conditions)) return filters;+ const conditions = filters.conditions.flatMap((condition: unknown) => {+ if (!isBlob(condition)) return [];+ const field = mapFieldKey(condition.field, refs);+ if (field === undefined) return [];+ const kind = valueKind(condition.field, refs);+ if (!kind || !Array.isArray(condition.values)) return [{ ...condition, field }];+ const values = kept(condition.values, (value) =>+ isReference(kind, value) ? refs.map(kind, value) : value,+ );+ if (values.length === 0 && condition.values.length > 0) return [];+ return [{ ...condition, field, values }];+ });+ return {+ ...filters,+ conditions: conditions.map((condition, index) => ({ ...condition, id: String(index + 1) })),+ };+}++const GROUP_KINDS: Record<string, ReferenceKind> = {+ c: 'column',+ t: 'type',+ i: 'initiative',+ y: 'cycle',+ a: 'person',+ d: 'person',+};++// The keys of groupKeyOf in the web app: c<columnId>, t<typeId>, i<initiativeId>,+// y<cycleId>, a<userId>, d<userId>, f<fieldId>u<userId> and f<fieldId>-none name+// something; 'all', a priority (p<priority>) and the other *-none buckets do not.+function mapGroupKey(key: unknown, refs: References): unknown {+ if (typeof key !== 'string' || key === 'all') return key;+ const member = /^f(\d+)(?:u(.+)|-none)$/.exec(key);+ if (member) {+ const field = refs.map('field', Number(member[1]));+ if (field === undefined) return undefined;+ if (member[2] === undefined) return `f${field}-none`;+ const person = refs.map('person', member[2]);+ return person === undefined ? undefined : `f${field}u${person}`;+ }+ const kind = GROUP_KINDS[key[0]];+ const id = key.slice(1);+ if (!kind || id === '-none') return key;+ const mapped = refs.map(kind, kind === 'person' ? id : Number(id));+ return mapped === undefined ? undefined : `${key[0]}${mapped}`;+}++// A grouping or a date field that is dropped leaves its key out, which the web app reads+// as the view's default.+export function mapDisplay(display: unknown, refs: References): unknown {+ if (!isBlob(display)) return display;+ const out: Blob = { ...display };+ for (const key of ['group', 'subgroup', 'calendarDateField']) {+ const mapped = mapFieldKey(out[key], refs);+ if (mapped === undefined) delete out[key];+ else out[key] = mapped;+ }+ if (Array.isArray(out.properties)) {+ out.properties = kept(out.properties, (key) => mapFieldKey(key, refs));+ }+ for (const key of ['hiddenGroups', 'collapsedGroups']) {+ const groups = out[key];+ if (Array.isArray(groups)) out[key] = kept(groups, (group) => mapGroupKey(group, refs));+ }+ if (typeof out.pinnedGroup === 'string') {+ out.pinnedGroup = mapGroupKey(out.pinnedGroup, refs) ?? null;+ }+ return out;+}++// A key that is there sets what it names, so a dropped reference takes its key with it+// rather than leaving null, which clears it.+function mapKeys(blob: Blob, kinds: Record<string, ReferenceKind>, refs: References): Blob {+ const out: Blob = { ...blob };+ for (const [key, kind] of Object.entries(kinds)) {+ const value = out[key];+ if (!isReference(kind, value)) continue;+ const mapped = refs.map(kind, value);+ if (mapped === undefined) delete out[key];+ else out[key] = mapped;+ }+ return out;+}++// An action's effect is a partial issue patch.+export function mapEffect(effect: unknown, refs: References): unknown {+ if (!isBlob(effect)) return effect;+ const out = mapKeys(+ effect,+ { columnId: 'column', typeId: 'type', assigneeUserId: 'person' },+ refs,+ );+ if (Array.isArray(out.labelIds)) {+ out.labelIds = kept(out.labelIds, (id) =>+ isReference('label', id) ? refs.map('label', id) : id,+ );+ }+ return out;+}++// A widget's id only tells it from the others of its dashboard, so the layout numbers+// them.+export function mapLayout(layout: unknown, refs: References): unknown[] {+ if (!Array.isArray(layout)) return [];+ return layout.filter(isBlob).map((widget, index) => {+ const out: Blob = { ...widget, id: String(index + 1) };+ if (isBlob(widget.config)) {+ const config = mapKeys(+ widget.config,+ { typeId: 'type', actorUserId: 'person', initiativeId: 'initiative' },+ refs,+ );+ if ('filters' in config) config.filters = mapFilters(config.filters, refs);+ out.config = config;+ }+ return out;+ });+}diff --git a/apps/api/src/modules/projects/service.ts b/apps/api/src/modules/projects/service.tsindex 1977dc21..bcd7ad3a 100644--- a/apps/api/src/modules/projects/service.ts+++ b/apps/api/src/modules/projects/service.ts@@ -222,7 +222,6 @@ async function readProjects(grantedTeams.length > 0 ? inArray(project.teamId, grantedTeams) : undefined,),isNull(project.archivedAt),- eq(project.isTemplate, false),opts.mcpOnly ? and(eq(project.mcpEnabled, true), eq(team.mcpEnabled, true)) : undefined,opts.teamId !== undefined ? eq(project.teamId, opts.teamId) : undefined,opts.workspaceId !== undefined ? eq(team.workspaceId, opts.workspaceId) : undefined,@@ -636,7 +635,9 @@ export async function setProjectArchived(}// The project's feature toggles, read from the project row.-export function projectFeatures(row: ProjectRow): ProjectFeatures {+export function projectFeatures(+ row: Pick<ProjectRow, `${keyof ProjectFeatures}Enabled`>,+): ProjectFeatures {return {initiatives: row.initiativesEnabled,dashboards: row.dashboardsEnabled,diff --git a/apps/api/src/modules/scim/mappings.ts b/apps/api/src/modules/scim/mappings.tsindex 46b50475..3d3a42b0 100644--- a/apps/api/src/modules/scim/mappings.ts+++ b/apps/api/src/modules/scim/mappings.ts@@ -107,13 +107,7 @@ export async function setGroupMappings(.select({ id: project.id, teamId: project.teamId }).from(project).innerJoin(team, eq(team.id, project.teamId))- .where(- and(- inArray(project.id, projectIds),- eq(project.isTemplate, false),- where && or(where, inArray(project.id, before)),- ),- );+ .where(and(inArray(project.id, projectIds), where && or(where, inArray(project.id, before))));if (known.length !== projectIds.length) throw new HttpError(400, 'Unknown project');// A custom role belongs to one team, so a mapping that names another team's role// would silently grant the wrong permissions. A system role fits every team.@@ -163,7 +157,7 @@ export async function listMappableProjects(workspaceId: number | null) {.select({ id: project.id, key: project.key, name: project.name, teamId: project.teamId }).from(project).innerJoin(team, eq(team.id, project.teamId))- .where(and(where, eq(project.isTemplate, false)))+ .where(where).orderBy(asc(project.key)),db.select({ id: teamRole.id, name: teamRole.name, teamId: teamRole.teamId })diff --git a/apps/api/src/modules/teams/index.ts b/apps/api/src/modules/teams/index.tsindex c754a01e..b980b907 100644--- a/apps/api/src/modules/teams/index.ts+++ b/apps/api/src/modules/teams/index.ts@@ -326,9 +326,9 @@ export const teamRoutes = new Elysia({ name: 'teams', detail: { tags: ['Teams']detail: {summary: 'Delete a team',description:- 'Delete a team you own, with its members, roles, project templates, invites, skills, ' +- 'tools and integrations. A team that holds a project or an AI agent is refused ' +- 'until those are gone. Irreversible.',+ 'Delete a team you own, with its members, roles, invites, skills, tools and ' ++ 'integrations. A team that holds a project or an AI agent is refused until those ' ++ 'are gone. Irreversible.',},},)diff --git a/apps/api/src/modules/teams/model.ts b/apps/api/src/modules/teams/model.tsindex 46b507ab..53b07757 100644--- a/apps/api/src/modules/teams/model.ts+++ b/apps/api/src/modules/teams/model.ts@@ -65,7 +65,6 @@ export const TeamResponse = t.Object({}),joinedAt: t.String(),projectCount: t.Number(),- templateCount: t.Number({ description: 'How many project templates the team holds.' }),memberCount: t.Number(),ownerCount: t.Number({ description: 'How many members are owners; the last one cannot leave.' }),roleCount: t.Number({ description: "How many roles the team's projects assign from." }),diff --git a/apps/api/src/modules/teams/service.ts b/apps/api/src/modules/teams/service.tsindex cc15c9fd..7eb8874b 100644--- a/apps/api/src/modules/teams/service.ts+++ b/apps/api/src/modules/teams/service.ts@@ -86,7 +86,6 @@ export interface TeamRow {source: MemberSource;joinedAt: string;projectCount: number;- templateCount: number;memberCount: number;// How many of those members are owners: the last one cannot leave.ownerCount: number;@@ -265,9 +264,8 @@ async function loadTeamRows(userId: string, teamId?: number): Promise<TeamRow[]>db.select({teamId: project.teamId,- count: sql<number>`count(*) filter (where not ${project.isTemplate})::int`,- joined: sql<number>`count(${projectMember.userId}) filter (where not ${project.isTemplate})::int`,- templates: sql<number>`count(*) filter (where ${project.isTemplate})::int`,+ count: sql<number>`count(*)::int`,+ joined: sql<number>`count(${projectMember.userId})::int`,}).from(project).leftJoin(@@ -336,7 +334,6 @@ async function loadTeamRows(userId: string, teamId?: number): Promise<TeamRow[]>source: (row.source as MemberSource | null) ?? 'invite',joinedAt: iso(row.joinedAt ?? row.createdAt),projectCount: (runsTeam(standing) || grant ? projectCount?.count : projectCount?.joined) ?? 0,- templateCount: projectCount?.templates ?? 0,memberCount: members.get(row.id)?.count ?? 0,ownerCount: members.get(row.id)?.owners ?? 0,roleCount: roles.get(row.id) ?? 0,@@ -415,7 +412,7 @@ async function getTeamMcp(teamId: number): Promise<TeamMcpSettings> {db.select({ projectId: project.id, enabled: project.mcpEnabled }).from(project)- .where(and(eq(project.teamId, teamId), eq(project.isTemplate, false)))+ .where(eq(project.teamId, teamId)).orderBy(project.key),]);return { enabled: rows[0]?.mcpEnabled ?? false, projects };@@ -562,7 +559,6 @@ async function visibleTeamProjects(const term = search?.trim();return and(eq(project.teamId, teamId),- eq(project.isTemplate, false),seesAll? undefined: sql`exists (select 1 from ${projectMember} where ${projectMember.projectId} = ${project.id}@@ -691,14 +687,12 @@ async function lastActivityAt(projectId: number): Promise<string | null> {}// Whether the project is one the team owns. The team-scoped project routes check it-// so a project of another team, or a template, answers 404 rather than being acted on.+// so a project of another team answers 404 rather than being acted on.export async function teamOwnsProject(teamId: number, projectId: number): Promise<boolean> {const rows = await db.select({ id: project.id }).from(project)- .where(- and(eq(project.id, projectId), eq(project.teamId, teamId), eq(project.isTemplate, false)),- );+ .where(and(eq(project.id, projectId), eq(project.teamId, teamId)));return rows.length > 0;}@@ -848,7 +842,6 @@ export async function createTeam(source: 'invite',joinedAt: iso(membership.createdAt),projectCount: 0,- templateCount: 0,memberCount: 1,ownerCount: 1,roleCount: 1,@@ -908,7 +901,7 @@ export async function deleteTeam(teamId: number): Promise<void> {.where(and(eq(team.id, teamId),- sql`not exists (select 1 from ${project} where ${project.teamId} = ${team.id} and not ${project.isTemplate})`,+ sql`not exists (select 1 from ${project} where ${project.teamId} = ${team.id})`,sql`not exists (select 1 from ${aiAgent} where ${aiAgent.teamId} = ${team.id})`,),)diff --git a/apps/api/src/modules/workspaces/service.ts b/apps/api/src/modules/workspaces/service.tsindex 78038b6e..6500c93f 100644--- a/apps/api/src/modules/workspaces/service.ts+++ b/apps/api/src/modules/workspaces/service.ts@@ -71,7 +71,7 @@ export async function projectWorkspaceGrant(workspaceManager,and(eq(workspaceManager.workspaceId, team.workspaceId), eq(workspaceManager.userId, userId)),)- .where(and(eq(project.id, projectId), eq(project.isTemplate, false)));+ .where(eq(project.id, projectId));return row ? workspaceRoleGrant(row.role) : null;}@@ -206,8 +206,7 @@ async function runLimitCap(workspaceId: number): Promise<number> {}// Whether a team of the workspace has a project or an AI agent: people's work, which a-// deleted workspace would take with it. A project template is the team's configuration,-// not work, and goes with the workspace.+// deleted workspace would take with it.export async function workspaceHoldsWork(workspaceId: number): Promise<boolean> {const [row] = await db.select({ id: team.id })@@ -220,7 +219,7 @@ export async function workspaceHoldsWork(workspaceId: number): Promise<boolean>db.select({ n: sql`1` }).from(project)- .where(and(eq(project.teamId, team.id), eq(project.isTemplate, false))),+ .where(eq(project.teamId, team.id)),),exists(dbdiff --git a/apps/api/src/shared/access.ts b/apps/api/src/shared/access.tsindex c7a82299..d37a52f9 100644--- a/apps/api/src/shared/access.ts+++ b/apps/api/src/shared/access.ts@@ -434,10 +434,7 @@ export function reachedProjectIds(userId: string, grantedTeams: number[]): SQLWr.where(eq(projectMember.userId, userId));if (grantedTeams.length === 0) return member;return member.union(- db- .select({ id: project.id })- .from(project)- .where(and(inArray(project.teamId, grantedTeams), eq(project.isTemplate, false))),+ db.select({ id: project.id }).from(project).where(inArray(project.teamId, grantedTeams)),);}diff --git a/apps/web/messages/ar/projects.json b/apps/web/messages/ar/projects.jsonindex 1b701238..cecb926d 100644--- a/apps/web/messages/ar/projects.json+++ b/apps/web/messages/ar/projects.json@@ -4,7 +4,23 @@"saveTemplateAction": "حفظ كقالب","saveTemplate": {"title": "حفظ \"{name}\" كقالب",+ "newTitle": "قالب مشروع جديد","hint": "يحتفظ القالب بنسخة من الإعدادات المختارة. لا تغيّره التعديلات اللاحقة على المشروع. لا تُحفظ المستندات والوكلاء والجدولات وخطافات الويب.",+ "teams": "الفرق",+ "allTeams": "كل فرق مساحة العمل",+ "allTeamsHint": "أوقف هذا الخيار لاختيار الفرق التي ترى هذا القالب عند إنشاء مشروع.",+ "team": "الفريق",+ "project": "المشروع",+ "chooseTeam": "اختر فريقًا",+ "chooseProject": "اختر مشروعًا",+ "previewEmpty": "اختر مشروعًا لترى ما سيحتويه القالب.",+ "importTitle": "استيراد قالب مشروع",+ "importHint": "الصق قالبًا منسوخًا من مساحة عمل أخرى، أو ارفع ملفه. لا يُنقل الأشخاص المذكورون فيه.",+ "importLabel": "القالب",+ "importPlaceholder": "الصق القالب المنسوخ هنا",+ "importFile": "رفع ملف",+ "importEmpty": "الصق قالبًا لترى محتواه.",+ "importInvalid": "هذا ليس قالب مشروع، أو أنه تالف.","save": "حفظ القالب","saved": "تم حفظ القالب \"{name}\""},diff --git a/apps/web/messages/ar/teams.json b/apps/web/messages/ar/teams.jsonindex ad26f1c9..b612f25c 100644--- a/apps/web/messages/ar/teams.json+++ b/apps/web/messages/ar/teams.json@@ -188,19 +188,77 @@}},"templates": {- "ownerOnly": "يمكن لمالك الفريق أو مديره فقط إدارة قوالب المشاريع.","empty": "لا توجد قوالب مشاريع بعد","emptyHint": "احفظ مشروعًا كقالب لتنشئ منه مشاريع جديدة.",- "openProjects": "الانتقال إلى المشاريع",+ "newAction": "قالب جديد",+ "teams": "الفرق",+ "allTeams": "كل الفرق",+ "noTeams": "لا يوجد فريق",+ "editAction": "تعديل القالب",+ "editHint": "يبقى محتوى القالب كما حُفظ.",+ "copyAction": "نسخ القالب",+ "copied": "تم نسخ القالب \"{name}\". الصقه في مساحة عمل أخرى لاستيراده.",+ "downloadAction": "تنزيل",+ "downloadFailed": "تعذّر تنزيل القالب.",+ "importAction": "استيراد قالب","deleteAction": "حذف القالب","deleteDialog": {"title": "حذف القالب \"{name}\"؟","description": "لا تتغير المشاريع التي أُنشئت منه.",- "confirm": "حذف القالب"+ "confirm": "حذف القالب",+ "galleryNote": "وتُزال صفحته من المعرض أيضًا."},"panel": {"saved": "حُفظ في {date}",- "none": "لا شيء"+ "none": "لا شيء",+ "teams": "الفرق: {teams}"+ },+ "publish": {+ "action": "نشر",+ "published": "منشور",+ "account": "حساب المعرض",+ "publishingAs": "النشر باسم",+ "authorProfile": "ملف المؤلف",+ "changeEmail": "تغيير البريد الإلكتروني",+ "rules": "قواعد المعرض",+ "unlink": "إلغاء ربط مساحة العمل",+ "downloadable": "يمكن لأي شخص تنزيله",+ "private": "بلا مهام ولا أشخاص",+ "counts": "{states, plural, zero {# حالات} one {حالة واحدة} two {حالتان} few {# حالات} many {# حالة} other {# حالة}} · {types, plural, zero {# أنواع} one {نوع واحد} two {نوعان} few {# أنواع} many {# نوعًا} other {# نوع}} · {fields, plural, zero {# حقول} one {حقل واحد} two {حقلان} few {# حقول} many {# حقلًا} other {# حقل}}",+ "by": "بواسطة <b>{name}</b>",+ "authorHint": "يظهر على كل قالب يُنشر من {email}.",+ "authorName": "المؤلف",+ "authorUrl": "رابط الملف الشخصي",+ "optional": "اختياري",+ "authorUrlInvalid": "يجب أن يبدأ بـ https://",+ "submit": "نشر",+ "update": "تحديث الصفحة",+ "live": "متاح",+ "since": "منذ {date}",+ "openPage": "فتح الصفحة",+ "copyLink": "نسخ الرابط",+ "linkCopied": "تم نسخ الرابط",+ "copyFailed": "تعذّر نسخ الرابط",+ "unpublish": "إلغاء النشر",+ "unpublishConfirm": "إزالة الصفحة؟",+ "unpublishHint": "سيتوقف رابطها عن العمل.",+ "keep": "إبقاء",+ "publishedToast": "تم النشر",+ "updatedToast": "تم تحديث الصفحة",+ "badge": "عام",+ "badgeHint": "في المعرض منذ {date}",+ "link": {+ "intro": "أكّد بريدًا إلكترونيًا مرة واحدة لمساحة العمل هذه.",+ "email": "البريد الإلكتروني",+ "emailHint": "لا يُعرض للعامة",+ "agree": "بإرسال الرمز فإنك توافق على <rules>قواعد المعرض</rules>.",+ "sendCode": "إرسال الرمز",+ "codeSent": "أدخل الرمز المُرسل إلى {email}",+ "code": "الرمز",+ "confirm": "تأكيد",+ "resend": "إرسال مرة أخرى",+ "resent": "تم إرسال رمز جديد"+ }}},"panel": {diff --git a/apps/web/messages/en/projects.json b/apps/web/messages/en/projects.jsonindex ecb4f161..4639d9a2 100644--- a/apps/web/messages/en/projects.json+++ b/apps/web/messages/en/projects.json@@ -4,7 +4,23 @@"saveTemplateAction": "Save as template","saveTemplate": {"title": "Save \"{name}\" as a template",+ "newTitle": "New project template","hint": "The template keeps a copy of the chosen settings. Later changes to this project don't change it. Docs, agents, schedules and webhooks aren't saved.",+ "teams": "Teams",+ "allTeams": "All teams of the workspace",+ "allTeamsHint": "Turn off to choose the teams that see this template when they create a project.",+ "team": "Team",+ "project": "Project",+ "chooseTeam": "Choose a team",+ "chooseProject": "Choose a project",+ "previewEmpty": "Choose a project to see what the template will hold.",+ "importTitle": "Import a project template",+ "importHint": "Paste a template copied from another workspace, or upload its file. The people it named are left out.",+ "importLabel": "Template",+ "importPlaceholder": "Paste the copied template here",+ "importFile": "Upload file",+ "importEmpty": "Paste a template to see what it holds.",+ "importInvalid": "This is not a project template, or it is damaged.","save": "Save template","saved": "Template \"{name}\" saved"},diff --git a/apps/web/messages/en/teams.json b/apps/web/messages/en/teams.jsonindex 8705427a..d0700261 100644--- a/apps/web/messages/en/teams.json+++ b/apps/web/messages/en/teams.json@@ -188,19 +188,77 @@}},"templates": {- "ownerOnly": "Only a team owner or manager can manage project templates.","empty": "No project templates yet","emptyHint": "Save a project as a template, then start new projects from it.",- "openProjects": "Go to projects",+ "newAction": "New template",+ "teams": "Teams",+ "allTeams": "All teams",+ "noTeams": "No team",+ "editAction": "Edit template",+ "editHint": "What the template holds stays as saved.",+ "copyAction": "Copy template",+ "copied": "Template \"{name}\" copied. Paste it into another workspace to import it.",+ "downloadAction": "Download",+ "downloadFailed": "Couldn't download the template.",+ "importAction": "Import template","deleteAction": "Delete template","deleteDialog": {"title": "Delete template \"{name}\"?","description": "Projects created from it stay as they are.",- "confirm": "Delete template"+ "confirm": "Delete template",+ "galleryNote": "Its gallery page goes offline too."},"panel": {"saved": "Saved {date}",- "none": "None"+ "none": "None",+ "teams": "Teams: {teams}"+ },+ "publish": {+ "action": "Publish",+ "published": "Published",+ "account": "Gallery account",+ "publishingAs": "Publishing as",+ "authorProfile": "Author profile",+ "changeEmail": "Change email",+ "rules": "Gallery rules",+ "unlink": "Unlink workspace",+ "downloadable": "Anyone can download it",+ "private": "No issues or people",+ "counts": "{states, plural, one {# state} other {# states}} · {types, plural, one {# type} other {# types}} · {fields, plural, one {# field} other {# fields}}",+ "by": "by <b>{name}</b>",+ "authorHint": "Shown on every template published from {email}.",+ "authorName": "Author",+ "authorUrl": "Profile link",+ "optional": "Optional",+ "authorUrlInvalid": "Must start with https://",+ "submit": "Publish",+ "update": "Update page",+ "live": "Live",+ "since": "since {date}",+ "openPage": "Open page",+ "copyLink": "Copy link",+ "linkCopied": "Link copied",+ "copyFailed": "Couldn't copy the link",+ "unpublish": "Unpublish",+ "unpublishConfirm": "Take the page down?",+ "unpublishHint": "Its link stops working.",+ "keep": "Keep",+ "publishedToast": "Published",+ "updatedToast": "Page updated",+ "badge": "Public",+ "badgeHint": "In the gallery since {date}",+ "link": {+ "intro": "Confirm an email once for this workspace.",+ "email": "Email",+ "emailHint": "Not shown publicly",+ "agree": "By sending the code you accept the <rules>gallery rules</rules>.",+ "sendCode": "Send code",+ "codeSent": "Enter the code sent to {email}",+ "code": "Code",+ "confirm": "Confirm",+ "resend": "Send again",+ "resent": "New code sent"+ }}},"panel": {diff --git a/apps/web/messages/es-ES/projects.json b/apps/web/messages/es-ES/projects.jsonindex 9911bc77..c26bdf68 100644--- a/apps/web/messages/es-ES/projects.json+++ b/apps/web/messages/es-ES/projects.json@@ -4,7 +4,23 @@"saveTemplateAction": "Guardar como plantilla","saveTemplate": {"title": "Guardar «{name}» como plantilla",+ "newTitle": "Nueva plantilla de proyecto","hint": "La plantilla guarda una copia de los ajustes elegidos. Los cambios posteriores en el proyecto no la modifican. Los documentos, los agentes, las tareas programadas y los webhooks no se guardan.",+ "teams": "Equipos",+ "allTeams": "Todos los equipos del espacio de trabajo",+ "allTeamsHint": "Desactívalo para elegir los equipos que ven esta plantilla al crear un proyecto.",+ "team": "Equipo",+ "project": "Proyecto",+ "chooseTeam": "Elige un equipo",+ "chooseProject": "Elige un proyecto",+ "previewEmpty": "Elige un proyecto para ver lo que tendrá la plantilla.",+ "importTitle": "Importar una plantilla de proyecto",+ "importHint": "Pega una plantilla copiada de otro espacio de trabajo o sube su archivo. Las personas que nombraba no se incluyen.",+ "importLabel": "Plantilla",+ "importPlaceholder": "Pega aquí la plantilla copiada",+ "importFile": "Subir archivo",+ "importEmpty": "Pega una plantilla para ver lo que contiene.",+ "importInvalid": "Esto no es una plantilla de proyecto o está dañada.","save": "Guardar plantilla","saved": "Plantilla «{name}» guardada"},diff --git a/apps/web/messages/es-ES/teams.json b/apps/web/messages/es-ES/teams.jsonindex d09136b7..046bbe5e 100644--- a/apps/web/messages/es-ES/teams.json+++ b/apps/web/messages/es-ES/teams.json@@ -188,19 +188,77 @@}},"templates": {- "ownerOnly": "Solo un propietario o administrador del equipo puede gestionar las plantillas de proyecto.","empty": "Todavía no hay plantillas de proyecto","emptyHint": "Guarda un proyecto como plantilla para crear proyectos nuevos a partir de ella.",- "openProjects": "Ir a proyectos",+ "newAction": "Nueva plantilla",+ "teams": "Equipos",+ "allTeams": "Todos los equipos",+ "noTeams": "Ningún equipo",+ "editAction": "Editar plantilla",+ "editHint": "Lo que contiene la plantilla se queda tal como se guardó.",+ "copyAction": "Copiar plantilla",+ "copied": "Plantilla \"{name}\" copiada. Pégala en otro espacio de trabajo para importarla.",+ "downloadAction": "Descargar",+ "downloadFailed": "No se pudo descargar la plantilla.",+ "importAction": "Importar plantilla","deleteAction": "Eliminar plantilla","deleteDialog": {"title": "¿Eliminar la plantilla «{name}»?","description": "Los proyectos creados con ella no cambian.",- "confirm": "Eliminar plantilla"+ "confirm": "Eliminar plantilla",+ "galleryNote": "Su página en la galería también se retira."},"panel": {"saved": "Guardada el {date}",- "none": "Ninguno"+ "none": "Ninguno",+ "teams": "Equipos: {teams}"+ },+ "publish": {+ "action": "Publicar",+ "published": "Publicada",+ "account": "Cuenta de la galería",+ "publishingAs": "Publicas como",+ "authorProfile": "Perfil del autor",+ "changeEmail": "Cambiar correo",+ "rules": "Normas de la galería",+ "unlink": "Desvincular espacio de trabajo",+ "downloadable": "Cualquiera puede descargarla",+ "private": "Sin tickets ni personas",+ "counts": "{states, plural, one {# estado} other {# estados}} · {types, plural, one {# tipo} other {# tipos}} · {fields, plural, one {# campo} other {# campos}}",+ "by": "de <b>{name}</b>",+ "authorHint": "Se muestra en todas las plantillas publicadas desde {email}.",+ "authorName": "Autor",+ "authorUrl": "Enlace al perfil",+ "optional": "Opcional",+ "authorUrlInvalid": "Debe empezar por https://",+ "submit": "Publicar",+ "update": "Actualizar página",+ "live": "En línea",+ "since": "desde el {date}",+ "openPage": "Abrir página",+ "copyLink": "Copiar enlace",+ "linkCopied": "Enlace copiado",+ "copyFailed": "No se pudo copiar el enlace",+ "unpublish": "Retirar",+ "unpublishConfirm": "¿Retirar la página?",+ "unpublishHint": "Su enlace dejará de funcionar.",+ "keep": "Mantener",+ "publishedToast": "Publicada",+ "updatedToast": "Página actualizada",+ "badge": "Pública",+ "badgeHint": "En la galería desde el {date}",+ "link": {+ "intro": "Confirma un correo una sola vez para este espacio de trabajo.",+ "email": "Correo electrónico",+ "emailHint": "No se muestra públicamente",+ "agree": "Al enviar el código aceptas las <rules>normas de la galería</rules>.",+ "sendCode": "Enviar código",+ "codeSent": "Introduce el código enviado a {email}",+ "code": "Código",+ "confirm": "Confirmar",+ "resend": "Enviar de nuevo",+ "resent": "Código nuevo enviado"+ }}},"panel": {diff --git a/apps/web/messages/fa/projects.json b/apps/web/messages/fa/projects.jsonindex 969a051c..7a767e78 100644--- a/apps/web/messages/fa/projects.json+++ b/apps/web/messages/fa/projects.json@@ -4,7 +4,23 @@"saveTemplateAction": "ذخیره بهعنوان قالب","saveTemplate": {"title": "ذخیرهٔ «{name}» بهعنوان قالب",+ "newTitle": "قالب پروژه جدید","hint": "قالب یک نسخه از تنظیمات انتخابشده را نگه میدارد. تغییرات بعدی پروژه آن را تغییر نمیدهد. مستندات، ایجنتها، زمانبندیها و وبهوکها ذخیره نمیشوند.",+ "teams": "تیمها",+ "allTeams": "همه تیمهای فضای کار",+ "allTeamsHint": "برای انتخاب تیمهایی که هنگام ساخت پروژه این قالب را میبینند، خاموشش کنید.",+ "team": "تیم",+ "project": "پروژه",+ "chooseTeam": "یک تیم انتخاب کنید",+ "chooseProject": "یک پروژه انتخاب کنید",+ "previewEmpty": "یک پروژه انتخاب کنید تا ببینید قالب چه چیزهایی در بر میگیرد.",+ "importTitle": "وارد کردن قالب پروژه",+ "importHint": "قالبی را که از فضای کاری دیگری کپی شده بچسبانید یا فایل آن را بارگذاری کنید. افرادی که در آن نام برده شدهاند منتقل نمیشوند.",+ "importLabel": "قالب",+ "importPlaceholder": "قالب کپیشده را اینجا بچسبانید",+ "importFile": "بارگذاری فایل",+ "importEmpty": "قالبی بچسبانید تا محتوای آن را ببینید.",+ "importInvalid": "این یک قالب پروژه نیست یا آسیب دیده است.","save": "ذخیرهٔ قالب","saved": "قالب «{name}» ذخیره شد"},diff --git a/apps/web/messages/fa/teams.json b/apps/web/messages/fa/teams.jsonindex d16d72f2..ae52f18f 100644--- a/apps/web/messages/fa/teams.json+++ b/apps/web/messages/fa/teams.json@@ -188,19 +188,77 @@}},"templates": {- "ownerOnly": "فقط مالک یا مدیر تیم میتواند قالبهای پروژه را مدیریت کند.","empty": "هنوز قالب پروژهای وجود ندارد","emptyHint": "یک پروژه را بهعنوان قالب ذخیره کنید تا پروژههای جدید را از آن بسازید.",- "openProjects": "رفتن به پروژهها",+ "newAction": "قالب جدید",+ "teams": "تیمها",+ "allTeams": "همه تیمها",+ "noTeams": "هیچ تیمی",+ "editAction": "ویرایش قالب",+ "editHint": "محتوای قالب همانطور که ذخیره شده باقی میماند.",+ "copyAction": "کپی قالب",+ "copied": "قالب «{name}» کپی شد. آن را در فضای کاری دیگری بچسبانید تا وارد شود.",+ "downloadAction": "دانلود",+ "downloadFailed": "دانلود قالب ممکن نشد.",+ "importAction": "وارد کردن قالب","deleteAction": "حذف قالب","deleteDialog": {"title": "قالب «{name}» حذف شود؟","description": "پروژههایی که از آن ساخته شدهاند تغییری نمیکنند.",- "confirm": "حذف قالب"+ "confirm": "حذف قالب",+ "galleryNote": "صفحهاش در گالری هم برداشته میشود."},"panel": {"saved": "ذخیرهشده در {date}",- "none": "هیچ"+ "none": "هیچ",+ "teams": "تیمها: {teams}"+ },+ "publish": {+ "action": "انتشار",+ "published": "منتشرشده",+ "account": "حساب گالری",+ "publishingAs": "انتشار با",+ "authorProfile": "نمایه نویسنده",+ "changeEmail": "تغییر ایمیل",+ "rules": "قوانین گالری",+ "unlink": "لغو اتصال فضای کاری",+ "downloadable": "همه میتوانند آن را دانلود کنند",+ "private": "بدون تسک و افراد",+ "counts": "{states, plural, one {# وضعیت} other {# وضعیت}} · {types, plural, one {# نوع} other {# نوع}} · {fields, plural, one {# فیلد} other {# فیلد}}",+ "by": "از <b>{name}</b>",+ "authorHint": "روی هر قالبی که از {email} منتشر شود نمایش داده میشود.",+ "authorName": "نویسنده",+ "authorUrl": "پیوند نمایه",+ "optional": "اختیاری",+ "authorUrlInvalid": "باید با https:// شروع شود",+ "submit": "انتشار",+ "update": "بهروزرسانی صفحه",+ "live": "در دسترس",+ "since": "از {date}",+ "openPage": "باز کردن صفحه",+ "copyLink": "کپی پیوند",+ "linkCopied": "پیوند کپی شد",+ "copyFailed": "کپی پیوند ممکن نشد",+ "unpublish": "لغو انتشار",+ "unpublishConfirm": "صفحه برداشته شود؟",+ "unpublishHint": "پیوند آن دیگر کار نمیکند.",+ "keep": "نگه دار",+ "publishedToast": "منتشر شد",+ "updatedToast": "صفحه بهروز شد",+ "badge": "عمومی",+ "badgeHint": "از {date} در گالری",+ "link": {+ "intro": "یک بار ایمیلی را برای این فضای کاری تأیید کنید.",+ "email": "ایمیل",+ "emailHint": "بهصورت عمومی نمایش داده نمیشود",+ "agree": "با ارسال کد، <rules>قوانین گالری</rules> را میپذیرید.",+ "sendCode": "ارسال کد",+ "codeSent": "کد ارسالشده به {email} را وارد کنید",+ "code": "کد",+ "confirm": "تأیید",+ "resend": "ارسال دوباره",+ "resent": "کد جدید ارسال شد"+ }}},"panel": {diff --git a/apps/web/messages/fr/projects.json b/apps/web/messages/fr/projects.jsonindex f5dabf34..c1ab5a1c 100644--- a/apps/web/messages/fr/projects.json+++ b/apps/web/messages/fr/projects.json@@ -4,7 +4,23 @@"saveTemplateAction": "Enregistrer comme modèle","saveTemplate": {"title": "Enregistrer « {name} » comme modèle",+ "newTitle": "Nouveau modèle de projet","hint": "Le modèle garde une copie des paramètres choisis. Les modifications ultérieures du projet ne le changent pas. Les documents, les agents, les planifications et les webhooks ne sont pas enregistrés.",+ "teams": "Équipes",+ "allTeams": "Toutes les équipes de l'espace de travail",+ "allTeamsHint": "Désactivez pour choisir les équipes qui voient ce modèle lorsqu'elles créent un projet.",+ "team": "Équipe",+ "project": "Projet",+ "chooseTeam": "Choisissez une équipe",+ "chooseProject": "Choisissez un projet",+ "previewEmpty": "Choisissez un projet pour voir ce que contiendra le modèle.",+ "importTitle": "Importer un modèle de projet",+ "importHint": "Collez un modèle copié depuis un autre espace de travail, ou téléversez son fichier. Les personnes qu'il nommait ne sont pas reprises.",+ "importLabel": "Modèle",+ "importPlaceholder": "Collez ici le modèle copié",+ "importFile": "Téléverser un fichier",+ "importEmpty": "Collez un modèle pour voir ce qu'il contient.",+ "importInvalid": "Ce n'est pas un modèle de projet, ou il est endommagé.","save": "Enregistrer le modèle","saved": "Modèle « {name} » enregistré"},diff --git a/apps/web/messages/fr/teams.json b/apps/web/messages/fr/teams.jsonindex 56ced353..b14905b3 100644--- a/apps/web/messages/fr/teams.json+++ b/apps/web/messages/fr/teams.json@@ -188,19 +188,77 @@}},"templates": {- "ownerOnly": "Seul un propriétaire ou un responsable de l'équipe peut gérer les modèles de projet.","empty": "Aucun modèle de projet pour l'instant","emptyHint": "Enregistrez un projet comme modèle pour créer de nouveaux projets à partir de celui-ci.",- "openProjects": "Voir les projets",+ "newAction": "Nouveau modèle",+ "teams": "Équipes",+ "allTeams": "Toutes les équipes",+ "noTeams": "Aucune équipe",+ "editAction": "Modifier le modèle",+ "editHint": "Le contenu du modèle reste tel qu'il a été enregistré.",+ "copyAction": "Copier le modèle",+ "copied": "Modèle « {name} » copié. Collez-le dans un autre espace de travail pour l'importer.",+ "downloadAction": "Télécharger",+ "downloadFailed": "Impossible de télécharger le modèle.",+ "importAction": "Importer un modèle","deleteAction": "Supprimer le modèle","deleteDialog": {"title": "Supprimer le modèle « {name} » ?","description": "Les projets créés à partir de ce modèle restent inchangés.",- "confirm": "Supprimer le modèle"+ "confirm": "Supprimer le modèle",+ "galleryNote": "Sa page dans la galerie est aussi retirée."},"panel": {"saved": "Enregistré le {date}",- "none": "Aucun"+ "none": "Aucun",+ "teams": "Équipes : {teams}"+ },+ "publish": {+ "action": "Publier",+ "published": "Publié",+ "account": "Compte de la galerie",+ "publishingAs": "Publication en tant que",+ "authorProfile": "Profil de l’auteur",+ "changeEmail": "Changer d’e-mail",+ "rules": "Règles de la galerie",+ "unlink": "Dissocier l’espace de travail",+ "downloadable": "Tout le monde peut le télécharger",+ "private": "Ni tickets ni personnes",+ "counts": "{states, plural, one {# état} other {# états}} · {types, plural, one {# type} other {# types}} · {fields, plural, one {# champ} other {# champs}}",+ "by": "par <b>{name}</b>",+ "authorHint": "Affiché sur chaque modèle publié depuis {email}.",+ "authorName": "Auteur",+ "authorUrl": "Lien vers le profil",+ "optional": "Facultatif",+ "authorUrlInvalid": "Doit commencer par https://",+ "submit": "Publier",+ "update": "Mettre à jour la page",+ "live": "En ligne",+ "since": "depuis le {date}",+ "openPage": "Ouvrir la page",+ "copyLink": "Copier le lien",+ "linkCopied": "Lien copié",+ "copyFailed": "Impossible de copier le lien",+ "unpublish": "Dépublier",+ "unpublishConfirm": "Retirer la page ?",+ "unpublishHint": "Son lien ne fonctionnera plus.",+ "keep": "Garder",+ "publishedToast": "Publié",+ "updatedToast": "Page mise à jour",+ "badge": "Public",+ "badgeHint": "Dans la galerie depuis le {date}",+ "link": {+ "intro": "Confirmez une adresse e-mail une seule fois pour cet espace de travail.",+ "email": "E-mail",+ "emailHint": "Non affichée publiquement",+ "agree": "En envoyant le code, vous acceptez les <rules>règles de la galerie</rules>.",+ "sendCode": "Envoyer le code",+ "codeSent": "Saisissez le code envoyé à {email}",+ "code": "Code",+ "confirm": "Confirmer",+ "resend": "Renvoyer",+ "resent": "Nouveau code envoyé"+ }}},"panel": {diff --git a/apps/web/messages/id/projects.json b/apps/web/messages/id/projects.jsonindex cb94a6af..8d1f79d6 100644--- a/apps/web/messages/id/projects.json+++ b/apps/web/messages/id/projects.json@@ -4,7 +4,23 @@"saveTemplateAction": "Simpan sebagai templat","saveTemplate": {"title": "Simpan \"{name}\" sebagai templat",+ "newTitle": "Templat proyek baru","hint": "Templat menyimpan salinan pengaturan yang dipilih. Perubahan proyek setelahnya tidak mengubah templat. Dokumen, agen, jadwal, dan webhook tidak disimpan.",+ "teams": "Tim",+ "allTeams": "Semua tim di workspace",+ "allTeamsHint": "Matikan untuk memilih tim yang melihat templat ini saat membuat proyek.",+ "team": "Tim",+ "project": "Proyek",+ "chooseTeam": "Pilih tim",+ "chooseProject": "Pilih proyek",+ "previewEmpty": "Pilih proyek untuk melihat isi templat.",+ "importTitle": "Impor templat proyek",+ "importHint": "Tempel templat yang disalin dari ruang kerja lain, atau unggah berkasnya. Orang yang disebut di dalamnya tidak ikut.",+ "importLabel": "Templat",+ "importPlaceholder": "Tempel templat yang disalin di sini",+ "importFile": "Unggah berkas",+ "importEmpty": "Tempel templat untuk melihat isinya.",+ "importInvalid": "Ini bukan templat proyek, atau templat rusak.","save": "Simpan templat","saved": "Templat \"{name}\" disimpan"},diff --git a/apps/web/messages/id/teams.json b/apps/web/messages/id/teams.jsonindex c69470ed..ec1870b2 100644--- a/apps/web/messages/id/teams.json+++ b/apps/web/messages/id/teams.json@@ -188,19 +188,77 @@}},"templates": {- "ownerOnly": "Hanya pemilik atau manajer tim yang dapat mengelola templat proyek.","empty": "Belum ada templat proyek","emptyHint": "Simpan proyek sebagai templat untuk membuat proyek baru darinya.",- "openProjects": "Buka proyek",+ "newAction": "Templat baru",+ "teams": "Tim",+ "allTeams": "Semua tim",+ "noTeams": "Tidak ada tim",+ "editAction": "Edit templat",+ "editHint": "Isi templat tetap seperti saat disimpan.",+ "copyAction": "Salin templat",+ "copied": "Templat \"{name}\" disalin. Tempelkan di ruang kerja lain untuk mengimpornya.",+ "downloadAction": "Unduh",+ "downloadFailed": "Tidak dapat mengunduh templat.",+ "importAction": "Impor templat","deleteAction": "Hapus templat","deleteDialog": {"title": "Hapus templat \"{name}\"?","description": "Proyek yang dibuat dari templat ini tidak berubah.",- "confirm": "Hapus templat"+ "confirm": "Hapus templat",+ "galleryNote": "Halamannya di galeri juga diturunkan."},"panel": {"saved": "Disimpan {date}",- "none": "Tidak ada"+ "none": "Tidak ada",+ "teams": "Tim: {teams}"+ },+ "publish": {+ "action": "Terbitkan",+ "published": "Diterbitkan",+ "account": "Akun galeri",+ "publishingAs": "Menerbitkan sebagai",+ "authorProfile": "Profil penulis",+ "changeEmail": "Ganti email",+ "rules": "Aturan galeri",+ "unlink": "Putuskan workspace",+ "downloadable": "Siapa pun bisa mengunduhnya",+ "private": "Tanpa issue atau orang",+ "counts": "{states, plural, other {# status}} · {types, plural, other {# jenis}} · {fields, plural, other {# bidang}}",+ "by": "oleh <b>{name}</b>",+ "authorHint": "Ditampilkan di setiap templat yang diterbitkan dari {email}.",+ "authorName": "Penulis",+ "authorUrl": "Tautan profil",+ "optional": "Opsional",+ "authorUrlInvalid": "Harus diawali https://",+ "submit": "Terbitkan",+ "update": "Perbarui halaman",+ "live": "Aktif",+ "since": "sejak {date}",+ "openPage": "Buka halaman",+ "copyLink": "Salin tautan",+ "linkCopied": "Tautan disalin",+ "copyFailed": "Tidak dapat menyalin tautan",+ "unpublish": "Batalkan terbitan",+ "unpublishConfirm": "Turunkan halaman?",+ "unpublishHint": "Tautannya tidak akan berfungsi lagi.",+ "keep": "Biarkan",+ "publishedToast": "Diterbitkan",+ "updatedToast": "Halaman diperbarui",+ "badge": "Publik",+ "badgeHint": "Di galeri sejak {date}",+ "link": {+ "intro": "Konfirmasikan email sekali untuk workspace ini.",+ "email": "Email",+ "emailHint": "Tidak ditampilkan publik",+ "agree": "Dengan mengirim kode, Anda menerima <rules>aturan galeri</rules>.",+ "sendCode": "Kirim kode",+ "codeSent": "Masukkan kode yang dikirim ke {email}",+ "code": "Kode",+ "confirm": "Konfirmasi",+ "resend": "Kirim lagi",+ "resent": "Kode baru terkirim"+ }}},"panel": {diff --git a/apps/web/messages/ko/projects.json b/apps/web/messages/ko/projects.jsonindex 0be1e503..04e6bb62 100644--- a/apps/web/messages/ko/projects.json+++ b/apps/web/messages/ko/projects.json@@ -4,7 +4,23 @@"saveTemplateAction": "템플릿으로 저장","saveTemplate": {"title": "\"{name}\"을(를) 템플릿으로 저장",+ "newTitle": "새 프로젝트 템플릿","hint": "템플릿은 선택한 설정의 사본을 보관합니다. 이후 프로젝트를 변경해도 템플릿은 바뀌지 않습니다. 문서, AI 에이전트, 일정, 웹훅은 저장되지 않습니다.",+ "teams": "팀",+ "allTeams": "워크스페이스의 모든 팀",+ "allTeamsHint": "끄면 프로젝트를 만들 때 이 템플릿을 볼 팀을 선택할 수 있습니다.",+ "team": "팀",+ "project": "프로젝트",+ "chooseTeam": "팀 선택",+ "chooseProject": "프로젝트 선택",+ "previewEmpty": "프로젝트를 선택하면 템플릿에 포함될 내용을 볼 수 있습니다.",+ "importTitle": "프로젝트 템플릿 가져오기",+ "importHint": "다른 워크스페이스에서 복사한 템플릿을 붙여넣거나 파일을 업로드하세요. 템플릿에 지정된 사람은 포함되지 않습니다.",+ "importLabel": "템플릿",+ "importPlaceholder": "복사한 템플릿을 여기에 붙여넣으세요",+ "importFile": "파일 업로드",+ "importEmpty": "템플릿을 붙여넣으면 내용을 볼 수 있습니다.",+ "importInvalid": "프로젝트 템플릿이 아니거나 손상되었습니다.","save": "템플릿 저장","saved": "\"{name}\" 템플릿이 저장되었습니다"},diff --git a/apps/web/messages/ko/teams.json b/apps/web/messages/ko/teams.jsonindex c8d5cf7a..f37304be 100644--- a/apps/web/messages/ko/teams.json+++ b/apps/web/messages/ko/teams.json@@ -188,19 +188,77 @@}},"templates": {- "ownerOnly": "팀 소유자 또는 관리자만 프로젝트 템플릿을 관리할 수 있습니다.","empty": "아직 프로젝트 템플릿이 없습니다","emptyHint": "프로젝트를 템플릿으로 저장하면 그 템플릿으로 새 프로젝트를 만들 수 있습니다.",- "openProjects": "프로젝트로 이동",+ "newAction": "새 템플릿",+ "teams": "팀",+ "allTeams": "모든 팀",+ "noTeams": "팀 없음",+ "editAction": "템플릿 편집",+ "editHint": "템플릿에 담긴 내용은 저장된 그대로 유지됩니다.",+ "copyAction": "템플릿 복사",+ "copied": "템플릿 \"{name}\"을(를) 복사했습니다. 다른 워크스페이스에 붙여넣어 가져오세요.",+ "downloadAction": "다운로드",+ "downloadFailed": "템플릿을 다운로드하지 못했습니다.",+ "importAction": "템플릿 가져오기","deleteAction": "템플릿 삭제","deleteDialog": {"title": "\"{name}\" 템플릿을 삭제할까요?","description": "이 템플릿으로 만든 프로젝트는 그대로 유지됩니다.",- "confirm": "템플릿 삭제"+ "confirm": "템플릿 삭제",+ "galleryNote": "갤러리 페이지도 내려갑니다."},"panel": {"saved": "{date}에 저장됨",- "none": "없음"+ "none": "없음",+ "teams": "팀: {teams}"+ },+ "publish": {+ "action": "게시",+ "published": "게시됨",+ "account": "갤러리 계정",+ "publishingAs": "게시 계정",+ "authorProfile": "작성자 프로필",+ "changeEmail": "이메일 변경",+ "rules": "갤러리 규칙",+ "unlink": "워크스페이스 연결 해제",+ "downloadable": "누구나 다운로드할 수 있음",+ "private": "이슈와 사람은 포함되지 않음",+ "counts": "{states, plural, other {상태 #개}} · {types, plural, other {유형 #개}} · {fields, plural, other {필드 #개}}",+ "by": "작성자 <b>{name}</b>",+ "authorHint": "{email}(으)로 게시한 모든 템플릿에 표시됩니다.",+ "authorName": "작성자",+ "authorUrl": "프로필 링크",+ "optional": "선택 사항",+ "authorUrlInvalid": "https://로 시작해야 합니다",+ "submit": "게시",+ "update": "페이지 업데이트",+ "live": "게시 중",+ "since": "{date}부터",+ "openPage": "페이지 열기",+ "copyLink": "링크 복사",+ "linkCopied": "링크를 복사했습니다",+ "copyFailed": "링크를 복사하지 못했습니다",+ "unpublish": "게시 취소",+ "unpublishConfirm": "페이지를 내릴까요?",+ "unpublishHint": "링크가 더 이상 작동하지 않습니다.",+ "keep": "유지",+ "publishedToast": "게시됨",+ "updatedToast": "페이지가 업데이트됨",+ "badge": "공개",+ "badgeHint": "{date}부터 갤러리에 게시됨",+ "link": {+ "intro": "이 워크스페이스에 대해 이메일을 한 번만 확인하세요.",+ "email": "이메일",+ "emailHint": "공개되지 않음",+ "agree": "코드를 보내면 <rules>갤러리 규칙</rules>에 동의하는 것입니다.",+ "sendCode": "코드 보내기",+ "codeSent": "{email}(으)로 보낸 코드를 입력하세요",+ "code": "코드",+ "confirm": "확인",+ "resend": "다시 보내기",+ "resent": "새 코드를 보냈습니다"+ }}},"panel": {diff --git a/apps/web/messages/pt-BR/projects.json b/apps/web/messages/pt-BR/projects.jsonindex d410bde6..2b4781a6 100644--- a/apps/web/messages/pt-BR/projects.json+++ b/apps/web/messages/pt-BR/projects.json@@ -4,7 +4,23 @@"saveTemplateAction": "Salvar como modelo","saveTemplate": {"title": "Salvar \"{name}\" como modelo",+ "newTitle": "Novo modelo de projeto","hint": "O modelo guarda uma cópia das configurações escolhidas. Mudanças posteriores no projeto não o alteram. Documentos, agentes, agendamentos e webhooks não são salvos.",+ "teams": "Equipes",+ "allTeams": "Todas as equipes do workspace",+ "allTeamsHint": "Desative para escolher as equipes que veem este modelo ao criar um projeto.",+ "team": "Equipe",+ "project": "Projeto",+ "chooseTeam": "Escolha uma equipe",+ "chooseProject": "Escolha um projeto",+ "previewEmpty": "Escolha um projeto para ver o que o modelo vai ter.",+ "importTitle": "Importar um modelo de projeto",+ "importHint": "Cole um modelo copiado de outro espaço de trabalho ou envie o arquivo dele. As pessoas citadas nele ficam de fora.",+ "importLabel": "Modelo",+ "importPlaceholder": "Cole aqui o modelo copiado",+ "importFile": "Enviar arquivo",+ "importEmpty": "Cole um modelo para ver o que ele contém.",+ "importInvalid": "Isto não é um modelo de projeto, ou ele está danificado.","save": "Salvar modelo","saved": "Modelo \"{name}\" salvo"},diff --git a/apps/web/messages/pt-BR/teams.json b/apps/web/messages/pt-BR/teams.jsonindex 6f893be4..5a280af8 100644--- a/apps/web/messages/pt-BR/teams.json+++ b/apps/web/messages/pt-BR/teams.json@@ -188,19 +188,77 @@}},"templates": {- "ownerOnly": "Só um dono ou gerente do time pode gerenciar modelos de projeto.","empty": "Nenhum modelo de projeto ainda","emptyHint": "Salve um projeto como modelo para criar novos projetos a partir dele.",- "openProjects": "Ir para projetos",+ "newAction": "Novo modelo",+ "teams": "Equipes",+ "allTeams": "Todas as equipes",+ "noTeams": "Nenhuma equipe",+ "editAction": "Editar modelo",+ "editHint": "O conteúdo do modelo continua como foi salvo.",+ "copyAction": "Copiar modelo",+ "copied": "Modelo \"{name}\" copiado. Cole-o em outro espaço de trabalho para importá-lo.",+ "downloadAction": "Baixar",+ "downloadFailed": "Não foi possível baixar o modelo.",+ "importAction": "Importar modelo","deleteAction": "Excluir modelo","deleteDialog": {"title": "Excluir o modelo \"{name}\"?","description": "Os projetos criados a partir dele continuam iguais.",- "confirm": "Excluir modelo"+ "confirm": "Excluir modelo",+ "galleryNote": "A página dele na galeria também sai do ar."},"panel": {"saved": "Salvo em {date}",- "none": "Nenhum"+ "none": "Nenhum",+ "teams": "Equipes: {teams}"+ },+ "publish": {+ "action": "Publicar",+ "published": "Publicado",+ "account": "Conta da galeria",+ "publishingAs": "Publicando como",+ "authorProfile": "Perfil do autor",+ "changeEmail": "Trocar e-mail",+ "rules": "Regras da galeria",+ "unlink": "Desvincular workspace",+ "downloadable": "Qualquer pessoa pode baixar",+ "private": "Sem issues nem pessoas",+ "counts": "{states, plural, one {# estado} other {# estados}} · {types, plural, one {# tipo} other {# tipos}} · {fields, plural, one {# campo} other {# campos}}",+ "by": "por <b>{name}</b>",+ "authorHint": "Aparece em todos os modelos publicados a partir de {email}.",+ "authorName": "Autor",+ "authorUrl": "Link do perfil",+ "optional": "Opcional",+ "authorUrlInvalid": "Deve começar com https://",+ "submit": "Publicar",+ "update": "Atualizar página",+ "live": "No ar",+ "since": "desde {date}",+ "openPage": "Abrir página",+ "copyLink": "Copiar link",+ "linkCopied": "Link copiado",+ "copyFailed": "Não foi possível copiar o link",+ "unpublish": "Despublicar",+ "unpublishConfirm": "Tirar a página do ar?",+ "unpublishHint": "O link dela vai parar de funcionar.",+ "keep": "Manter",+ "publishedToast": "Publicado",+ "updatedToast": "Página atualizada",+ "badge": "Público",+ "badgeHint": "Na galeria desde {date}",+ "link": {+ "intro": "Confirme um e-mail uma única vez para este workspace.",+ "email": "E-mail",+ "emailHint": "Não aparece publicamente",+ "agree": "Ao enviar o código, você aceita as <rules>regras da galeria</rules>.",+ "sendCode": "Enviar código",+ "codeSent": "Digite o código enviado para {email}",+ "code": "Código",+ "confirm": "Confirmar",+ "resend": "Enviar de novo",+ "resent": "Novo código enviado"+ }}},"panel": {diff --git a/apps/web/messages/ru/projects.json b/apps/web/messages/ru/projects.jsonindex 86dfc85c..5c302a43 100644--- a/apps/web/messages/ru/projects.json+++ b/apps/web/messages/ru/projects.json@@ -4,7 +4,23 @@"saveTemplateAction": "Сохранить как шаблон","saveTemplate": {"title": "Сохранить «{name}» как шаблон",+ "newTitle": "Новый шаблон проекта","hint": "Шаблон хранит копию выбранных настроек. Изменения проекта после сохранения его не меняют. Документы, агенты, расписания и вебхуки не сохраняются.",+ "teams": "Команды",+ "allTeams": "Все команды воркспейса",+ "allTeamsHint": "Выключите, чтобы выбрать команды, которые увидят этот шаблон при создании проекта.",+ "team": "Команда",+ "project": "Проект",+ "chooseTeam": "Выберите команду",+ "chooseProject": "Выберите проект",+ "previewEmpty": "Выберите проект, чтобы увидеть, что будет в шаблоне.",+ "importTitle": "Импорт шаблона проекта",+ "importHint": "Вставьте шаблон, скопированный в другом воркспейсе, или загрузите его файл. Люди, указанные в нём, не переносятся.",+ "importLabel": "Шаблон",+ "importPlaceholder": "Вставьте скопированный шаблон",+ "importFile": "Загрузить файл",+ "importEmpty": "Вставьте шаблон, чтобы увидеть, что в нём.",+ "importInvalid": "Это не шаблон проекта, или он повреждён.","save": "Сохранить шаблон","saved": "Шаблон «{name}» сохранён"},diff --git a/apps/web/messages/ru/teams.json b/apps/web/messages/ru/teams.jsonindex ddc5ac09..d76dc561 100644--- a/apps/web/messages/ru/teams.json+++ b/apps/web/messages/ru/teams.json@@ -188,19 +188,77 @@}},"templates": {- "ownerOnly": "Шаблонами проектов управляют только владелец или менеджер команды.","empty": "Шаблонов проектов пока нет","emptyHint": "Сохраните проект как шаблон, чтобы создавать по нему новые проекты.",- "openProjects": "Перейти к проектам",+ "newAction": "Новый шаблон",+ "teams": "Команды",+ "allTeams": "Все команды",+ "noTeams": "Ни одной команды",+ "editAction": "Изменить шаблон",+ "editHint": "Содержимое шаблона остаётся таким, каким его сохранили.",+ "copyAction": "Копировать шаблон",+ "copied": "Шаблон «{name}» скопирован. Вставьте его в другой воркспейс, чтобы импортировать.",+ "downloadAction": "Скачать",+ "downloadFailed": "Не удалось скачать шаблон.",+ "importAction": "Импортировать шаблон","deleteAction": "Удалить шаблон","deleteDialog": {"title": "Удалить шаблон «{name}»?","description": "Проекты, созданные по нему, не изменятся.",- "confirm": "Удалить шаблон"+ "confirm": "Удалить шаблон",+ "galleryNote": "Его страница в галерее тоже исчезнет."},"panel": {"saved": "Сохранён {date}",- "none": "Нет"+ "none": "Нет",+ "teams": "Команды: {teams}"+ },+ "publish": {+ "action": "Опубликовать",+ "published": "Опубликован",+ "account": "Аккаунт галереи",+ "publishingAs": "Публикуете как",+ "authorProfile": "Профиль автора",+ "changeEmail": "Сменить email",+ "rules": "Правила галереи",+ "unlink": "Отвязать воркспейс",+ "downloadable": "Скачать может любой",+ "private": "Без задач и людей",+ "counts": "{states, plural, one {# статус} few {# статуса} many {# статусов} other {# статуса}} · {types, plural, one {# тип} few {# типа} many {# типов} other {# типа}} · {fields, plural, one {# поле} few {# поля} many {# полей} other {# поля}}",+ "by": "автор <b>{name}</b>",+ "authorHint": "Показывается на всех шаблонах, опубликованных с {email}.",+ "authorName": "Автор",+ "authorUrl": "Ссылка на профиль",+ "optional": "Необязательно",+ "authorUrlInvalid": "Ссылка должна начинаться с https://",+ "submit": "Опубликовать",+ "update": "Обновить страницу",+ "live": "Доступен",+ "since": "с {date}",+ "openPage": "Открыть страницу",+ "copyLink": "Копировать ссылку",+ "linkCopied": "Ссылка скопирована",+ "copyFailed": "Не удалось скопировать ссылку",+ "unpublish": "Снять с публикации",+ "unpublishConfirm": "Снять страницу?",+ "unpublishHint": "Её ссылка перестанет работать.",+ "keep": "Оставить",+ "publishedToast": "Опубликовано",+ "updatedToast": "Страница обновлена",+ "badge": "Публичный",+ "badgeHint": "В галерее с {date}",+ "link": {+ "intro": "Подтвердите email один раз для этого воркспейса.",+ "email": "Email",+ "emailHint": "Не показывается публично",+ "agree": "Отправляя код, вы принимаете <rules>правила галереи</rules>.",+ "sendCode": "Отправить код",+ "codeSent": "Введите код, отправленный на {email}",+ "code": "Код",+ "confirm": "Подтвердить",+ "resend": "Отправить ещё раз",+ "resent": "Новый код отправлен"+ }}},"panel": {diff --git a/apps/web/messages/tr/projects.json b/apps/web/messages/tr/projects.jsonindex 09a7b3a1..17888f7a 100644--- a/apps/web/messages/tr/projects.json+++ b/apps/web/messages/tr/projects.json@@ -4,7 +4,23 @@"saveTemplateAction": "Şablon olarak kaydet","saveTemplate": {"title": "\"{name}\" projesini şablon olarak kaydet",+ "newTitle": "Yeni proje şablonu","hint": "Şablon, seçilen ayarların bir kopyasını saklar. Projede sonradan yapılan değişiklikler şablonu değiştirmez. Belgeler, ajanlar, zamanlamalar ve webhook'lar kaydedilmez.",+ "teams": "Takımlar",+ "allTeams": "Çalışma alanının tüm takımları",+ "allTeamsHint": "Proje oluştururken bu şablonu görecek takımları seçmek için kapatın.",+ "team": "Takım",+ "project": "Proje",+ "chooseTeam": "Bir takım seçin",+ "chooseProject": "Bir proje seçin",+ "previewEmpty": "Şablonda neler olacağını görmek için bir proje seçin.",+ "importTitle": "Proje şablonu içe aktar",+ "importHint": "Başka bir çalışma alanından kopyalanan şablonu yapıştırın veya dosyasını yükleyin. İçinde adı geçen kişiler aktarılmaz.",+ "importLabel": "Şablon",+ "importPlaceholder": "Kopyalanan şablonu buraya yapıştırın",+ "importFile": "Dosya yükle",+ "importEmpty": "İçeriğini görmek için bir şablon yapıştırın.",+ "importInvalid": "Bu bir proje şablonu değil veya bozuk.","save": "Şablonu kaydet","saved": "\"{name}\" şablonu kaydedildi"},diff --git a/apps/web/messages/tr/teams.json b/apps/web/messages/tr/teams.jsonindex 28a1c332..e42d6746 100644--- a/apps/web/messages/tr/teams.json+++ b/apps/web/messages/tr/teams.json@@ -188,19 +188,77 @@}},"templates": {- "ownerOnly": "Proje şablonlarını yalnızca bir takım sahibi veya yöneticisi yönetebilir.","empty": "Henüz proje şablonu yok","emptyHint": "Yeni projeleri bir şablondan başlatmak için bir projeyi şablon olarak kaydedin.",- "openProjects": "Projelere git",+ "newAction": "Yeni şablon",+ "teams": "Takımlar",+ "allTeams": "Tüm takımlar",+ "noTeams": "Hiçbir takım",+ "editAction": "Şablonu düzenle",+ "editHint": "Şablonun içeriği kaydedildiği gibi kalır.",+ "copyAction": "Şablonu kopyala",+ "copied": "\"{name}\" şablonu kopyalandı. İçe aktarmak için başka bir çalışma alanına yapıştırın.",+ "downloadAction": "İndir",+ "downloadFailed": "Şablon indirilemedi.",+ "importAction": "Şablonu içe aktar","deleteAction": "Şablonu sil","deleteDialog": {"title": "\"{name}\" şablonu silinsin mi?","description": "Bu şablondan oluşturulan projeler değişmez.",- "confirm": "Şablonu sil"+ "confirm": "Şablonu sil",+ "galleryNote": "Galerideki sayfası da kaldırılır."},"panel": {"saved": "{date} tarihinde kaydedildi",- "none": "Yok"+ "none": "Yok",+ "teams": "Takımlar: {teams}"+ },+ "publish": {+ "action": "Yayınla",+ "published": "Yayında",+ "account": "Galeri hesabı",+ "publishingAs": "Yayınlayan",+ "authorProfile": "Yazar profili",+ "changeEmail": "E-postayı değiştir",+ "rules": "Galeri kuralları",+ "unlink": "Çalışma alanının bağlantısını kaldır",+ "downloadable": "Herkes indirebilir",+ "private": "İş ve kişi içermez",+ "counts": "{states, plural, other {# durum}} · {types, plural, other {# tür}} · {fields, plural, other {# alan}}",+ "by": "<b>{name}</b> tarafından",+ "authorHint": "{email} adresinden yayınlanan her şablonda gösterilir.",+ "authorName": "Yazar",+ "authorUrl": "Profil bağlantısı",+ "optional": "İsteğe bağlı",+ "authorUrlInvalid": "https:// ile başlamalı",+ "submit": "Yayınla",+ "update": "Sayfayı güncelle",+ "live": "Yayında",+ "since": "{date} tarihinden beri",+ "openPage": "Sayfayı aç",+ "copyLink": "Bağlantıyı kopyala",+ "linkCopied": "Bağlantı kopyalandı",+ "copyFailed": "Bağlantı kopyalanamadı",+ "unpublish": "Yayından kaldır",+ "unpublishConfirm": "Sayfa kaldırılsın mı?",+ "unpublishHint": "Bağlantısı artık çalışmaz.",+ "keep": "Kalsın",+ "publishedToast": "Yayınlandı",+ "updatedToast": "Sayfa güncellendi",+ "badge": "Herkese açık",+ "badgeHint": "{date} tarihinden beri galeride",+ "link": {+ "intro": "Bu çalışma alanı için bir e-postayı bir kez doğrulayın.",+ "email": "E-posta",+ "emailHint": "Herkese gösterilmez",+ "agree": "Kodu göndererek <rules>galeri kurallarını</rules> kabul etmiş olursunuz.",+ "sendCode": "Kod gönder",+ "codeSent": "{email} adresine gönderilen kodu girin",+ "code": "Kod",+ "confirm": "Doğrula",+ "resend": "Yeniden gönder",+ "resent": "Yeni kod gönderildi"+ }}},"panel": {diff --git a/apps/web/messages/uk/projects.json b/apps/web/messages/uk/projects.jsonindex f5d1ea69..ee401312 100644--- a/apps/web/messages/uk/projects.json+++ b/apps/web/messages/uk/projects.json@@ -4,7 +4,23 @@"saveTemplateAction": "Зберегти як шаблон","saveTemplate": {"title": "Зберегти «{name}» як шаблон",+ "newTitle": "Новий шаблон проєкту","hint": "Шаблон зберігає копію вибраних налаштувань. Зміни проєкту після збереження його не змінюють. Документи, агенти, розклади та вебхуки не зберігаються.",+ "teams": "Команди",+ "allTeams": "Усі команди воркспейсу",+ "allTeamsHint": "Вимкніть, щоб вибрати команди, які побачать цей шаблон під час створення проєкту.",+ "team": "Команда",+ "project": "Проєкт",+ "chooseTeam": "Виберіть команду",+ "chooseProject": "Виберіть проєкт",+ "previewEmpty": "Виберіть проєкт, щоб побачити, що буде в шаблоні.",+ "importTitle": "Імпорт шаблону проєкту",+ "importHint": "Вставте шаблон, скопійований в іншому воркспейсі, або завантажте його файл. Люди, вказані в ньому, не переносяться.",+ "importLabel": "Шаблон",+ "importPlaceholder": "Вставте скопійований шаблон",+ "importFile": "Завантажити файл",+ "importEmpty": "Вставте шаблон, щоб побачити, що в ньому.",+ "importInvalid": "Це не шаблон проєкту, або він пошкоджений.","save": "Зберегти шаблон","saved": "Шаблон «{name}» збережено"},diff --git a/apps/web/messages/uk/teams.json b/apps/web/messages/uk/teams.jsonindex 879e507c..3360bdd5 100644--- a/apps/web/messages/uk/teams.json+++ b/apps/web/messages/uk/teams.json@@ -188,19 +188,77 @@}},"templates": {- "ownerOnly": "Шаблонами проєктів керують лише власник або менеджер команди.","empty": "Шаблонів проєктів поки немає","emptyHint": "Збережіть проєкт як шаблон, щоб створювати за ним нові проєкти.",- "openProjects": "Перейти до проєктів",+ "newAction": "Новий шаблон",+ "teams": "Команди",+ "allTeams": "Усі команди",+ "noTeams": "Жодної команди",+ "editAction": "Змінити шаблон",+ "editHint": "Вміст шаблону лишається таким, яким його зберегли.",+ "copyAction": "Копіювати шаблон",+ "copied": "Шаблон «{name}» скопійовано. Вставте його в інший воркспейс, щоб імпортувати.",+ "downloadAction": "Завантажити",+ "downloadFailed": "Не вдалося завантажити шаблон.",+ "importAction": "Імпортувати шаблон","deleteAction": "Видалити шаблон","deleteDialog": {"title": "Видалити шаблон «{name}»?","description": "Проєкти, створені за ним, не зміняться.",- "confirm": "Видалити шаблон"+ "confirm": "Видалити шаблон",+ "galleryNote": "Його сторінка в галереї теж зникне."},"panel": {"saved": "Збережено {date}",- "none": "Немає"+ "none": "Немає",+ "teams": "Команди: {teams}"+ },+ "publish": {+ "action": "Опублікувати",+ "published": "Опублікований",+ "account": "Акаунт галереї",+ "publishingAs": "Публікуєте як",+ "authorProfile": "Профіль автора",+ "changeEmail": "Змінити email",+ "rules": "Правила галереї",+ "unlink": "Відв’язати воркспейс",+ "downloadable": "Завантажити може будь-хто",+ "private": "Без задач і людей",+ "counts": "{states, plural, one {# статус} few {# статуси} many {# статусів} other {# статусу}} · {types, plural, one {# тип} few {# типи} many {# типів} other {# типу}} · {fields, plural, one {# поле} few {# поля} many {# полів} other {# поля}}",+ "by": "автор <b>{name}</b>",+ "authorHint": "Показується на всіх шаблонах, опублікованих з {email}.",+ "authorName": "Автор",+ "authorUrl": "Посилання на профіль",+ "optional": "Необов’язково",+ "authorUrlInvalid": "Посилання має починатися з https://",+ "submit": "Опублікувати",+ "update": "Оновити сторінку",+ "live": "Доступний",+ "since": "з {date}",+ "openPage": "Відкрити сторінку",+ "copyLink": "Копіювати посилання",+ "linkCopied": "Посилання скопійовано",+ "copyFailed": "Не вдалося скопіювати посилання",+ "unpublish": "Зняти з публікації",+ "unpublishConfirm": "Зняти сторінку?",+ "unpublishHint": "Її посилання перестане працювати.",+ "keep": "Залишити",+ "publishedToast": "Опубліковано",+ "updatedToast": "Сторінку оновлено",+ "badge": "Публічний",+ "badgeHint": "У галереї з {date}",+ "link": {+ "intro": "Підтвердьте email один раз для цього воркспейсу.",+ "email": "Email",+ "emailHint": "Не показується публічно",+ "agree": "Надсилаючи код, ви приймаєте <rules>правила галереї</rules>.",+ "sendCode": "Надіслати код",+ "codeSent": "Введіть код, надісланий на {email}",+ "code": "Код",+ "confirm": "Підтвердити",+ "resend": "Надіслати ще раз",+ "resent": "Новий код надіслано"+ }}},"panel": {diff --git a/apps/web/messages/zh-CN/projects.json b/apps/web/messages/zh-CN/projects.jsonindex 9a1828be..62acfde3 100644--- a/apps/web/messages/zh-CN/projects.json+++ b/apps/web/messages/zh-CN/projects.json@@ -4,7 +4,23 @@"saveTemplateAction": "另存为模板","saveTemplate": {"title": "将“{name}”另存为模板",+ "newTitle": "新建项目模板","hint": "模板会保存所选设置的副本。之后对项目的更改不会影响模板。文档、代理、定时任务和 Webhook 不会保存。",+ "teams": "团队",+ "allTeams": "工作区的所有团队",+ "allTeamsHint": "关闭后可选择在创建项目时能看到此模板的团队。",+ "team": "团队",+ "project": "项目",+ "chooseTeam": "选择团队",+ "chooseProject": "选择项目",+ "previewEmpty": "选择一个项目,查看模板将包含的内容。",+ "importTitle": "导入项目模板",+ "importHint": "粘贴从其他工作区复制的模板,或上传其文件。模板中指定的人员不会导入。",+ "importLabel": "模板",+ "importPlaceholder": "在此粘贴复制的模板",+ "importFile": "上传文件",+ "importEmpty": "粘贴模板即可查看其内容。",+ "importInvalid": "这不是项目模板,或模板已损坏。","save": "保存模板","saved": "模板“{name}”已保存"},diff --git a/apps/web/messages/zh-CN/teams.json b/apps/web/messages/zh-CN/teams.jsonindex 18187660..23f9e016 100644--- a/apps/web/messages/zh-CN/teams.json+++ b/apps/web/messages/zh-CN/teams.json@@ -188,19 +188,77 @@}},"templates": {- "ownerOnly": "只有团队所有者或管理者可以管理项目模板。","empty": "暂无项目模板","emptyHint": "将项目另存为模板,即可基于它创建新项目。",- "openProjects": "前往项目",+ "newAction": "新建模板",+ "teams": "团队",+ "allTeams": "所有团队",+ "noTeams": "无团队",+ "editAction": "编辑模板",+ "editHint": "模板内容保持保存时的样子。",+ "copyAction": "复制模板",+ "copied": "已复制模板“{name}”。将其粘贴到另一个工作区即可导入。",+ "downloadAction": "下载",+ "downloadFailed": "无法下载模板。",+ "importAction": "导入模板","deleteAction": "删除模板","deleteDialog": {"title": "删除模板“{name}”?","description": "基于该模板创建的项目不受影响。",- "confirm": "删除模板"+ "confirm": "删除模板",+ "galleryNote": "它在图库中的页面也会下架。"},"panel": {"saved": "保存于 {date}",- "none": "无"+ "none": "无",+ "teams": "团队:{teams}"+ },+ "publish": {+ "action": "发布",+ "published": "已发布",+ "account": "图库账号",+ "publishingAs": "发布身份",+ "authorProfile": "作者资料",+ "changeEmail": "更换邮箱",+ "rules": "图库规则",+ "unlink": "解除工作区关联",+ "downloadable": "任何人都可下载",+ "private": "不含工作项和成员",+ "counts": "{states, plural, other {# 个状态}} · {types, plural, other {# 种类型}} · {fields, plural, other {# 个字段}}",+ "by": "作者 <b>{name}</b>",+ "authorHint": "显示在从 {email} 发布的每个模板上。",+ "authorName": "作者",+ "authorUrl": "个人主页链接",+ "optional": "可选",+ "authorUrlInvalid": "必须以 https:// 开头",+ "submit": "发布",+ "update": "更新页面",+ "live": "已上线",+ "since": "自 {date}",+ "openPage": "打开页面",+ "copyLink": "复制链接",+ "linkCopied": "链接已复制",+ "copyFailed": "无法复制链接",+ "unpublish": "取消发布",+ "unpublishConfirm": "下架页面?",+ "unpublishHint": "它的链接将失效。",+ "keep": "保留",+ "publishedToast": "已发布",+ "updatedToast": "页面已更新",+ "badge": "公开",+ "badgeHint": "自 {date} 起在图库中",+ "link": {+ "intro": "为这个工作区确认一次邮箱。",+ "email": "邮箱",+ "emailHint": "不会公开显示",+ "agree": "发送验证码即表示你接受<rules>图库规则</rules>。",+ "sendCode": "发送验证码",+ "codeSent": "输入发送到 {email} 的验证码",+ "code": "验证码",+ "confirm": "确认",+ "resend": "重新发送",+ "resent": "已发送新验证码"+ }}},"panel": {diff --git a/apps/web/messages/zh-TW/projects.json b/apps/web/messages/zh-TW/projects.jsonindex 9944129c..0298f7d2 100644--- a/apps/web/messages/zh-TW/projects.json+++ b/apps/web/messages/zh-TW/projects.json@@ -4,7 +4,23 @@"saveTemplateAction": "另存為範本","saveTemplate": {"title": "將「{name}」另存為範本",+ "newTitle": "新增專案範本","hint": "範本會保存所選設定的副本。之後對專案的變更不會影響範本。文件、代理、排程和 Webhook 不會儲存。",+ "teams": "團隊",+ "allTeams": "工作區的所有團隊",+ "allTeamsHint": "關閉後可選擇在建立專案時能看到此範本的團隊。",+ "team": "團隊",+ "project": "專案",+ "chooseTeam": "選擇團隊",+ "chooseProject": "選擇專案",+ "previewEmpty": "選擇一個專案,查看範本將包含的內容。",+ "importTitle": "匯入專案範本",+ "importHint": "貼上從其他工作區複製的範本,或上傳其檔案。範本中指定的人員不會匯入。",+ "importLabel": "範本",+ "importPlaceholder": "在此貼上複製的範本",+ "importFile": "上傳檔案",+ "importEmpty": "貼上範本即可查看其內容。",+ "importInvalid": "這不是專案範本,或範本已損壞。","save": "儲存範本","saved": "範本「{name}」已儲存"},diff --git a/apps/web/messages/zh-TW/teams.json b/apps/web/messages/zh-TW/teams.jsonindex e6445ff1..c6ea7940 100644--- a/apps/web/messages/zh-TW/teams.json+++ b/apps/web/messages/zh-TW/teams.json@@ -188,19 +188,77 @@}},"templates": {- "ownerOnly": "只有團隊所有者或管理者可以管理專案範本。","empty": "暫無專案範本","emptyHint": "將專案另存為範本,即可依據它建立新專案。",- "openProjects": "前往專案",+ "newAction": "新增範本",+ "teams": "團隊",+ "allTeams": "所有團隊",+ "noTeams": "無團隊",+ "editAction": "編輯範本",+ "editHint": "範本內容維持儲存時的樣子。",+ "copyAction": "複製範本",+ "copied": "已複製範本「{name}」。將其貼到另一個工作區即可匯入。",+ "downloadAction": "下載",+ "downloadFailed": "無法下載範本。",+ "importAction": "匯入範本","deleteAction": "刪除範本","deleteDialog": {"title": "刪除範本「{name}」?","description": "以此範本建立的專案不受影響。",- "confirm": "刪除範本"+ "confirm": "刪除範本",+ "galleryNote": "它在圖庫中的頁面也會下架。"},"panel": {"saved": "儲存於 {date}",- "none": "無"+ "none": "無",+ "teams": "團隊:{teams}"+ },+ "publish": {+ "action": "發布",+ "published": "已發布",+ "account": "圖庫帳號",+ "publishingAs": "發布身分",+ "authorProfile": "作者資料",+ "changeEmail": "變更電子郵件",+ "rules": "圖庫規則",+ "unlink": "解除工作區連結",+ "downloadable": "任何人都能下載",+ "private": "不含工作項目和成員",+ "counts": "{states, plural, other {# 個狀態}} · {types, plural, other {# 種類型}} · {fields, plural, other {# 個欄位}}",+ "by": "作者 <b>{name}</b>",+ "authorHint": "顯示在從 {email} 發布的每個範本上。",+ "authorName": "作者",+ "authorUrl": "個人檔案連結",+ "optional": "選填",+ "authorUrlInvalid": "必須以 https:// 開頭",+ "submit": "發布",+ "update": "更新頁面",+ "live": "已上線",+ "since": "自 {date}",+ "openPage": "開啟頁面",+ "copyLink": "複製連結",+ "linkCopied": "已複製連結",+ "copyFailed": "無法複製連結",+ "unpublish": "取消發布",+ "unpublishConfirm": "下架頁面?",+ "unpublishHint": "它的連結將失效。",+ "keep": "保留",+ "publishedToast": "已發布",+ "updatedToast": "頁面已更新",+ "badge": "公開",+ "badgeHint": "自 {date} 起在圖庫中",+ "link": {+ "intro": "為這個工作區確認一次電子郵件。",+ "email": "電子郵件",+ "emailHint": "不會公開顯示",+ "agree": "傳送驗證碼即表示你接受<rules>圖庫規則</rules>。",+ "sendCode": "傳送驗證碼",+ "codeSent": "輸入傳送到 {email} 的驗證碼",+ "code": "驗證碼",+ "confirm": "確認",+ "resend": "重新傳送",+ "resent": "已傳送新驗證碼"+ }}},"panel": {diff --git a/apps/web/src/app/[teamRef]/settings/templates/page.tsx b/apps/web/src/app/[teamRef]/settings/templates/page.tsxdeleted file mode 100644index 97b37385..00000000--- a/apps/web/src/app/[teamRef]/settings/templates/page.tsx+++ /dev/null@@ -1,9 +0,0 @@-'use client';--import TeamTemplatesSection from '@/features/teams/components/templates/TeamTemplatesSection';-import { useRouteTeam } from '@/features/teams/hooks/useRouteTeam';--export default function Page() {- const team = useRouteTeam();- return team && <TeamTemplatesSection teamId={team.id} />;-}diff --git a/apps/web/src/app/workspaces/[workspaceId]/templates/page.tsx b/apps/web/src/app/workspaces/[workspaceId]/templates/page.tsxnew file mode 100644index 00000000..ee9c2662--- /dev/null+++ b/apps/web/src/app/workspaces/[workspaceId]/templates/page.tsx@@ -0,0 +1,9 @@+'use client';++import WorkspaceTemplatesSection from '@/features/teams/components/workspace/WorkspaceTemplatesSection';+import { useRouteWorkspaceId } from '@/features/teams/hooks/useRouteWorkspaceId';++export default function Page() {+ const workspaceId = useRouteWorkspaceId();+ return workspaceId !== null && <WorkspaceTemplatesSection workspaceId={workspaceId} />;+}diff --git a/apps/web/src/components/common/RowAction.tsx b/apps/web/src/components/common/RowAction.tsxindex d1bbeafb..25a39867 100644--- a/apps/web/src/components/common/RowAction.tsx+++ b/apps/web/src/components/common/RowAction.tsx@@ -11,11 +11,13 @@ export default function RowAction({icon: Icon,label,destructive,+ className,onClick,}: {icon: LucideIcon;label: string;destructive?: boolean;+ className?: string;onClick: () => void;}) {return (@@ -27,6 +29,7 @@ export default function RowAction({className={cn('size-8 text-muted-foreground',destructive ? 'hover:text-destructive' : 'hover:text-foreground',+ className,)}aria-label={label}onClick={onClick}diff --git a/apps/web/src/components/common/overlay/Modal.tsx b/apps/web/src/components/common/overlay/Modal.tsxindex df98b454..bd9c2c5a 100644--- a/apps/web/src/components/common/overlay/Modal.tsx+++ b/apps/web/src/components/common/overlay/Modal.tsx@@ -41,6 +41,7 @@ export default function Modal({title,crumb,headerAction,+ controls,description,scope,onClose,@@ -58,6 +59,8 @@ export default function Modal({// caller that passes one has to focus its own first field through// onOpenAutoFocus.headerAction?: ReactNode;+ // Icon buttons shown before the fullscreen and close buttons.+ controls?: ReactNode;description?: string;// Leading breadcrumb naming what the dialog acts in: a project key, a team.scope?: ReactNode;@@ -134,6 +137,7 @@ export default function Modal({{/* After the body: Radix focuses the first tabbable node on open, whichshould be a field of the body, not a control. */}<div className="absolute end-3 top-3 flex items-center gap-1">+ {controls}{onToggleFullscreen && (<Buttonvariant="ghost"diff --git a/apps/web/src/components/common/project-template/ProjectTemplateContents.tsx b/apps/web/src/components/common/project-template/ProjectTemplateContents.tsxindex bcbf973b..46edae94 100644--- a/apps/web/src/components/common/project-template/ProjectTemplateContents.tsx+++ b/apps/web/src/components/common/project-template/ProjectTemplateContents.tsx@@ -2,7 +2,7 @@import type { ReactNode } from 'react';import { useTranslations } from 'next-intl';-import type { ProjectTemplateDetail } from '@/lib/api/endpoints/project-templates';+import type { TemplateContents } from '@/lib/api/endpoints/project-templates';import { useCopyColumns } from '@/hooks/useCopyColumns';import ProjectTemplateConfiguration from './ProjectTemplateConfiguration';import ProjectTemplateItems, { type TemplateItem } from './ProjectTemplateItems';@@ -12,14 +12,14 @@ import ProjectTemplateStates from './ProjectTemplateStates';// What a template holds, in the groups and the order "Save as template" offers them,// the hosted build's parts included.-export default function ProjectTemplateContents({ template }: { template: ProjectTemplateDetail }) {+export default function ProjectTemplateContents({ template }: { template: TemplateContents }) {const t = useTranslations('teams.templates.panel');const tFieldTypes = useTranslations('settings.customFields.fieldTypes');const columns = useCopyColumns(true);const typeName = (id: number | null) => template.issueTypes.find((type) => type.id === id)?.name;- const named = (items: { id: number; name: string }[]) =>- items.map((item) => ({ key: item.id, name: item.name }));+ const named = (items: { name: string }[]) =>+ items.map((item, i) => ({ key: i, name: item.name }));const lists: Record<string, TemplateItem[]> = {issueTypes: template.issueTypes.map((x) => ({ key: x.id, name: x.name, color: x.color })),diff --git a/apps/web/src/components/common/project-template/ProjectTemplateDetails.tsx b/apps/web/src/components/common/project-template/ProjectTemplateDetails.tsxindex 1e6253b9..bdc61eec 100644--- a/apps/web/src/components/common/project-template/ProjectTemplateDetails.tsx+++ b/apps/web/src/components/common/project-template/ProjectTemplateDetails.tsx@@ -3,20 +3,20 @@import { useTranslations } from 'next-intl';import type { ProjectTemplate } from '@/lib/api/endpoints/project-templates';import { formatDate } from '@/utils/dates';-import { useProjectTemplateQuery } from '@/services/projectTemplates.service';+import { useProjectTemplateQuery, type TemplateScope } from '@/services/projectTemplates.service';import ListSkeleton from '@/components/common/skeleton/ListSkeleton';import ProjectTemplateContents from './ProjectTemplateContents';// What a template is, then what a project created from it starts with.export default function ProjectTemplateDetails({- teamId,+ scope,template,}: {- teamId: number;+ scope: TemplateScope;template: ProjectTemplate;}) {const t = useTranslations('teams.templates.panel');- const { data: detail } = useProjectTemplateQuery(teamId, template.id);+ const { data: detail } = useProjectTemplateQuery(scope, template.id);return (<div className="space-y-8">diff --git a/apps/web/src/components/common/project-template/ProjectTemplateLabels.tsx b/apps/web/src/components/common/project-template/ProjectTemplateLabels.tsxindex e735fa22..67a20764 100644--- a/apps/web/src/components/common/project-template/ProjectTemplateLabels.tsx+++ b/apps/web/src/components/common/project-template/ProjectTemplateLabels.tsx@@ -1,16 +1,18 @@'use client';import { useTranslations } from 'next-intl';-import type { Label, LabelGroup } from '@/lib/api/endpoints/labels';+import type { TemplateContents } from '@/lib/api/endpoints/project-templates';import ProjectTemplateItems from './ProjectTemplateItems';+type Label = TemplateContents['labels'][number];+// The labels of a template under their groups, the ungrouped ones last.export default function ProjectTemplateLabels({labels,groups,}: {labels: Label[];- groups: LabelGroup[];+ groups: TemplateContents['labelGroups'];}) {const t = useTranslations('settings.labels');const items = (list: Label[]) => list.map((l) => ({ key: l.id, name: l.name, color: l.color }));diff --git a/apps/web/src/components/common/project-template/ProjectTemplateStates.tsx b/apps/web/src/components/common/project-template/ProjectTemplateStates.tsxindex 1523e1f8..963d5114 100644--- a/apps/web/src/components/common/project-template/ProjectTemplateStates.tsx+++ b/apps/web/src/components/common/project-template/ProjectTemplateStates.tsx@@ -1,8 +1,10 @@import { Fragment } from 'react';import { ChevronRight } from 'lucide-react';-import type { Column } from '@/lib/api/endpoints/columns';+import type { TemplateContents } from '@/lib/api/endpoints/project-templates';import { colorDot } from '@/components/common/fields/colorDot';+type Column = TemplateContents['columns'][number];+// The states of a template in board order, the canceled ones set apart after the flow.export default function ProjectTemplateStates({ columns }: { columns: Column[] }) {const flow = columns.filter((column) => column.stateType !== 'canceled');diff --git a/apps/web/src/components/layout/NewProjectModal.tsx b/apps/web/src/components/layout/NewProjectModal.tsxindex ac176f51..60a13d7b 100644--- a/apps/web/src/components/layout/NewProjectModal.tsx+++ b/apps/web/src/components/layout/NewProjectModal.tsx@@ -4,7 +4,7 @@ import { useTranslations } from 'next-intl';import { useCreateProject } from '@/services/projects.service';import { useTeamsQuery, useTeamProjectDefaultsQuery } from '@/services/teams.service';import { useAiAgentsQuery } from '@/services/aiAgents.service';-import { useProjectTemplatesQuery } from '@/services/projectTemplates.service';+import { useTeamProjectTemplatesQuery } from '@/services/projectTemplates.service';import { useCopyColumns } from '@/hooks/useCopyColumns';import { includeOf, type CopyInclude } from '@/utils/copyOptions';import { normalizeKey, suggestKey } from '@/utils/projectKey';@@ -18,24 +18,21 @@ import NewProjectFields from '@/components/layout/NewProjectFields';import NewProjectPreset from '@/components/layout/NewProjectPreset';import NewProjectStart from '@/components/layout/NewProjectStart';-// Creates a project, from scratch or from one of the team's templates, or — when+// Creates a project, from scratch or from one of the templates the team sees, or — when// `copyFrom` is set — copies that project's structure (states, issue types, labels,// custom fields) into a new project without its issues. `teamId` is the team the project-// belongs to; a copy is always made within the source project's team. While the team has-// templates, creating takes two steps: what the project starts from, then its fields;-// `initialTemplateId` opens the second step with that template picked.+// belongs to; a copy is always made within the source project's team. While the team sees+// templates, creating takes two steps: what the project starts from, then its fields.export default function NewProjectModal({onClose,onCreated,teamId,copyFrom,- initialTemplateId,}: {onClose: () => void;onCreated: (projectKey: string) => void;teamId: number;copyFrom?: { id: number; name: string; description: string };- initialTemplateId?: number;}) {const t = useTranslations('newProject');const tCommon = useTranslations('common');@@ -54,11 +51,9 @@ export default function NewProjectModal({// source project, and a project from a template from the template, so the preset// applies only when creating from scratch.const [preset, setPreset] = useState<PresetKey>('general');- const [templateId, setTemplateId] = useState<number | null>(initialTemplateId ?? null);- const [step, setStep] = useState<'start' | 'details'>(- initialTemplateId != null ? 'details' : 'start',- );- const templatesQuery = useProjectTemplatesQuery(copyFrom ? null : teamId);+ const [templateId, setTemplateId] = useState<number | null>(null);+ const [step, setStep] = useState<'start' | 'details'>('start');+ const templatesQuery = useTeamProjectTemplatesQuery(copyFrom ? null : teamId);// The list is for the team's owners and managers; anyone it is refused to starts// from scratch.const templates = templatesQuery.isError ? [] : templatesQuery.data;diff --git a/apps/web/src/components/layout/NewProjectStart.tsx b/apps/web/src/components/layout/NewProjectStart.tsxindex c471443b..2b82321d 100644--- a/apps/web/src/components/layout/NewProjectStart.tsx+++ b/apps/web/src/components/layout/NewProjectStart.tsx@@ -5,7 +5,7 @@ import { formatDate } from '@/utils/dates';import ProjectTemplateDetails from '@/components/common/project-template/ProjectTemplateDetails';import NewProjectOption from '@/components/layout/NewProjectOption';-// The first step while the team has templates: a blank project or one of the templates,+// The first step while the team sees templates: a blank project or one of the templates,// and beside the list what the choice starts the project with. A blank project shows// `blank`, the issue-type picker.export default function NewProjectStart({@@ -63,7 +63,7 @@ export default function NewProjectStart({<h3 className="text-base font-semibold" dir="auto">{template.name}</h3>- <ProjectTemplateDetails teamId={teamId} template={template} />+ <ProjectTemplateDetails scope={{ teamId }} template={template} /></>) : (<>diff --git a/apps/web/src/components/layout/ProjectSwitcher.test.tsx b/apps/web/src/components/layout/ProjectSwitcher.test.tsxindex f465b7bd..2bc2c3dd 100644--- a/apps/web/src/components/layout/ProjectSwitcher.test.tsx+++ b/apps/web/src/components/layout/ProjectSwitcher.test.tsx@@ -79,7 +79,6 @@ function team(id: number, workspaceId: number): Team {source: 'invite',joinedAt: '2026-01-01T00:00:00Z',projectCount: 0,- templateCount: 0,memberCount: 1,ownerCount: 1,roleCount: 0,diff --git a/apps/web/src/features/teams/components/TeamSectionNav.tsx b/apps/web/src/features/teams/components/TeamSectionNav.tsxindex 1f069128..100413b3 100644--- a/apps/web/src/features/teams/components/TeamSectionNav.tsx+++ b/apps/web/src/features/teams/components/TeamSectionNav.tsx@@ -12,7 +12,6 @@ import {FolderKanban,GitBranch,Info,- LayoutTemplate,PanelLeftClose,PanelLeftOpen,Plug,@@ -41,13 +40,13 @@ import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/componentimport { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';// The sections of the open team, as the page's last rail: the team itself, its-// projects and the templates they are created from, the roles they assign from and its-// members, then the AI group — the integration credentials the agents run on, the-// agents themselves, the skills they load, the tools they can call and what they spent — with what MCP clients reach and-// the notification providers last. The counts come with the team list, so each is shown-// before its section is opened. A section the caller may not read is left out, and the-// AI group with it once none of them is readable. Collapsed, the rail shows the icons of-// every section, the AI group's included, without the group.+// projects, the roles they assign from and its members, then the AI group — the+// integration credentials the agents run on, the agents themselves, the skills they+// load, the tools they can call, the run queue and what they spent — with Git, what MCP+// clients reach and the notification providers last. The counts come with the team+// list, so each is shown before its section is opened. A section the caller may not read+// is left out, and the AI group with it once none of them is readable. Collapsed, the+// rail shows the icons of every section, the AI group's included, without the group.export default function TeamSectionNav({team,collapsed,@@ -84,14 +83,8 @@ export default function TeamSectionNav({const top = [section('info', t('info.title'), Info),section('projects', t('projects.title'), FolderKanban, team.projectCount),- // The project templates and the roles are managed by the team's owner and managers,- // so the sections are theirs.- ...(runsTeam- ? [- section('templates', t('templates.title'), LayoutTemplate, team.templateCount),- section('roles', t('roles.title'), ShieldCheck, team.roleCount),- ]- : []),+ // The roles are managed by the team's owner and managers, so the section is theirs.+ ...(runsTeam ? [section('roles', t('roles.title'), ShieldCheck, team.roleCount)] : []),section('members', t('members.title'), Users, team.memberCount),];const ai = [diff --git a/apps/web/src/features/teams/components/WorkspaceTemplateDialog.tsx b/apps/web/src/features/teams/components/WorkspaceTemplateDialog.tsxnew file mode 100644index 00000000..ec8d6d37--- /dev/null+++ b/apps/web/src/features/teams/components/WorkspaceTemplateDialog.tsx@@ -0,0 +1,44 @@+'use client';++import type { ReactNode } from 'react';+import { useTranslations } from 'next-intl';+import Modal from '@/components/common/overlay/Modal';+import { Button } from '@/components/ui/button';++// The dialog a template of the workspace is saved and edited in: the form, and beside it+// the template as the new project dialog will show it.+export default function WorkspaceTemplateDialog({+ title,+ crumb,+ form,+ preview,+ canSave,+ onSave,+ onClose,+}: {+ title: string;+ crumb?: string;+ form: ReactNode;+ preview: ReactNode;+ canSave: boolean;+ onSave: () => void;+ onClose: () => void;+}) {+ const t = useTranslations('projects.saveTemplate');++ return (+ <Modal title={title} crumb={crumb} onClose={onClose} fullscreen className="pb-3">+ <div className="flex min-h-0 flex-1 flex-col overflow-hidden">+ <div className="grid min-h-0 flex-1 gap-6 overflow-y-auto sm:grid-cols-[360px_minmax(0,1fr)] sm:overflow-visible">+ <div className="space-y-4 sm:overflow-y-auto sm:pe-1">{form}</div>+ <div className="min-w-0 sm:overflow-y-auto sm:border-s sm:ps-6">{preview}</div>+ </div>+ <div className="mt-4 flex justify-end border-t pt-3">+ <Button disabled={!canSave} onClick={onSave}>+ {t('save')}+ </Button>+ </div>+ </div>+ </Modal>+ );+}diff --git a/apps/web/src/features/teams/components/WorkspaceTemplateFields.tsx b/apps/web/src/features/teams/components/WorkspaceTemplateFields.tsxnew file mode 100644index 00000000..74770da7--- /dev/null+++ b/apps/web/src/features/teams/components/WorkspaceTemplateFields.tsx@@ -0,0 +1,60 @@+'use client';++import { useTranslations } from 'next-intl';+import { Input } from '@/components/ui/input';+import { Label } from '@/components/ui/label';+import { Textarea } from '@/components/ui/textarea';+import WorkspaceTemplateTeamsField from './WorkspaceTemplateTeamsField';++// `teamIds` is null for every team of the workspace.+export interface WorkspaceTemplateFieldsValue {+ name: string;+ description: string;+ teamIds: number[] | null;+}++export function templateFieldsComplete(value: WorkspaceTemplateFieldsValue): boolean {+ return value.name.trim() !== '' && value.teamIds?.length !== 0;+}++// The name, the description and the teams of a template of the workspace.+export default function WorkspaceTemplateFields({+ workspaceId,+ value,+ onChange,+ autoFocus,+}: {+ workspaceId: number;+ value: WorkspaceTemplateFieldsValue;+ onChange: (next: WorkspaceTemplateFieldsValue) => void;+ autoFocus?: boolean;+}) {+ const t = useTranslations('newProject');++ return (+ <>+ <div className="space-y-1.5">+ <Label>{t('name')}</Label>+ <Input+ autoFocus={autoFocus}+ value={value.name}+ onChange={(e) => onChange({ ...value, name: e.target.value })}+ />+ </div>+ <div className="space-y-1.5">+ <Label>{t('description')}</Label>+ <Textarea+ rows={2}+ className="resize-none"+ value={value.description}+ onChange={(e) => onChange({ ...value, description: e.target.value })}+ />+ </div>+ <WorkspaceTemplateTeamsField+ workspaceId={workspaceId}+ value={value.teamIds}+ onChange={(teamIds) => onChange({ ...value, teamIds })}+ />+ </>+ );+}diff --git a/apps/web/src/features/teams/components/WorkspaceTemplatePreview.tsx b/apps/web/src/features/teams/components/WorkspaceTemplatePreview.tsxnew file mode 100644index 00000000..ef1b5eb8--- /dev/null+++ b/apps/web/src/features/teams/components/WorkspaceTemplatePreview.tsx@@ -0,0 +1,40 @@+'use client';++import { useTranslations } from 'next-intl';+import type { TemplateContents } from '@/lib/api/endpoints/project-templates';+import ProjectTemplateContents from '@/components/common/project-template/ProjectTemplateContents';+import ListSkeleton from '@/components/common/skeleton/ListSkeleton';++// The template being saved or edited, as the new project dialog will show it. `contents`+// is undefined while it loads.+export default function WorkspaceTemplatePreview({+ name,+ description,+ contents,+}: {+ name: string;+ description: string;+ contents: TemplateContents | undefined;+}) {+ const t = useTranslations('projects.saveTemplate');++ return (+ <div className="space-y-4">+ <h3 className="text-base font-semibold" dir="auto">+ {name || t('newTitle')}+ </h3>+ <div className="space-y-8">+ {description && (+ <p className="text-sm whitespace-pre-line text-foreground" dir="auto">+ {description}+ </p>+ )}+ {contents ? (+ <ProjectTemplateContents template={contents} />+ ) : (+ <ListSkeleton rows={5} rowClassName="h-10" />+ )}+ </div>+ </div>+ );+}diff --git a/apps/web/src/features/teams/components/WorkspaceTemplateSaveModal.tsx b/apps/web/src/features/teams/components/WorkspaceTemplateSaveModal.tsxnew file mode 100644index 00000000..d4a96e50--- /dev/null+++ b/apps/web/src/features/teams/components/WorkspaceTemplateSaveModal.tsx@@ -0,0 +1,117 @@+'use client';++import { useState } from 'react';+import { useTranslations } from 'next-intl';+import { toast } from 'sonner';+import {+ useProjectTemplatePreviewQuery,+ useSaveProjectTemplate,+} from '@/services/projectTemplates.service';+import { useCopyColumns } from '@/hooks/useCopyColumns';+import { includeOf, type CopyInclude } from '@/utils/copyOptions';+import CopyProjectOptions from '@/components/layout/CopyProjectOptions';+import WorkspaceTemplateDialog from './WorkspaceTemplateDialog';+import WorkspaceTemplateFields, {+ templateFieldsComplete,+ type WorkspaceTemplateFieldsValue,+} from './WorkspaceTemplateFields';+import WorkspaceTemplatePreview from './WorkspaceTemplatePreview';+import WorkspaceTemplateSource from './WorkspaceTemplateSource';++// Saves the chosen parts of a project's configuration as a template of the workspace.+// Opened from a project, it saves that one; opened from the workspace, the team and the+// project are picked first. Only what a template carries is offered.+export default function WorkspaceTemplateSaveModal({+ workspaceId,+ project,+ onClose,+}: {+ workspaceId: number;+ project?: { id: number; name: string; description: string };+ onClose: () => void;+}) {+ const t = useTranslations('projects.saveTemplate');+ const [teamId, setTeamId] = useState<number | null>(null);+ const [projectId, setProjectId] = useState<number | null>(project?.id ?? null);+ const [fields, setFields] = useState<WorkspaceTemplateFieldsValue>({+ name: project?.name ?? '',+ description: project?.description ?? '',+ teamIds: null,+ });+ // A picked project names the template until the name is edited.+ const [nameEdited, setNameEdited] = useState(false);+ const columns = useCopyColumns(true);+ const [include, setInclude] = useState<CopyInclude>({});+ const selected = includeOf(columns, include);+ const preview = useProjectTemplatePreviewQuery(workspaceId, projectId, selected);+ const save = useSaveProjectTemplate(workspaceId);++ function submit() {+ if (projectId === null) return;+ save.mutate(+ {+ projectId,+ name: fields.name.trim(),+ description: fields.description.trim(),+ include: selected,+ teamIds: fields.teamIds ?? undefined,+ },+ {+ onSuccess: (template) => {+ toast.success(t('saved', { name: template.name }));+ onClose();+ },+ },+ );+ }++ return (+ <WorkspaceTemplateDialog+ title={project ? t('title', { name: project.name }) : t('newTitle')}+ onClose={onClose}+ canSave={!save.isPending && projectId !== null && templateFieldsComplete(fields)}+ onSave={submit}+ form={+ <>+ <p className="text-sm text-muted-foreground">{t('hint')}</p>+ {!project && (+ <WorkspaceTemplateSource+ workspaceId={workspaceId}+ teamId={teamId}+ projectId={projectId}+ onTeamChange={(next) => {+ setTeamId(next);+ setProjectId(null);+ }}+ onProjectChange={(picked) => {+ setProjectId(picked.id);+ if (!nameEdited) setFields({ ...fields, name: picked.name });+ }}+ />+ )}+ <WorkspaceTemplateFields+ workspaceId={workspaceId}+ autoFocus={!!project}+ value={fields}+ onChange={(next) => {+ if (next.name !== fields.name) setNameEdited(next.name !== '');+ setFields(next);+ }}+ />+ <CopyProjectOptions columns={[columns.flat()]} value={include} onChange={setInclude} />+ </>+ }+ preview={+ projectId === null ? (+ <p className="text-sm text-muted-foreground">{t('previewEmpty')}</p>+ ) : (+ <WorkspaceTemplatePreview+ name={fields.name.trim()}+ description={fields.description.trim()}+ contents={preview.data}+ />+ )+ }+ />+ );+}diff --git a/apps/web/src/features/teams/components/WorkspaceTemplateSource.tsx b/apps/web/src/features/teams/components/WorkspaceTemplateSource.tsxnew file mode 100644index 00000000..e01b678f--- /dev/null+++ b/apps/web/src/features/teams/components/WorkspaceTemplateSource.tsx@@ -0,0 +1,77 @@+'use client';++import { useTranslations } from 'next-intl';+import type { TeamProjectOption } from '@/lib/api/endpoints/teams';+import { useTeamProjectOptionsQuery, useTeamsQuery } from '@/services/teams.service';+import { Label } from '@/components/ui/label';+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from '@/components/ui/select';++// The team of the workspace and its project a template is saved from.+export default function WorkspaceTemplateSource({+ workspaceId,+ teamId,+ projectId,+ onTeamChange,+ onProjectChange,+}: {+ workspaceId: number;+ teamId: number | null;+ projectId: number | null;+ onTeamChange: (teamId: number) => void;+ onProjectChange: (project: TeamProjectOption) => void;+}) {+ const t = useTranslations('projects.saveTemplate');+ const teams = useTeamsQuery().data?.filter((team) => team.workspaceId === workspaceId) ?? [];+ const projects = useTeamProjectOptionsQuery(teamId).data ?? [];++ return (+ <div className="grid gap-3 sm:grid-cols-2">+ <div className="space-y-1.5">+ <Label htmlFor="template-team">{t('team')}</Label>+ <Select+ value={teamId === null ? '' : String(teamId)}+ onValueChange={(value) => onTeamChange(Number(value))}+ >+ <SelectTrigger id="template-team" className="w-full">+ <SelectValue placeholder={t('chooseTeam')} />+ </SelectTrigger>+ <SelectContent>+ {teams.map((team) => (+ <SelectItem key={team.id} value={String(team.id)}>+ {team.name}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </div>+ <div className="space-y-1.5">+ <Label htmlFor="template-project">{t('project')}</Label>+ <Select+ value={projectId === null ? '' : String(projectId)}+ onValueChange={(value) => {+ const project = projects.find((one) => one.id === Number(value));+ if (project) onProjectChange(project);+ }}+ disabled={teamId === null}+ >+ <SelectTrigger id="template-project" className="w-full">+ <SelectValue placeholder={t('chooseProject')} />+ </SelectTrigger>+ <SelectContent>+ {projects.map((project) => (+ <SelectItem key={project.id} value={String(project.id)}>+ {project.name}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </div>+ </div>+ );+}diff --git a/apps/web/src/features/teams/components/WorkspaceTemplateTeamsField.tsx b/apps/web/src/features/teams/components/WorkspaceTemplateTeamsField.tsxnew file mode 100644index 00000000..f7ac0d5f--- /dev/null+++ b/apps/web/src/features/teams/components/WorkspaceTemplateTeamsField.tsx@@ -0,0 +1,57 @@+'use client';++import { useTranslations } from 'next-intl';+import { useTeamsQuery } from '@/services/teams.service';+import { Checkbox } from '@/components/ui/checkbox';+import { Label } from '@/components/ui/label';+import { Switch } from '@/components/ui/switch';++// Which teams of the workspace see a template: all of them, or the ones ticked. `value`+// is null for all of them.+export default function WorkspaceTemplateTeamsField({+ workspaceId,+ value,+ onChange,+}: {+ workspaceId: number;+ value: number[] | null;+ onChange: (next: number[] | null) => void;+}) {+ const t = useTranslations('projects.saveTemplate');+ const teams = useTeamsQuery().data?.filter((team) => team.workspaceId === workspaceId) ?? [];++ return (+ <div className="space-y-2">+ <Label>{t('teams')}</Label>+ <label className="flex cursor-pointer items-center justify-between gap-3">+ <span className="min-w-0">+ <span className="text-sm">{t('allTeams')}</span>+ <span className="block text-xs text-muted-foreground">{t('allTeamsHint')}</span>+ </span>+ <Switch checked={value === null} onCheckedChange={(all) => onChange(all ? null : [])} />+ </label>+ {value !== null && (+ <div className="grid grid-cols-2 gap-x-4 gap-y-1">+ {teams.map((team) => (+ <label+ key={team.id}+ className="flex min-w-0 cursor-pointer items-center gap-2 text-sm text-foreground"+ >+ <Checkbox+ checked={value.includes(team.id)}+ onCheckedChange={(checked) =>+ onChange(+ checked === true ? [...value, team.id] : value.filter((id) => id !== team.id),+ )+ }+ />+ <span className="truncate" dir="auto">+ {team.name}+ </span>+ </label>+ ))}+ </div>+ )}+ </div>+ );+}diff --git a/apps/web/src/features/teams/components/projects/TeamProjectActions.tsx b/apps/web/src/features/teams/components/projects/TeamProjectActions.tsxindex 6bc2de4e..003f2788 100644--- a/apps/web/src/features/teams/components/projects/TeamProjectActions.tsx+++ b/apps/web/src/features/teams/components/projects/TeamProjectActions.tsx@@ -18,19 +18,22 @@ import type { AccessVia } from '@/lib/api/endpoints/projects';import type { TeamProject, TeamRole } from '@/lib/api/endpoints/teams';import { useSession } from '@/lib/auth-client';import { useSetTeamProjectArchived } from '@/services/projects.service';+import { useTeam } from '@/services/teams.service';+import { useWorkspacesQuery } from '@/services/workspaces.service';import { projectPath } from '@/utils/paths';import RowAction from '@/components/common/RowAction';import NewProjectModal from '@/components/layout/NewProjectModal';import TeamProjectDeleteDialog from './TeamProjectDeleteDialog';import TeamProjectEditModal from './TeamProjectEditModal';import TeamProjectLeaveDialog from './TeamProjectLeaveDialog';-import TeamProjectTemplateModal from './TeamProjectTemplateModal';+import WorkspaceTemplateSaveModal from '../WorkspaceTemplateSaveModal';// What the reader may do with one project of the team, as the actions of the panel-// header. Editing, copying, saving as a template and archiving follow their rank in the-// team — a manager does all four, an owner also deletes — while leaving follows their-// membership in the project, which its last owner, and anyone a provisioned group put-// there, cannot give up.+// header. Editing, copying and archiving follow their rank in the team — a manager does+// all three, an owner also deletes — and saving as a template their role in the+// workspace, whose owner and admins keep its templates. Leaving follows their membership+// in the project, which its last owner, and anyone a provisioned group put there, cannot+// give up.export default function TeamProjectActions({teamId,teamRole,@@ -51,6 +54,9 @@ export default function TeamProjectActions({const [deleting, setDeleting] = useState(false);const [leaving, setLeaving] = useState(false);const setArchived = useSetTeamProjectArchived();+ const workspaceId = useTeam(teamId)?.workspaceId;+ const managesWorkspace =+ useWorkspacesQuery().data?.some((w) => w.id === workspaceId && w.role !== null) ?? false;const userId = session?.user.id;const isLastOwner = viewer?.role === 'owner' && project.owners.length === 1;@@ -76,11 +82,6 @@ export default function TeamProjectActions({<><RowAction icon={Pencil} label={t('editAction')} onClick={() => setEditing(true)} /><RowAction icon={Copy} label={t('copyAction')} onClick={() => setCopying(true)} />- <RowAction- icon={LayoutTemplate}- label={t('saveTemplateAction')}- onClick={() => setTemplating(true)}- /><RowActionicon={archived ? ArchiveRestore : Archive}label={t(archived ? 'restoreAction' : 'archiveAction')}@@ -88,6 +89,13 @@ export default function TeamProjectActions({/></>)}+ {managesWorkspace && (+ <RowAction+ icon={LayoutTemplate}+ label={t('saveTemplateAction')}+ onClick={() => setTemplating(true)}+ />+ )}{canLeave && (<RowAction icon={LogOut} label={t('leaveAction')} onClick={() => setLeaving(true)} />)}@@ -116,9 +124,9 @@ export default function TeamProjectActions({/>)}- {templating && (- <TeamProjectTemplateModal- teamId={teamId}+ {templating && workspaceId !== undefined && (+ <WorkspaceTemplateSaveModal+ workspaceId={workspaceId}project={project}onClose={() => setTemplating(false)}/>diff --git a/apps/web/src/features/teams/components/projects/TeamProjectTemplateModal.tsx b/apps/web/src/features/teams/components/projects/TeamProjectTemplateModal.tsxdeleted file mode 100644index 3c8cb74a..00000000--- a/apps/web/src/features/teams/components/projects/TeamProjectTemplateModal.tsx+++ /dev/null@@ -1,81 +0,0 @@-'use client';--import { useState } from 'react';-import { useTranslations } from 'next-intl';-import { toast } from 'sonner';-import type { TeamProject } from '@/lib/api/endpoints/teams';-import { useSaveProjectTemplate } from '@/services/projectTemplates.service';-import Modal from '@/components/common/overlay/Modal';-import { useCopyColumns } from '@/hooks/useCopyColumns';-import { includeOf, type CopyInclude } from '@/utils/copyOptions';-import CopyProjectOptions from '@/components/layout/CopyProjectOptions';-import { Button } from '@/components/ui/button';-import { Input } from '@/components/ui/input';-import { Label } from '@/components/ui/label';-import { Textarea } from '@/components/ui/textarea';--// Saves the chosen parts of a project's configuration as a project template of the team.-// Only what a template carries is offered.-export default function TeamProjectTemplateModal({- teamId,- project,- onClose,-}: {- teamId: number;- project: TeamProject;- onClose: () => void;-}) {- const t = useTranslations('projects.saveTemplate');- const tNew = useTranslations('newProject');- const [name, setName] = useState(project.name);- const [description, setDescription] = useState(project.description);- const columns = useCopyColumns(true);- const [include, setInclude] = useState<CopyInclude>({});- const save = useSaveProjectTemplate(teamId);-- function submit() {- save.mutate(- {- projectId: project.id,- name: name.trim(),- description: description.trim(),- include: includeOf(columns, include),- },- {- onSuccess: (template) => {- toast.success(t('saved', { name: template.name }));- onClose();- },- },- );- }-- return (- <Modal title={t('title', { name: project.name })} onClose={onClose} wide="xl" className="pb-3">- <div className="flex min-h-0 flex-col">- <div className="max-h-[55vh] space-y-4 overflow-y-auto pr-1">- <p className="text-sm text-muted-foreground">{t('hint')}</p>- <div className="space-y-1.5">- <Label>{tNew('name')}</Label>- <Input autoFocus value={name} onChange={(e) => setName(e.target.value)} />- </div>- <div className="space-y-1.5">- <Label>{tNew('description')}</Label>- <Textarea- rows={2}- className="resize-none"- value={description}- onChange={(e) => setDescription(e.target.value)}- />- </div>- <CopyProjectOptions columns={columns} value={include} onChange={setInclude} />- </div>- <div className="mt-4 flex justify-end border-t pt-3">- <Button disabled={save.isPending || !name.trim()} onClick={submit}>- {t('save')}- </Button>- </div>- </div>- </Modal>- );-}diff --git a/apps/web/src/features/teams/components/templates/TeamTemplatePanel.tsx b/apps/web/src/features/teams/components/templates/TeamTemplatePanel.tsxdeleted file mode 100644index d1928670..00000000--- a/apps/web/src/features/teams/components/templates/TeamTemplatePanel.tsx+++ /dev/null@@ -1,90 +0,0 @@-'use client';--import { useState } from 'react';-import { useRouter } from 'next/navigation';-import { LayoutTemplate, Plus, Trash2, X } from 'lucide-react';-import { useTranslations } from 'next-intl';-import type { ProjectTemplate } from '@/lib/api/endpoints/project-templates';-import { projectPath } from '@/utils/paths';-import { useExitOnEscape } from '@/hooks/useExitOnEscape';-import ProjectTemplateDetails from '@/components/common/project-template/ProjectTemplateDetails';-import NewProjectModal from '@/components/layout/NewProjectModal';-import { Button } from '@/components/ui/button';--// One template of the team in a right-hand side panel, the surface a project of the-// team opens in: what it is, what a project created from it starts with, and a project-// to create from it. Escape or a backdrop click closes it.-export default function TeamTemplatePanel({- teamId,- template,- onDelete,- onClose,-}: {- teamId: number;- template: ProjectTemplate;- onDelete: () => void;- onClose: () => void;-}) {- const t = useTranslations('teams');- const tCommon = useTranslations('common');- const router = useRouter();- const [creating, setCreating] = useState(false);-- useExitOnEscape(onClose);-- return (- <div- className="fixed inset-0 z-40 flex bg-black/20"- onClick={(e) => e.target === e.currentTarget && onClose()}- >- <div className="ms-auto flex h-full w-full flex-col border-s bg-card sm:w-[680px] sm:max-w-[92vw]">- <div className="flex shrink-0 items-center justify-between gap-3 bg-muted/30 px-6 py-4">- <div className="flex min-w-0 items-center gap-2">- <LayoutTemplate className="size-4 shrink-0 text-muted-foreground" />- <h2 className="truncate text-base font-semibold" dir="auto">- {template.name}- </h2>- </div>- <Button- variant="ghost"- size="icon"- className="size-7 shrink-0"- onClick={onClose}- title={tCommon('close')}- >- <X />- </Button>- </div>-- <div className="flex-1 overflow-y-auto px-6 py-6">- <ProjectTemplateDetails teamId={teamId} template={template} />- </div>-- <div className="flex shrink-0 items-center justify-between gap-3 border-t px-6 py-3">- <Button- variant="ghost"- size="sm"- className="text-muted-foreground hover:text-destructive"- onClick={onDelete}- >- <Trash2 />- {t('templates.deleteAction')}- </Button>- <Button size="sm" onClick={() => setCreating(true)}>- <Plus />- {t('panel.newProject')}- </Button>- </div>- </div>-- {creating && (- <NewProjectModal- teamId={teamId}- initialTemplateId={template.id}- onClose={() => setCreating(false)}- onCreated={(key) => router.push(projectPath(key))}- />- )}- </div>- );-}diff --git a/apps/web/src/features/teams/components/templates/TeamTemplatesSection.tsx b/apps/web/src/features/teams/components/templates/TeamTemplatesSection.tsxdeleted file mode 100644index 8ac86634..00000000--- a/apps/web/src/features/teams/components/templates/TeamTemplatesSection.tsx+++ /dev/null@@ -1,46 +0,0 @@-'use client';--import Link from 'next/link';-import { useTranslations } from 'next-intl';-import { teamSectionPath } from '@/utils/paths';-import { useTeam } from '@/services/teams.service';-import { useProjectTemplatesQuery } from '@/services/projectTemplates.service';-import { EmptyState } from '@/components/common/page/EmptyState';-import SectionPageView from '@/components/common/page/SectionPageView';-import ListSkeleton from '@/components/common/skeleton/ListSkeleton';-import { Button } from '@/components/ui/button';-import TeamTemplatesTable from './TeamTemplatesTable';--// The project templates of a team, which its owners and managers save from a project's-// row in Projects and pick when they create a project. A plain member reads a notice-// instead of the list.-export default function TeamTemplatesSection({ teamId }: { teamId: number }) {- const t = useTranslations('teams');- const team = useTeam(teamId);- const canManage = team?.role === 'owner' || team?.role === 'manager';- const { data: templates } = useProjectTemplatesQuery(canManage ? teamId : null);-- return (- <SectionPageView- title={t('sections.templates.title')}- description={t('sections.templates.description')}- wide- >- {!team ? (- <ListSkeleton rows={2} rowClassName="h-12" />- ) : !canManage ? (- <p className="text-sm text-muted-foreground">{t('templates.ownerOnly')}</p>- ) : !templates ? (- <ListSkeleton rows={2} rowClassName="h-12" />- ) : templates.length === 0 ? (- <EmptyState title={t('templates.empty')} description={t('templates.emptyHint')}>- <Button asChild size="sm" variant="outline">- <Link href={teamSectionPath(team.ref, 'projects')}>{t('templates.openProjects')}</Link>- </Button>- </EmptyState>- ) : (- <TeamTemplatesTable teamId={teamId} templates={templates} />- )}- </SectionPageView>- );-}diff --git a/apps/web/src/features/teams/components/templates/TeamTemplatesTable.tsx b/apps/web/src/features/teams/components/templates/TeamTemplatesTable.tsxdeleted file mode 100644index ed76e1f2..00000000--- a/apps/web/src/features/teams/components/templates/TeamTemplatesTable.tsx+++ /dev/null@@ -1,111 +0,0 @@-'use client';--import { useState } from 'react';-import { Trash2 } from 'lucide-react';-import { useTranslations } from 'next-intl';-import type { ProjectTemplate } from '@/lib/api/endpoints/project-templates';-import { formatDate } from '@/utils/dates';-import RowAction from '@/components/common/RowAction';-import {- Table,- TableBody,- TableCell,- TableHead,- TableHeader,- TableRow,-} from '@/components/ui/table';-import TeamTemplateDeleteDialog from './TeamTemplateDeleteDialog';-import TeamTemplatePanel from './TeamTemplatePanel';--// The templates of the team. A row opens what the template holds in a side panel.-export default function TeamTemplatesTable({- teamId,- templates,-}: {- teamId: number;- templates: ProjectTemplate[];-}) {- const t = useTranslations('teams');- const tCommon = useTranslations('common');- const [deleting, setDeleting] = useState<ProjectTemplate | null>(null);- const [selectedId, setSelectedId] = useState<number | null>(null);- // Read from the list, so the panel closes once its template is deleted.- const selected = templates.find((template) => template.id === selectedId) ?? null;-- return (- <div className="overflow-x-auto">- <Table className="min-w-[560px] table-fixed">- <colgroup>- <col className="w-[66%]" />- <col className="w-[20%]" />- <col className="w-[14%]" />- </colgroup>- <TableHeader>- <TableRow className="hover:bg-transparent">- <TableHead className="text-xs font-medium text-muted-foreground">- {t('columns.template')}- </TableHead>- <TableHead className="text-xs font-medium text-muted-foreground">- {t('columns.created')}- </TableHead>- <TableHead className="text-end text-xs font-medium text-muted-foreground">- {tCommon('actions')}- </TableHead>- </TableRow>- </TableHeader>- <TableBody>- {templates.map((template) => (- <TableRow- key={template.id}- className="cursor-pointer"- onClick={() => setSelectedId(template.id)}- >- <TableCell className="px-3 py-3 whitespace-normal">- <p className="text-sm font-medium wrap-anywhere" dir="auto">- {template.name}- </p>- {template.description && (- <p- className="line-clamp-1 text-xs wrap-anywhere text-muted-foreground"- dir="auto"- title={template.description}- >- {template.description}- </p>- )}- </TableCell>- <TableCell className="px-3 py-3 text-sm text-muted-foreground">- {formatDate(template.createdAt)}- </TableCell>- <TableCell className="px-3 py-2 text-end" onClick={(e) => e.stopPropagation()}>- <RowAction- icon={Trash2}- label={t('templates.deleteAction')}- destructive- onClick={() => setDeleting(template)}- />- </TableCell>- </TableRow>- ))}- </TableBody>- </Table>-- {selected && (- <TeamTemplatePanel- teamId={teamId}- template={selected}- onDelete={() => setDeleting(selected)}- onClose={() => setSelectedId(null)}- />- )}-- {deleting && (- <TeamTemplateDeleteDialog- teamId={teamId}- template={deleting}- onClose={() => setDeleting(null)}- />- )}- </div>- );-}diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceTemplateCodeInput.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplateCodeInput.tsxnew file mode 100644index 00000000..539a9901--- /dev/null+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplateCodeInput.tsx@@ -0,0 +1,48 @@+'use client';++import { cn } from '@/lib/utils';++export const CODE_LENGTH = 6;++// The gallery's confirmation code as six cells. One input holds the whole code, so typing,+// pasting and the one-time-code autofill work as in a plain field.+export default function WorkspaceTemplateCodeInput({+ value,+ label,+ invalid,+ onChange,+}: {+ value: string;+ label: string;+ invalid: boolean;+ onChange: (code: string) => void;+}) {+ return (+ <div className="group relative flex gap-2" dir="ltr">+ {Array.from({ length: CODE_LENGTH }, (_, index) => (+ <span+ key={index}+ className={cn(+ 'flex h-14 w-12 items-center justify-center rounded-lg border border-input font-mono text-xl font-medium dark:bg-input/30',+ index === value.length &&+ 'group-focus-within:border-ring group-focus-within:ring-[3px] group-focus-within:ring-ring/50',+ invalid && 'border-destructive',+ )}+ >+ {value[index]}+ </span>+ ))}+ <input+ aria-label={label}+ aria-invalid={invalid}+ className="absolute inset-0 cursor-text opacity-0"+ value={value}+ autoFocus+ inputMode="numeric"+ autoComplete="one-time-code"+ maxLength={CODE_LENGTH}+ onChange={(e) => onChange(e.target.value.replace(/\D/g, '').slice(0, CODE_LENGTH))}+ />+ </div>+ );+}diff --git a/apps/web/src/features/teams/components/templates/TeamTemplateDeleteDialog.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplateDeleteDialog.tsxsimilarity index 54%rename from apps/web/src/features/teams/components/templates/TeamTemplateDeleteDialog.tsxrename to apps/web/src/features/teams/components/workspace/WorkspaceTemplateDeleteDialog.tsxindex 630dc1ab..fc92b5b7 100644--- a/apps/web/src/features/teams/components/templates/TeamTemplateDeleteDialog.tsx+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplateDeleteDialog.tsx@@ -1,21 +1,22 @@'use client';+import { Globe } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { ProjectTemplate } from '@/lib/api/endpoints/project-templates';+import type { WorkspaceProjectTemplate } from '@/lib/api/endpoints/project-templates';import { useDeleteProjectTemplate } from '@/services/projectTemplates.service';import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';-export default function TeamTemplateDeleteDialog({- teamId,+export default function WorkspaceTemplateDeleteDialog({+ workspaceId,template,onClose,}: {- teamId: number;- template: ProjectTemplate;+ workspaceId: number;+ template: WorkspaceProjectTemplate;onClose: () => void;}) {const t = useTranslations('teams.templates.deleteDialog');- const deleteTemplate = useDeleteProjectTemplate(teamId);+ const deleteTemplate = useDeleteProjectTemplate(workspaceId);return (<ConfirmDialog@@ -28,6 +29,12 @@ export default function TeamTemplateDeleteDialog({}}><p className="text-sm text-muted-foreground">{t('description')}</p>+ {template.publication && (+ <p className="flex items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2.5 text-sm">+ <Globe className="size-4 shrink-0 text-destructive" />+ {t('galleryNote')}+ </p>+ )}</ConfirmDialog>);}diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceTemplateEditModal.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplateEditModal.tsxnew file mode 100644index 00000000..6ed86ee2--- /dev/null+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplateEditModal.tsx@@ -0,0 +1,78 @@+'use client';++import { useState } from 'react';+import { useTranslations } from 'next-intl';+import type { ProjectTemplate } from '@/lib/api/endpoints/project-templates';+import {+ useProjectTemplateQuery,+ useUpdateProjectTemplate,+} from '@/services/projectTemplates.service';+import WorkspaceTemplateDialog from '../WorkspaceTemplateDialog';+import WorkspaceTemplateFields, {+ templateFieldsComplete,+ type WorkspaceTemplateFieldsValue,+} from '../WorkspaceTemplateFields';+import WorkspaceTemplatePreview from '../WorkspaceTemplatePreview';++// Edits the name, the description and the teams of a template of the workspace. What it+// holds stays as saved.+export default function WorkspaceTemplateEditModal({+ workspaceId,+ template,+ onClose,+}: {+ workspaceId: number;+ template: ProjectTemplate;+ onClose: () => void;+}) {+ const t = useTranslations('teams.templates');+ const [fields, setFields] = useState<WorkspaceTemplateFieldsValue>({+ name: template.name,+ description: template.description,+ teamIds: template.teamIds,+ });+ const { data: saved } = useProjectTemplateQuery({ workspaceId }, template.id);+ const update = useUpdateProjectTemplate(workspaceId);++ function submit() {+ update.mutate(+ {+ templateId: template.id,+ patch: {+ name: fields.name.trim(),+ description: fields.description.trim(),+ teamIds: fields.teamIds,+ },+ },+ { onSuccess: onClose },+ );+ }++ return (+ <WorkspaceTemplateDialog+ title={t('editAction')}+ crumb={template.name}+ onClose={onClose}+ canSave={!update.isPending && templateFieldsComplete(fields)}+ onSave={submit}+ form={+ <>+ <p className="text-sm text-muted-foreground">{t('editHint')}</p>+ <WorkspaceTemplateFields+ workspaceId={workspaceId}+ autoFocus+ value={fields}+ onChange={setFields}+ />+ </>+ }+ preview={+ <WorkspaceTemplatePreview+ name={fields.name.trim()}+ description={fields.description.trim()}+ contents={saved}+ />+ }+ />+ );+}diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceTemplateGalleryPreview.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplateGalleryPreview.tsxnew file mode 100644index 00000000..40637e61--- /dev/null+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplateGalleryPreview.tsx@@ -0,0 +1,74 @@+'use client';++import { Fragment } from 'react';+import { ExternalLink } from 'lucide-react';+import { useTranslations } from 'next-intl';+import type {+ TemplatePublisher,+ WorkspaceProjectTemplate,+} from '@/lib/api/endpoints/project-templates';+import { useProjectTemplateQuery } from '@/services/projectTemplates.service';+import { colorDot } from '@/components/common/fields/colorDot';+import { Button } from '@/components/ui/button';++// The template as the gallery lists it, under the address's author.+export default function WorkspaceTemplateGalleryPreview({+ workspaceId,+ template,+ publisher,+ onChangeAuthor,+}: {+ workspaceId: number;+ template: WorkspaceProjectTemplate;+ publisher: TemplatePublisher;+ onChangeAuthor: () => void;+}) {+ const t = useTranslations('teams.templates.publish');+ const tCommon = useTranslations('common');+ const { data } = useProjectTemplateQuery({ workspaceId }, template.id);++ return (+ <div className="flex flex-col gap-2 rounded-lg border bg-muted/30 px-4 py-3.5">+ <div className="flex items-center justify-between gap-3">+ <div className="flex gap-1">+ {data?.columns.map((column) => (+ <Fragment key={column.id}>{colorDot(column.color)}</Fragment>+ ))}+ </div>+ <span+ className="font-mono text-[10px] tracking-[0.14em] text-muted-foreground uppercase"+ dir="ltr"+ >+ itsaplan.dev/templates+ </span>+ </div>+ <p className="text-sm font-semibold wrap-anywhere" dir="auto">+ {template.name}+ </p>+ <div className="flex flex-wrap items-center justify-between gap-x-3 gap-y-1">+ <span className="font-mono text-[11px] tracking-wider text-muted-foreground uppercase">+ {data &&+ t('counts', {+ states: data.columns.length,+ types: data.issueTypes.length,+ fields: data.customFields.length,+ })}+ </span>+ <span className="flex min-w-0 items-center gap-1 text-sm text-muted-foreground">+ {t.rich('by', {+ name: publisher.authorName,+ b: (chunks) => (+ <span className="truncate font-medium text-foreground" dir="auto">+ {chunks}+ </span>+ ),+ })}+ {publisher.authorUrl && <ExternalLink className="size-3 shrink-0" />}+ <Button variant="link" size="sm" className="ms-1 h-auto p-0" onClick={onChangeAuthor}>+ {tCommon('change')}+ </Button>+ </span>+ </div>+ </div>+ );+}diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceTemplateImportModal.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplateImportModal.tsxnew file mode 100644index 00000000..1f859483--- /dev/null+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplateImportModal.tsx@@ -0,0 +1,158 @@+'use client';++import { useMemo, useRef, useState } from 'react';+import { Upload } from 'lucide-react';+import { useTranslations } from 'next-intl';+import { toast } from 'sonner';+import type { SharedProjectTemplate } from '@/lib/api/endpoints/project-templates';+import {+ useImportedTemplatePreviewQuery,+ useImportProjectTemplate,+} from '@/services/projectTemplates.service';+import { Button } from '@/components/ui/button';+import { Label } from '@/components/ui/label';+import { Textarea } from '@/components/ui/textarea';+import WorkspaceTemplateDialog from '../WorkspaceTemplateDialog';+import WorkspaceTemplateFields, {+ templateFieldsComplete,+ type WorkspaceTemplateFieldsValue,+} from '../WorkspaceTemplateFields';+import WorkspaceTemplatePreview from '../WorkspaceTemplatePreview';++// The pasted text as a template, or null when it is not a JSON object. The server checks+// the rest.+function parseShared(text: string): SharedProjectTemplate | null {+ try {+ const value: unknown = JSON.parse(text);+ return value && typeof value === 'object' && !Array.isArray(value)+ ? (value as SharedProjectTemplate)+ : null;+ } catch {+ return null;+ }+}++// Imports a template copied or downloaded from another workspace, pasted or uploaded as a+// file. It takes the name and the description the template came with until they are+// edited.+export default function WorkspaceTemplateImportModal({+ workspaceId,+ onClose,+}: {+ workspaceId: number;+ onClose: () => void;+}) {+ const t = useTranslations('projects.saveTemplate');+ const [text, setText] = useState('');+ const template = useMemo(() => parseShared(text), [text]);+ const [fields, setFields] = useState<WorkspaceTemplateFieldsValue>({+ name: '',+ description: '',+ teamIds: null,+ });+ const [fieldsEdited, setFieldsEdited] = useState(false);+ const fileInput = useRef<HTMLInputElement>(null);+ const preview = useImportedTemplatePreviewQuery(workspaceId, template);+ const importTemplate = useImportProjectTemplate(workspaceId);++ function paste(next: string) {+ setText(next);+ const parsed = parseShared(next);+ if (parsed && !fieldsEdited) {+ setFields({+ ...fields,+ name: String(parsed.name ?? ''),+ description: String(parsed.description ?? ''),+ });+ }+ }++ function submit() {+ if (!template) return;+ importTemplate.mutate(+ {+ template,+ name: fields.name.trim(),+ description: fields.description.trim(),+ teamIds: fields.teamIds ?? undefined,+ },+ {+ onSuccess: (created) => {+ toast.success(t('saved', { name: created.name }));+ onClose();+ },+ },+ );+ }++ let previewPane;+ if (text.trim() === '') {+ previewPane = <p className="text-sm text-muted-foreground">{t('importEmpty')}</p>;+ } else if (!template || preview.isError) {+ previewPane = <p className="text-sm text-destructive">{t('importInvalid')}</p>;+ } else {+ previewPane = (+ <WorkspaceTemplatePreview+ name={fields.name.trim()}+ description={fields.description.trim()}+ contents={preview.data}+ />+ );+ }++ return (+ <WorkspaceTemplateDialog+ title={t('importTitle')}+ onClose={onClose}+ canSave={+ !importTemplate.isPending && preview.data !== undefined && templateFieldsComplete(fields)+ }+ onSave={submit}+ form={+ <>+ <p className="text-sm text-muted-foreground">{t('importHint')}</p>+ <div className="space-y-1.5">+ <div className="flex items-center justify-between gap-2">+ <Label htmlFor="template-import">{t('importLabel')}</Label>+ <Button variant="ghost" size="sm" onClick={() => fileInput.current?.click()}>+ <Upload />+ {t('importFile')}+ </Button>+ <input+ ref={fileInput}+ type="file"+ accept=".json,application/json"+ hidden+ onChange={async (e) => {+ const file = e.target.files?.[0];+ e.target.value = '';+ if (file) paste(await file.text());+ }}+ />+ </div>+ <Textarea+ id="template-import"+ autoFocus+ rows={6}+ className="max-h-48 resize-none font-mono text-xs"+ placeholder={t('importPlaceholder')}+ value={text}+ onChange={(e) => paste(e.target.value)}+ />+ </div>+ <WorkspaceTemplateFields+ workspaceId={workspaceId}+ value={fields}+ onChange={(next) => {+ if (next.name !== fields.name || next.description !== fields.description) {+ setFieldsEdited(true);+ }+ setFields(next);+ }}+ />+ </>+ }+ preview={previewPane}+ />+ );+}diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePanel.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePanel.tsxnew file mode 100644index 00000000..53f78c1d--- /dev/null+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePanel.tsx@@ -0,0 +1,103 @@+'use client';++import { Copy, Download, Globe, LayoutTemplate, Pencil, Trash2, X } from 'lucide-react';+import { useTranslations } from 'next-intl';+import type { WorkspaceProjectTemplate } from '@/lib/api/endpoints/project-templates';+import { useExitOnEscape } from '@/hooks/useExitOnEscape';+import ProjectTemplateDetails from '@/components/common/project-template/ProjectTemplateDetails';+import RowAction from '@/components/common/RowAction';+import { Button } from '@/components/ui/button';+import { useTemplateTeamsLabel } from '../../hooks/useTemplateTeamsLabel';+import WorkspaceTemplatePublishedBadge from './WorkspaceTemplatePublishedBadge';++// One template of the workspace: the teams that see it and what a project created from it+// starts with.+export default function WorkspaceTemplatePanel({+ workspaceId,+ template,+ onEdit,+ onPublish,+ onCopy,+ onDownload,+ onDelete,+ onClose,+}: {+ workspaceId: number;+ template: WorkspaceProjectTemplate;+ onEdit: () => void;+ onPublish: () => void;+ onCopy: () => void;+ onDownload: () => void;+ onDelete: () => void;+ onClose: () => void;+}) {+ const t = useTranslations('teams');+ const tCommon = useTranslations('common');+ const teamsLabel = useTemplateTeamsLabel();++ useExitOnEscape(onClose);++ return (+ <div+ className="fixed inset-0 z-40 flex bg-black/20"+ onClick={(e) => e.target === e.currentTarget && onClose()}+ >+ <div className="ms-auto flex h-full w-full flex-col border-s bg-card sm:w-[680px] sm:max-w-[92vw]">+ <div className="flex shrink-0 items-center justify-between gap-3 bg-muted/30 px-6 py-4">+ <div className="flex min-w-0 items-center gap-2">+ <LayoutTemplate className="size-4 shrink-0 text-muted-foreground" />+ <h2 className="truncate text-base font-semibold" dir="auto">+ {template.name}+ </h2>+ {template.publication && (+ <WorkspaceTemplatePublishedBadge publication={template.publication} />+ )}+ </div>+ <Button+ variant="ghost"+ size="icon"+ className="size-7 shrink-0"+ onClick={onClose}+ title={tCommon('close')}+ >+ <X />+ </Button>+ </div>++ <div className="flex-1 space-y-2 overflow-y-auto px-6 py-6">+ <p className="text-xs text-muted-foreground">+ {t('templates.panel.teams', { teams: teamsLabel(template.teamIds) })}+ </p>+ <ProjectTemplateDetails scope={{ workspaceId }} template={template} />+ </div>++ <div className="flex shrink-0 items-center gap-1 border-t px-6 py-3">+ <Button+ variant="ghost"+ size="sm"+ className={template.publication ? 'text-foreground' : 'text-muted-foreground'}+ onClick={onPublish}+ >+ {template.publication ? (+ <span className="mx-0.5 size-2 rounded-full bg-emerald-500" />+ ) : (+ <Globe />+ )}+ {t(template.publication ? 'templates.publish.published' : 'templates.publish.action')}+ </Button>+ <div className="ms-auto flex items-center gap-1">+ <RowAction icon={Pencil} label={t('templates.editAction')} onClick={onEdit} />+ <RowAction icon={Copy} label={t('templates.copyAction')} onClick={onCopy} />+ <RowAction icon={Download} label={t('templates.downloadAction')} onClick={onDownload} />+ <RowAction+ icon={Trash2}+ label={t('templates.deleteAction')}+ destructive+ onClick={onDelete}+ />+ </div>+ </div>+ </div>+ </div>+ );+}diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublication.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublication.tsxnew file mode 100644index 00000000..e0488b2a--- /dev/null+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublication.tsx@@ -0,0 +1,57 @@+'use client';++import { Copy, ExternalLink } from 'lucide-react';+import { useTranslations } from 'next-intl';+import { toast } from 'sonner';+import type { TemplatePublication } from '@/lib/api/endpoints/project-templates';+import { formatDate } from '@/utils/dates';+import { Button } from '@/components/ui/button';++// The template's page in the gallery: since when it is up, and its link.+export default function WorkspaceTemplatePublication({+ publication,+}: {+ publication: TemplatePublication;+}) {+ const t = useTranslations('teams.templates.publish');++ async function copyLink() {+ try {+ await navigator.clipboard.writeText(publication.url);+ toast.success(t('linkCopied'));+ } catch {+ toast.error(t('copyFailed'));+ }+ }++ return (+ <div className="flex items-center gap-1 rounded-lg border py-2.5 ps-3.5 pe-2">+ <div className="flex min-w-0 flex-1 flex-col gap-1">+ <div className="flex items-center gap-2 text-[13px]">+ <span className="size-2 shrink-0 rounded-full bg-emerald-500 ring-[3px] ring-emerald-500/15" />+ <span className="font-medium">{t('live')}</span>+ <span className="text-muted-foreground">+ {t('since', { date: formatDate(publication.publishedAt) })}+ </span>+ </div>+ <a+ href={publication.url}+ target="_blank"+ rel="noreferrer"+ dir="ltr"+ className="truncate font-mono text-xs text-muted-foreground hover:text-foreground"+ >+ {publication.url.replace(/^https:\/\//, '')}+ </a>+ </div>+ <Button variant="ghost" size="icon-sm" title={t('copyLink')} onClick={() => void copyLink()}>+ <Copy />+ </Button>+ <Button variant="ghost" size="icon-sm" title={t('openPage')} asChild>+ <a href={publication.url} target="_blank" rel="noreferrer">+ <ExternalLink />+ </a>+ </Button>+ </div>+ );+}diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublishDialog.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublishDialog.tsxnew file mode 100644index 00000000..cbeeac22--- /dev/null+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublishDialog.tsx@@ -0,0 +1,85 @@+'use client';++import { useState } from 'react';+import { useTranslations } from 'next-intl';+import type { WorkspaceProjectTemplate } from '@/lib/api/endpoints/project-templates';+import { useSession } from '@/lib/auth-client';+import {+ useTemplatePublisherQuery,+ useUnlinkTemplatePublisher,+} from '@/services/projectTemplates.service';+import Modal from '@/components/common/overlay/Modal';+import ListSkeleton from '@/components/common/skeleton/ListSkeleton';+import WorkspaceTemplatePublishForm from './WorkspaceTemplatePublishForm';+import WorkspaceTemplatePublisherAuthor from './WorkspaceTemplatePublisherAuthor';+import WorkspaceTemplatePublisherLink from './WorkspaceTemplatePublisherLink';+import WorkspaceTemplatePublisherMenu from './WorkspaceTemplatePublisherMenu';++// Publishes a template to the gallery at itsaplan.dev. A workspace not linked to the+// gallery yet confirms an email first, and an address with no author names one.+export default function WorkspaceTemplatePublishDialog({+ workspaceId,+ template,+ onClose,+}: {+ workspaceId: number;+ template: WorkspaceProjectTemplate;+ onClose: () => void;+}) {+ const t = useTranslations('teams.templates.publish');+ const { data: session } = useSession();+ const publisher = useTemplatePublisherQuery(workspaceId);+ const unlink = useUnlinkTemplatePublisher(workspaceId);+ const [relinking, setRelinking] = useState(false);+ const [naming, setNaming] = useState(false);+ const linked = publisher.data && !relinking ? publisher.data : null;+ const askAuthor = naming || !linked?.authorName;++ return (+ <Modal+ title={t('action')}+ crumb={template.name}+ controls={+ linked && (+ <WorkspaceTemplatePublisherMenu+ publisher={linked}+ onChangeAuthor={() => setNaming(true)}+ onChangeEmail={() => {+ setNaming(false);+ setRelinking(true);+ }}+ onUnlink={() => unlink.mutate()}+ />+ )+ }+ onClose={onClose}+ >+ {publisher.isPending && <ListSkeleton rows={3} rowClassName="h-9" />}+ {publisher.isSuccess && !linked && (+ <WorkspaceTemplatePublisherLink+ workspaceId={workspaceId}+ defaultEmail={publisher.data?.email ?? session?.user.email ?? ''}+ onLinked={() => setRelinking(false)}+ onCancel={relinking ? () => setRelinking(false) : onClose}+ />+ )}+ {linked && askAuthor && (+ <WorkspaceTemplatePublisherAuthor+ workspaceId={workspaceId}+ publisher={linked}+ defaultName={session?.user.name ?? ''}+ onDone={() => setNaming(false)}+ />+ )}+ {linked && !askAuthor && (+ <WorkspaceTemplatePublishForm+ workspaceId={workspaceId}+ template={template}+ publisher={linked}+ onChangeAuthor={() => setNaming(true)}+ onClose={onClose}+ />+ )}+ </Modal>+ );+}diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublishForm.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublishForm.tsxnew file mode 100644index 00000000..a4db7605--- /dev/null+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublishForm.tsx@@ -0,0 +1,98 @@+'use client';++import { useState } from 'react';+import { Download, Lock } from 'lucide-react';+import { useTranslations } from 'next-intl';+import { toast } from 'sonner';+import type {+ TemplatePublisher,+ WorkspaceProjectTemplate,+} from '@/lib/api/endpoints/project-templates';+import { usePublishTemplate } from '@/services/projectTemplates.service';+import { Button } from '@/components/ui/button';+import WorkspaceTemplateGalleryPreview from './WorkspaceTemplateGalleryPreview';+import WorkspaceTemplatePublication from './WorkspaceTemplatePublication';+import WorkspaceTemplateUnpublishConfirm from './WorkspaceTemplateUnpublishConfirm';++// Publishes the template under the address's author, and once it is, shows its page.+export default function WorkspaceTemplatePublishForm({+ workspaceId,+ template,+ publisher,+ onChangeAuthor,+ onClose,+}: {+ workspaceId: number;+ template: WorkspaceProjectTemplate;+ publisher: TemplatePublisher;+ onChangeAuthor: () => void;+ onClose: () => void;+}) {+ const t = useTranslations('teams.templates.publish');+ const tCommon = useTranslations('common');+ const [unpublishing, setUnpublishing] = useState(false);+ const publish = usePublishTemplate(workspaceId);+ const { publication } = template;++ function submit() {+ publish.mutate(template.id, {+ onSuccess: () => toast.success(t(publication ? 'updatedToast' : 'publishedToast')),+ });+ }++ return (+ <div className="flex flex-col gap-4">+ {publication ? (+ <WorkspaceTemplatePublication publication={publication} />+ ) : (+ <>+ <WorkspaceTemplateGalleryPreview+ workspaceId={workspaceId}+ template={template}+ publisher={publisher}+ onChangeAuthor={onChangeAuthor}+ />+ <div className="flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground">+ <span className="flex items-center gap-1.5">+ <Download className="size-3.5" />+ {t('downloadable')}+ </span>+ <span className="flex items-center gap-1.5">+ <Lock className="size-3.5" />+ {t('private')}+ </span>+ </div>+ </>+ )}++ {publication && unpublishing ? (+ <WorkspaceTemplateUnpublishConfirm+ workspaceId={workspaceId}+ templateId={template.id}+ onDone={() => setUnpublishing(false)}+ />+ ) : (+ <div className="flex flex-wrap items-center gap-2">+ {publication && (+ <Button+ variant="ghost"+ className="text-destructive hover:text-destructive"+ disabled={publish.isPending}+ onClick={() => setUnpublishing(true)}+ >+ {t('unpublish')}+ </Button>+ )}+ <div className="ms-auto flex gap-2">+ <Button variant="ghost" onClick={onClose}>+ {tCommon(publication ? 'close' : 'cancel')}+ </Button>+ <Button disabled={publish.isPending} onClick={submit}>+ {t(publication ? 'update' : 'submit')}+ </Button>+ </div>+ </div>+ )}+ </div>+ );+}diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublishedBadge.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublishedBadge.tsxnew file mode 100644index 00000000..34ce53a9--- /dev/null+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublishedBadge.tsx@@ -0,0 +1,34 @@+'use client';++import { useTranslations } from 'next-intl';+import type { TemplatePublication } from '@/lib/api/endpoints/project-templates';+import { formatDate } from '@/utils/dates';+import { Badge } from '@/components/ui/badge';++// Marks a template published to the gallery and opens its page there.+export default function WorkspaceTemplatePublishedBadge({+ publication,+}: {+ publication: TemplatePublication;+}) {+ const t = useTranslations('teams.templates.publish');++ return (+ <Badge+ variant="outline"+ className="shrink-0 gap-1.5 rounded-full border-transparent bg-emerald-500/10 text-emerald-600 dark:text-emerald-400"+ asChild+ >+ <a+ href={publication.url}+ target="_blank"+ rel="noreferrer"+ title={t('badgeHint', { date: formatDate(publication.publishedAt) })}+ onClick={(e) => e.stopPropagation()}+ >+ <span className="size-1.5 rounded-full bg-current" />+ {t('badge')}+ </a>+ </Badge>+ );+}diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublisherAuthor.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublisherAuthor.tsxnew file mode 100644index 00000000..23cd85e1--- /dev/null+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublisherAuthor.tsx@@ -0,0 +1,84 @@+'use client';++import { useState } from 'react';+import { useTranslations } from 'next-intl';+import type { TemplatePublisher } from '@/lib/api/endpoints/project-templates';+import { useSetPublisherAuthor } from '@/services/projectTemplates.service';+import { Button } from '@/components/ui/button';+import { Input } from '@/components/ui/input';+import { Label } from '@/components/ui/label';++const NAME_LIMIT = 80;+const URL_LIMIT = 200;++// The name and the profile link the gallery shows on every template of the address. The+// first time it is asked for, the account name stands in.+export default function WorkspaceTemplatePublisherAuthor({+ workspaceId,+ publisher,+ defaultName,+ onDone,+}: {+ workspaceId: number;+ publisher: TemplatePublisher;+ defaultName: string;+ onDone: () => void;+}) {+ const t = useTranslations('teams.templates.publish');+ const tCommon = useTranslations('common');+ const [authorName, setAuthorName] = useState(publisher.authorName || defaultName);+ const [authorUrl, setAuthorUrl] = useState(publisher.authorUrl ?? '');+ const setAuthor = useSetPublisherAuthor(workspaceId);++ const name = authorName.trim();+ const url = authorUrl.trim();+ const urlInvalid = url !== '' && (!url.startsWith('https://') || url.length > URL_LIMIT);+ const valid = name !== '' && name.length <= NAME_LIMIT && !urlInvalid;++ return (+ <div className="flex flex-col gap-4">+ <p className="text-sm text-muted-foreground">{t('authorHint', { email: publisher.email })}</p>+ <div className="flex flex-col gap-1.5">+ <Label htmlFor="publish-author">{t('authorName')}</Label>+ <Input+ id="publish-author"+ value={authorName}+ maxLength={NAME_LIMIT}+ autoFocus+ onChange={(e) => setAuthorName(e.target.value)}+ />+ </div>+ <div className="flex flex-col gap-1.5">+ <div className="flex items-baseline justify-between gap-2">+ <Label htmlFor="publish-author-url">{t('authorUrl')}</Label>+ <span className="text-xs text-muted-foreground">{t('optional')}</span>+ </div>+ <Input+ id="publish-author-url"+ type="url"+ dir="ltr"+ value={authorUrl}+ placeholder="https://"+ aria-invalid={urlInvalid}+ onChange={(e) => setAuthorUrl(e.target.value)}+ />+ {urlInvalid && <p className="text-xs text-destructive">{t('authorUrlInvalid')}</p>}+ </div>+ <div className="flex justify-end gap-2">+ {publisher.authorName && (+ <Button variant="ghost" onClick={onDone}>+ {tCommon('cancel')}+ </Button>+ )}+ <Button+ disabled={!valid || setAuthor.isPending}+ onClick={() =>+ setAuthor.mutate({ authorName: name, authorUrl: url || null }, { onSuccess: onDone })+ }+ >+ {tCommon('save')}+ </Button>+ </div>+ </div>+ );+}diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublisherCode.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublisherCode.tsxnew file mode 100644index 00000000..d1013230--- /dev/null+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublisherCode.tsx@@ -0,0 +1,82 @@+'use client';++import { useState } from 'react';+import { useTranslations } from 'next-intl';+import { toast } from 'sonner';+import {+ useLinkTemplatePublisher,+ useRequestPublisherCode,+} from '@/services/projectTemplates.service';+import { Button } from '@/components/ui/button';+import WorkspaceTemplateCodeInput, { CODE_LENGTH } from './WorkspaceTemplateCodeInput';++// Takes the code the gallery emailed and links the workspace with it. A full code is sent+// as soon as its last digit is typed.+export default function WorkspaceTemplatePublisherCode({+ workspaceId,+ email,+ onChangeEmail,+ onLinked,+ onCancel,+}: {+ workspaceId: number;+ email: string;+ onChangeEmail: () => void;+ onLinked: () => void;+ onCancel: () => void;+}) {+ const t = useTranslations('teams.templates.publish.link');+ const tCommon = useTranslations('common');+ const [code, setCode] = useState('');+ const requestCode = useRequestPublisherCode(workspaceId);+ const link = useLinkTemplatePublisher(workspaceId);++ function confirm(value: string) {+ link.mutate({ email, code: value }, { onSuccess: onLinked });+ }++ function changeCode(value: string) {+ setCode(value);+ link.reset();+ if (value.length === CODE_LENGTH) confirm(value);+ }++ return (+ <div className="flex flex-col gap-4">+ <p className="text-sm text-muted-foreground">+ {t('codeSent', { email })}{' '}+ <Button variant="link" className="h-auto p-0" onClick={onChangeEmail}>+ {tCommon('change')}+ </Button>+ </p>+ <div className="flex flex-col gap-2">+ <WorkspaceTemplateCodeInput+ value={code}+ label={t('code')}+ invalid={link.isError}+ onChange={changeCode}+ />+ {link.error && <p className="text-sm text-destructive">{link.error.message}</p>}+ </div>+ <Button+ variant="link"+ className="h-auto self-start p-0 text-muted-foreground"+ disabled={requestCode.isPending}+ onClick={() => requestCode.mutate(email, { onSuccess: () => toast.success(t('resent')) })}+ >+ {t('resend')}+ </Button>+ <div className="flex justify-end gap-2">+ <Button variant="ghost" onClick={onCancel}>+ {tCommon('cancel')}+ </Button>+ <Button+ disabled={code.length !== CODE_LENGTH || link.isPending}+ onClick={() => confirm(code)}+ >+ {t('confirm')}+ </Button>+ </div>+ </div>+ );+}diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublisherEmail.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublisherEmail.tsxnew file mode 100644index 00000000..1531245c--- /dev/null+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublisherEmail.tsx@@ -0,0 +1,83 @@+'use client';++import { useTranslations } from 'next-intl';+import { TEMPLATE_GALLERY_RULES_URL } from '@/utils/app';+import { useRequestPublisherCode } from '@/services/projectTemplates.service';+import { Button } from '@/components/ui/button';+import { Input } from '@/components/ui/input';+import { Label } from '@/components/ui/label';++const EMAIL = /^[^@\s]+@[^@\s]+\.[^@\s]+$/;++// Asks the gallery to email a code to the address. Sending the code accepts the gallery+// rules.+export default function WorkspaceTemplatePublisherEmail({+ workspaceId,+ email,+ onEmailChange,+ onSent,+ onCancel,+}: {+ workspaceId: number;+ email: string;+ onEmailChange: (email: string) => void;+ onSent: () => void;+ onCancel: () => void;+}) {+ const t = useTranslations('teams.templates.publish.link');+ const tCommon = useTranslations('common');+ const requestCode = useRequestPublisherCode(workspaceId);+ const address = email.trim();+ const ready = EMAIL.test(address) && !requestCode.isPending;++ function send() {+ requestCode.mutate(address, {+ onSuccess: () => {+ onEmailChange(address);+ onSent();+ },+ });+ }++ return (+ <div className="flex flex-col gap-4">+ <p className="text-sm text-muted-foreground">{t('intro')}</p>+ <div className="flex flex-col gap-1.5">+ <div className="flex items-baseline justify-between gap-2">+ <Label htmlFor="publisher-email">{t('email')}</Label>+ <span className="text-xs text-muted-foreground">{t('emailHint')}</span>+ </div>+ <Input+ id="publisher-email"+ type="email"+ value={email}+ autoFocus+ onChange={(e) => onEmailChange(e.target.value)}+ onKeyDown={(e) => e.key === 'Enter' && ready && send()}+ />+ </div>+ <p className="text-xs text-muted-foreground">+ {t.rich('agree', {+ rules: (chunks) => (+ <a+ href={TEMPLATE_GALLERY_RULES_URL}+ target="_blank"+ rel="noreferrer"+ className="underline underline-offset-4 hover:text-foreground"+ >+ {chunks}+ </a>+ ),+ })}+ </p>+ <div className="flex justify-end gap-2">+ <Button variant="ghost" onClick={onCancel}>+ {tCommon('cancel')}+ </Button>+ <Button disabled={!ready} onClick={send}>+ {t('sendCode')}+ </Button>+ </div>+ </div>+ );+}diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublisherLink.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublisherLink.tsxnew file mode 100644index 00000000..7ea1b660--- /dev/null+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublisherLink.tsx@@ -0,0 +1,40 @@+'use client';++import { useState } from 'react';+import WorkspaceTemplatePublisherCode from './WorkspaceTemplatePublisherCode';+import WorkspaceTemplatePublisherEmail from './WorkspaceTemplatePublisherEmail';++// Links the workspace to the gallery: the gallery emails a code to the address, and the+// code confirms it.+export default function WorkspaceTemplatePublisherLink({+ workspaceId,+ defaultEmail,+ onLinked,+ onCancel,+}: {+ workspaceId: number;+ defaultEmail: string;+ onLinked: () => void;+ onCancel: () => void;+}) {+ const [email, setEmail] = useState(defaultEmail);+ const [codeSent, setCodeSent] = useState(false);++ return codeSent ? (+ <WorkspaceTemplatePublisherCode+ workspaceId={workspaceId}+ email={email}+ onChangeEmail={() => setCodeSent(false)}+ onLinked={onLinked}+ onCancel={onCancel}+ />+ ) : (+ <WorkspaceTemplatePublisherEmail+ workspaceId={workspaceId}+ email={email}+ onEmailChange={setEmail}+ onSent={() => setCodeSent(true)}+ onCancel={onCancel}+ />+ );+}diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublisherMenu.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublisherMenu.tsxnew file mode 100644index 00000000..b4ae5909--- /dev/null+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatePublisherMenu.tsx@@ -0,0 +1,73 @@+'use client';++import { AtSign, BookOpen, ExternalLink, MoreHorizontal, Unlink, UserPen } from 'lucide-react';+import { useTranslations } from 'next-intl';+import type { TemplatePublisher } from '@/lib/api/endpoints/project-templates';+import { TEMPLATE_GALLERY_RULES_URL } from '@/utils/app';+import { Button } from '@/components/ui/button';+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuLabel,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+} from '@/components/ui/dropdown-menu';++// The gallery account of the workspace: the address it publishes under, its author, the+// rules, and the way to link another address or none.+export default function WorkspaceTemplatePublisherMenu({+ publisher,+ onChangeAuthor,+ onChangeEmail,+ onUnlink,+}: {+ publisher: TemplatePublisher;+ onChangeAuthor: () => void;+ onChangeEmail: () => void;+ onUnlink: () => void;+}) {+ const t = useTranslations('teams.templates.publish');++ return (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button+ variant="ghost"+ size="icon"+ className="size-7 text-muted-foreground hover:text-foreground"+ aria-label={t('account')}+ >+ <MoreHorizontal />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" className="w-60">+ <DropdownMenuLabel className="flex flex-col gap-0.5 font-normal">+ <span className="text-xs text-muted-foreground">{t('publishingAs')}</span>+ <span className="truncate">{publisher.email}</span>+ </DropdownMenuLabel>+ <DropdownMenuSeparator />+ <DropdownMenuItem onSelect={onChangeAuthor}>+ <UserPen />+ {t('authorProfile')}+ </DropdownMenuItem>+ <DropdownMenuItem onSelect={onChangeEmail}>+ <AtSign />+ {t('changeEmail')}+ </DropdownMenuItem>+ <DropdownMenuItem asChild>+ <a href={TEMPLATE_GALLERY_RULES_URL} target="_blank" rel="noreferrer">+ <BookOpen />+ {t('rules')}+ <ExternalLink className="ms-auto" />+ </a>+ </DropdownMenuItem>+ <DropdownMenuSeparator />+ <DropdownMenuItem variant="destructive" onSelect={onUnlink}>+ <Unlink />+ {t('unlink')}+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ );+}diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceTemplateUnpublishConfirm.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplateUnpublishConfirm.tsxnew file mode 100644index 00000000..fbf5d837--- /dev/null+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplateUnpublishConfirm.tsx@@ -0,0 +1,39 @@+'use client';++import { useTranslations } from 'next-intl';+import { useUnpublishTemplate } from '@/services/projectTemplates.service';+import { Button } from '@/components/ui/button';++// Asks before the gallery page goes down, because its link stops working.+export default function WorkspaceTemplateUnpublishConfirm({+ workspaceId,+ templateId,+ onDone,+}: {+ workspaceId: number;+ templateId: number;+ onDone: () => void;+}) {+ const t = useTranslations('teams.templates.publish');+ const unpublish = useUnpublishTemplate(workspaceId);++ return (+ <div className="flex items-center gap-2 rounded-lg bg-destructive/10 py-2.5 ps-3.5 pe-2.5">+ <div className="min-w-0 flex-1 text-[13px]">+ <p className="font-medium">{t('unpublishConfirm')}</p>+ <p className="text-muted-foreground">{t('unpublishHint')}</p>+ </div>+ <Button variant="ghost" size="sm" onClick={onDone}>+ {t('keep')}+ </Button>+ <Button+ variant="destructive"+ size="sm"+ disabled={unpublish.isPending}+ onClick={() => unpublish.mutate(templateId, { onSuccess: onDone })}+ >+ {t('unpublish')}+ </Button>+ </div>+ );+}diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceTemplatesSection.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatesSection.tsxnew file mode 100644index 00000000..e3d0f675--- /dev/null+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatesSection.tsx@@ -0,0 +1,68 @@+'use client';++import { useState, type ReactNode } from 'react';+import { Import, Plus } from 'lucide-react';+import { useTranslations } from 'next-intl';+import { useWorkspaceProjectTemplatesQuery } from '@/services/projectTemplates.service';+import { EmptyState } from '@/components/common/page/EmptyState';+import SectionPageView from '@/components/common/page/SectionPageView';+import ListSkeleton from '@/components/common/skeleton/ListSkeleton';+import { Button } from '@/components/ui/button';+import WorkspaceTemplateSaveModal from '../WorkspaceTemplateSaveModal';+import WorkspaceTemplateImportModal from './WorkspaceTemplateImportModal';+import WorkspaceTemplatesTable from './WorkspaceTemplatesTable';++// The project templates of the workspace, which its owner and admins save here or from a+// project's panel in a team's Projects, and a team's owners and managers pick when they+// create a project.+export default function WorkspaceTemplatesSection({ workspaceId }: { workspaceId: number }) {+ const t = useTranslations('teams');+ const { data: templates } = useWorkspaceProjectTemplatesQuery(workspaceId);+ const [creating, setCreating] = useState(false);+ const [importing, setImporting] = useState(false);+ const actions = (+ <div className="flex items-center gap-2">+ <Button size="sm" variant="ghost" onClick={() => setImporting(true)}>+ <Import />+ {t('templates.importAction')}+ </Button>+ <Button size="sm" onClick={() => setCreating(true)}>+ <Plus />+ {t('templates.newAction')}+ </Button>+ </div>+ );++ let content: ReactNode;+ if (!templates) {+ content = <ListSkeleton rows={2} rowClassName="h-12" />;+ } else if (templates.length === 0) {+ content = (+ <EmptyState title={t('templates.empty')} description={t('templates.emptyHint')}>+ {actions}+ </EmptyState>+ );+ } else {+ content = <WorkspaceTemplatesTable workspaceId={workspaceId} templates={templates} />;+ }++ return (+ <SectionPageView+ title={t('sections.templates.title')}+ description={t('sections.templates.description')}+ actions={templates?.length ? actions : undefined}+ wide+ >+ {content}+ {creating && (+ <WorkspaceTemplateSaveModal workspaceId={workspaceId} onClose={() => setCreating(false)} />+ )}+ {importing && (+ <WorkspaceTemplateImportModal+ workspaceId={workspaceId}+ onClose={() => setImporting(false)}+ />+ )}+ </SectionPageView>+ );+}diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceTemplatesTable.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatesTable.tsxnew file mode 100644index 00000000..6ec7eb29--- /dev/null+++ b/apps/web/src/features/teams/components/workspace/WorkspaceTemplatesTable.tsx@@ -0,0 +1,178 @@+'use client';++import { useState } from 'react';+import { Copy, Globe, Pencil, Trash2 } from 'lucide-react';+import { useTranslations } from 'next-intl';+import type {+ ProjectTemplate,+ WorkspaceProjectTemplate,+} from '@/lib/api/endpoints/project-templates';+import { formatDate } from '@/utils/dates';+import RowAction from '@/components/common/RowAction';+import {+ Table,+ TableBody,+ TableCell,+ TableHead,+ TableHeader,+ TableRow,+} from '@/components/ui/table';+import { useTemplateExport } from '../../hooks/useTemplateExport';+import { useTemplateTeamsLabel } from '../../hooks/useTemplateTeamsLabel';+import WorkspaceTemplateDeleteDialog from './WorkspaceTemplateDeleteDialog';+import WorkspaceTemplateEditModal from './WorkspaceTemplateEditModal';+import WorkspaceTemplatePanel from './WorkspaceTemplatePanel';+import WorkspaceTemplatePublishDialog from './WorkspaceTemplatePublishDialog';+import WorkspaceTemplatePublishedBadge from './WorkspaceTemplatePublishedBadge';++// The templates of the workspace. A row opens what the template holds in a side panel.+export default function WorkspaceTemplatesTable({+ workspaceId,+ templates,+}: {+ workspaceId: number;+ templates: WorkspaceProjectTemplate[];+}) {+ const t = useTranslations('teams');+ const tCommon = useTranslations('common');+ const teamsLabel = useTemplateTeamsLabel();+ const share = useTemplateExport(workspaceId);+ const [editing, setEditing] = useState<ProjectTemplate | null>(null);+ const [deleting, setDeleting] = useState<WorkspaceProjectTemplate | null>(null);+ const [selectedId, setSelectedId] = useState<number | null>(null);+ const [publishingId, setPublishingId] = useState<number | null>(null);+ // Read from the list, so the panel closes once its template is deleted.+ const selected = templates.find((template) => template.id === selectedId) ?? null;+ const publishing = templates.find((template) => template.id === publishingId) ?? null;++ return (+ <div className="overflow-x-auto">+ <Table className="min-w-[640px] table-fixed">+ <colgroup>+ <col className="w-[46%]" />+ <col className="w-[24%]" />+ <col className="w-[18%]" />+ <col className="w-[12%]" />+ </colgroup>+ <TableHeader>+ <TableRow className="hover:bg-transparent">+ <TableHead className="text-xs font-medium text-muted-foreground">+ {t('columns.template')}+ </TableHead>+ <TableHead className="text-xs font-medium text-muted-foreground">+ {t('templates.teams')}+ </TableHead>+ <TableHead className="text-xs font-medium text-muted-foreground">+ {t('columns.created')}+ </TableHead>+ <TableHead className="text-end text-xs font-medium text-muted-foreground">+ {tCommon('actions')}+ </TableHead>+ </TableRow>+ </TableHeader>+ <TableBody>+ {templates.map((template) => (+ <TableRow+ key={template.id}+ className="cursor-pointer"+ onClick={() => setSelectedId(template.id)}+ >+ <TableCell className="px-3 py-3 whitespace-normal">+ <div className="flex min-w-0 items-center gap-2">+ <p className="min-w-0 text-sm font-medium wrap-anywhere" dir="auto">+ {template.name}+ </p>+ {template.publication && (+ <WorkspaceTemplatePublishedBadge publication={template.publication} />+ )}+ </div>+ {template.description && (+ <p+ className="line-clamp-1 text-xs wrap-anywhere text-muted-foreground"+ dir="auto"+ title={template.description}+ >+ {template.description}+ </p>+ )}+ </TableCell>+ <TableCell className="px-3 py-3 text-sm whitespace-normal text-muted-foreground">+ {teamsLabel(template.teamIds)}+ </TableCell>+ <TableCell className="px-3 py-3 text-sm text-muted-foreground">+ {formatDate(template.createdAt)}+ </TableCell>+ <TableCell className="px-3 py-2 text-end" onClick={(e) => e.stopPropagation()}>+ <RowAction+ icon={Globe}+ label={t(+ template.publication+ ? 'templates.publish.published'+ : 'templates.publish.action',+ )}+ className={+ template.publication ? 'text-emerald-600 dark:text-emerald-400' : undefined+ }+ onClick={() => setPublishingId(template.id)}+ />+ <RowAction+ icon={Copy}+ label={t('templates.copyAction')}+ onClick={() => void share.copy(template)}+ />+ <RowAction+ icon={Pencil}+ label={t('templates.editAction')}+ onClick={() => setEditing(template)}+ />+ <RowAction+ icon={Trash2}+ label={t('templates.deleteAction')}+ destructive+ onClick={() => setDeleting(template)}+ />+ </TableCell>+ </TableRow>+ ))}+ </TableBody>+ </Table>++ {selected && (+ <WorkspaceTemplatePanel+ workspaceId={workspaceId}+ template={selected}+ onEdit={() => setEditing(selected)}+ onPublish={() => setPublishingId(selected.id)}+ onCopy={() => void share.copy(selected)}+ onDownload={() => void share.download(selected)}+ onDelete={() => setDeleting(selected)}+ onClose={() => setSelectedId(null)}+ />+ )}++ {editing && (+ <WorkspaceTemplateEditModal+ workspaceId={workspaceId}+ template={editing}+ onClose={() => setEditing(null)}+ />+ )}++ {publishing && (+ <WorkspaceTemplatePublishDialog+ workspaceId={workspaceId}+ template={publishing}+ onClose={() => setPublishingId(null)}+ />+ )}++ {deleting && (+ <WorkspaceTemplateDeleteDialog+ workspaceId={workspaceId}+ template={deleting}+ onClose={() => setDeleting(null)}+ />+ )}+ </div>+ );+}diff --git a/apps/web/src/features/teams/hooks/useTemplateExport.ts b/apps/web/src/features/teams/hooks/useTemplateExport.tsnew file mode 100644index 00000000..664c602a--- /dev/null+++ b/apps/web/src/features/teams/hooks/useTemplateExport.ts@@ -0,0 +1,34 @@+import { useTranslations } from 'next-intl';+import { toast } from 'sonner';+import { saveTextFile } from '@/utils/download';+import { exportProjectTemplate, type ProjectTemplate } from '@/lib/api/endpoints/project-templates';++// Copies a template of the workspace to the clipboard, or saves it as a file, for another+// workspace to import. Plain reads, so they toast their own failure.+export function useTemplateExport(workspaceId: number) {+ const t = useTranslations('teams.templates');+ const tTransfer = useTranslations('settings.transfer');++ async function read(template: ProjectTemplate): Promise<string> {+ return JSON.stringify(await exportProjectTemplate(workspaceId, template.id), null, 2);+ }++ async function copy(template: ProjectTemplate) {+ try {+ await navigator.clipboard.writeText(await read(template));+ toast.success(t('copied', { name: template.name }));+ } catch {+ toast.error(tTransfer('copyFailed'));+ }+ }++ async function download(template: ProjectTemplate) {+ try {+ saveTextFile(`${template.name}.json`, await read(template));+ } catch {+ toast.error(t('downloadFailed'));+ }+ }++ return { copy, download };+}diff --git a/apps/web/src/features/teams/hooks/useTemplateTeamsLabel.ts b/apps/web/src/features/teams/hooks/useTemplateTeamsLabel.tsnew file mode 100644index 00000000..d8f7f317--- /dev/null+++ b/apps/web/src/features/teams/hooks/useTemplateTeamsLabel.ts@@ -0,0 +1,14 @@+import { useTranslations } from 'next-intl';+import { useTeamsQuery } from '@/services/teams.service';++// Names the teams a project template is open to: all of the workspace, none once the+// teams it was limited to are deleted, or those teams.+export function useTemplateTeamsLabel(): (teamIds: number[] | null) => string {+ const t = useTranslations('teams.templates');+ const teams = useTeamsQuery().data;+ return (teamIds) => {+ if (teamIds === null) return t('allTeams');+ if (teamIds.length === 0) return t('noTeams');+ return teamIds.flatMap((id) => teams?.find((team) => team.id === id)?.name ?? []).join(', ');+ };+}diff --git a/apps/web/src/features/teams/hooks/useWorkspaceSettingsSections.ts b/apps/web/src/features/teams/hooks/useWorkspaceSettingsSections.tsindex dcb9d570..deea2197 100644--- a/apps/web/src/features/teams/hooks/useWorkspaceSettingsSections.ts+++ b/apps/web/src/features/teams/hooks/useWorkspaceSettingsSections.ts@@ -1,4 +1,4 @@-import { BadgeDollarSign, Clock3, Coins, Info, ShieldCheck } from 'lucide-react';+import { BadgeDollarSign, Clock3, Coins, Info, LayoutTemplate, ShieldCheck } from 'lucide-react';import { useTranslations } from 'next-intl';import { useWorkspaceSections } from '@/cloud';import type { WorkspaceSummary } from '@/lib/api/endpoints/workspaces';@@ -8,13 +8,20 @@ import { useWorkspaceQuery } from '@/services/workspaces.service';// Grouped in menu order, so the first entry, the page a workspace opens on// (WorkspaceFirstSection), is the first of the top group.// Only the workspace's owner and its admins open them (WorkspaceLayout), and both read-// what the agents spent and set the model prices it is costed at.+// what the agents spent, keep its project templates and set the model prices it is costed at.export function useWorkspaceSettingsSections(workspace: WorkspaceSummary): WorkspaceSection[] {const t = useTranslations('teams.workspace');+ const tSections = useTranslations('teams.sections');const detail = useWorkspaceQuery(workspace.id).data;const sections = useWorkspaceSections(workspace, [{ id: 'queue', label: t('queue.title'), icon: Clock3, group: 'overview' },{ id: 'agent-usage', label: t('agentUsage.title'), icon: Coins, group: 'overview' },+ {+ id: 'templates',+ label: tSections('templates.title'),+ icon: LayoutTemplate,+ group: 'overview',+ },{ id: 'info', label: t('general'), icon: Info, group: 'settings' },{id: 'managers',diff --git a/apps/web/src/lib/api/endpoints/project-templates.ts b/apps/web/src/lib/api/endpoints/project-templates.tsindex fc69f0ac..5ed9a88e 100644--- a/apps/web/src/lib/api/endpoints/project-templates.ts+++ b/apps/web/src/lib/api/endpoints/project-templates.ts@@ -1,58 +1,209 @@import { request } from '@/lib/api/core/client';-import type { ActionDef } from '@/lib/api/endpoints/actions';-import type { Column } from '@/lib/api/endpoints/columns';+import type { StateType } from '@/lib/api/endpoints/columns';import type { CustomField } from '@/lib/api/endpoints/customFields';-import type { Dashboard } from '@/lib/api/endpoints/dashboards';-import type { IssueTemplate } from '@/lib/api/endpoints/issueTemplates';-import type { IssueType } from '@/lib/api/endpoints/issueTypes';-import type { Label, LabelGroup } from '@/lib/api/endpoints/labels';import type { EstimateSettings, ProjectFeatures } from '@/lib/api/endpoints/settings';-import type { View } from '@/lib/api/endpoints/views';-// A saved copy of a project's configuration that new projects of the team start from.+// A snapshot of a project's configuration that new projects of the workspace's teams start+// from. `teamIds` is null when every team of the workspace sees it.export interface ProjectTemplate {id: number;name: string;description: string;+ teamIds: number[] | null;createdAt: string;}-// What a template holds. `sections` are the parts the hosted build adds, by the key of-// their copy option, with the names of what each holds.-export interface ProjectTemplateDetail extends ProjectTemplate {- columns: Column[];- issueTypes: IssueType[];- labels: Label[];- labelGroups: LabelGroup[];- customFields: CustomField[];- issueTemplates: IssueTemplate[];- views: View[];- dashboards: Dashboard[];- actions: ActionDef[];+// What a template holds. Every entity keeps the id it had in the project the template was+// saved from, which is how the others reference it. `sections` are the parts the hosted+// build adds, by the key of their copy option, with the names of what each holds.+export interface TemplateContents {+ columns: {+ id: number;+ name: string;+ stateType: StateType;+ color: string;+ wipLimit: number | null;+ wipMode: 'soft' | 'hard';+ }[];+ issueTypes: { id: number; name: string; icon: string; color: string; isDefault: boolean }[];+ labelGroups: { id: number; name: string; color: string }[];+ labels: { id: number; groupId: number | null; name: string; color: string }[];+ customFields: {+ id: number;+ issueTypeId: number | null;+ name: string;+ fieldType: CustomField['fieldType'];+ memberScope: 'all' | 'humans' | 'agents' | null;+ showInBody: boolean;+ options: { id: number; value: string; color: string }[];+ }[];+ issueTemplates: {+ name: string;+ typeId: number | null;+ columnId: number | null;+ priority: string | null;+ labelIds: number[];+ }[];+ // The display, layout and effect blobs are the UI's own, as the views, dashboards and+ // actions store them.+ views: { name: string; display: unknown }[];+ dashboards: { name: string; layout: unknown }[];+ actions: { name: string; effect: unknown }[];+ settings: { key: string; value: unknown }[];features: ProjectFeatures;estimates: EstimateSettings;sections: { key: string; items: string[] }[];}-export const getProjectTemplate = (teamId: number, templateId: number) =>- request<ProjectTemplateDetail>(`/teams/${teamId}/project-templates/${templateId}`);+export interface ProjectTemplateDetail extends ProjectTemplate, TemplateContents {}++// A template's page in the gallery at itsaplan.dev.+export interface TemplatePublication {+ url: string;+ publishedAt: string;+}++// A template as its workspace lists it, with its page in the gallery, null while it is+// not published.+export interface WorkspaceProjectTemplate extends ProjectTemplate {+ publication: TemplatePublication | null;+}++// The gallery address a workspace publishes under, and the author the gallery shows on+// every template from it. `authorName` is empty until someone names one.+export interface TemplatePublisher {+ email: string;+ authorName: string;+ authorUrl: string | null;+}-export const listProjectTemplates = (teamId: number) =>+export const listTeamProjectTemplates = (teamId: number) =>request<ProjectTemplate[]>(`/teams/${teamId}/project-templates`);+export const getTeamProjectTemplate = (teamId: number, templateId: number) =>+ request<ProjectTemplateDetail>(`/teams/${teamId}/project-templates/${templateId}`);++export const listWorkspaceProjectTemplates = (workspaceId: number) =>+ request<WorkspaceProjectTemplate[]>(`/workspaces/${workspaceId}/project-templates`);++export const getWorkspaceProjectTemplate = (workspaceId: number, templateId: number) =>+ request<ProjectTemplateDetail>(`/workspaces/${workspaceId}/project-templates/${templateId}`);++// What a template saved from the project with this selection would hold.+export const previewProjectTemplate = (+ workspaceId: number,+ input: { projectId: number; include?: Record<string, boolean> },+) =>+ request<TemplateContents>(`/workspaces/${workspaceId}/project-templates/preview`, {+ method: 'POST',+ body: JSON.stringify(input),+ });+export const saveProjectTemplate = (- teamId: number,+ workspaceId: number,input: {projectId: number;name: string;description?: string;include?: Record<string, boolean>;+ teamIds?: number[];+ },+) =>+ request<ProjectTemplate>(`/workspaces/${workspaceId}/project-templates`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++// `teamIds` null opens the template to every team of the workspace.+export const updateProjectTemplate = (+ workspaceId: number,+ templateId: number,+ patch: { name?: string; description?: string; teamIds?: number[] | null },+) =>+ request<ProjectTemplate>(`/workspaces/${workspaceId}/project-templates/${templateId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++// A template as another workspace imports it, on this instance or another one. The web+// app copies, saves and pastes it whole; the server checks it.+export interface SharedProjectTemplate {+ format: string;+ version: number;+ name: string;+ description: string;+ snapshot: unknown;+}++export const exportProjectTemplate = (workspaceId: number, templateId: number) =>+ request<SharedProjectTemplate>(+ `/workspaces/${workspaceId}/project-templates/${templateId}/export`,+ );++export const previewImportedTemplate = (workspaceId: number, template: SharedProjectTemplate) =>+ request<TemplateContents>(`/workspaces/${workspaceId}/project-templates/import/preview`, {+ method: 'POST',+ body: JSON.stringify({ template }),+ });++export const importProjectTemplate = (+ workspaceId: number,+ input: {+ template: SharedProjectTemplate;+ name: string;+ description?: string;+ teamIds?: number[];},) =>- request<ProjectTemplate>(`/teams/${teamId}/project-templates`, {+ request<ProjectTemplate>(`/workspaces/${workspaceId}/project-templates/import`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const getTemplatePublisher = (workspaceId: number) =>+ request<{ publisher: TemplatePublisher | null }>(+ `/workspaces/${workspaceId}/template-publisher`,+ ).then((answer) => answer.publisher);++export const requestPublisherCode = (workspaceId: number, email: string) =>+ request<void>(`/workspaces/${workspaceId}/template-publisher/code`, {+ method: 'POST',+ body: JSON.stringify({ email }),+ });++export const linkTemplatePublisher = (+ workspaceId: number,+ input: { email: string; code: string },+) =>+ request<TemplatePublisher>(`/workspaces/${workspaceId}/template-publisher`, {method: 'POST',body: JSON.stringify(input),});-export const deleteProjectTemplate = (teamId: number, templateId: number) =>- request<void>(`/teams/${teamId}/project-templates/${templateId}`, { method: 'DELETE' });+export const unlinkTemplatePublisher = (workspaceId: number) =>+ request<void>(`/workspaces/${workspaceId}/template-publisher`, { method: 'DELETE' });++export const setTemplatePublisherAuthor = (+ workspaceId: number,+ author: { authorName: string; authorUrl: string | null },+) =>+ request<TemplatePublisher>(`/workspaces/${workspaceId}/template-publisher/author`, {+ method: 'PUT',+ body: JSON.stringify(author),+ });++export const publishTemplate = (workspaceId: number, templateId: number) =>+ request<TemplatePublication>(+ `/workspaces/${workspaceId}/project-templates/${templateId}/publication`,+ { method: 'POST' },+ );++export const unpublishTemplate = (workspaceId: number, templateId: number) =>+ request<void>(`/workspaces/${workspaceId}/project-templates/${templateId}/publication`, {+ method: 'DELETE',+ });++export const deleteProjectTemplate = (workspaceId: number, templateId: number) =>+ request<void>(`/workspaces/${workspaceId}/project-templates/${templateId}`, {+ method: 'DELETE',+ });diff --git a/apps/web/src/lib/api/endpoints/teams.ts b/apps/web/src/lib/api/endpoints/teams.tsindex 26e02cdf..42e44433 100644--- a/apps/web/src/lib/api/endpoints/teams.ts+++ b/apps/web/src/lib/api/endpoints/teams.ts@@ -32,7 +32,6 @@ export interface Team {source: 'invite' | 'scim';joinedAt: string;projectCount: number;- templateCount: number;memberCount: number;// How many of those members are owners: the last one cannot leave.ownerCount: number;diff --git a/apps/web/src/services/projectTemplates.service.ts b/apps/web/src/services/projectTemplates.service.tsindex c5e3725c..9a127c81 100644--- a/apps/web/src/services/projectTemplates.service.ts+++ b/apps/web/src/services/projectTemplates.service.ts@@ -1,54 +1,185 @@-import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';+import { keepPreviousData, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';import {deleteProjectTemplate,- getProjectTemplate,- listProjectTemplates,+ getTeamProjectTemplate,+ getTemplatePublisher,+ getWorkspaceProjectTemplate,+ importProjectTemplate,+ linkTemplatePublisher,+ listTeamProjectTemplates,+ listWorkspaceProjectTemplates,+ previewImportedTemplate,+ previewProjectTemplate,+ publishTemplate,+ requestPublisherCode,saveProjectTemplate,+ setTemplatePublisherAuthor,+ unlinkTemplatePublisher,+ unpublishTemplate,+ updateProjectTemplate,+ type ProjectTemplateDetail,+ type SharedProjectTemplate,} from '@/lib/api/endpoints/project-templates';import { qk } from '@/services/queryKeys';-// The team list carries how many templates each team holds, so a save or a delete-// refreshes it too.-function useTemplateMutation<TInput, TResult>(- teamId: number,- mutationFn: (input: TInput) => Promise<TResult>,-) {+function useTemplateMutation<TInput, TResult>(mutationFn: (input: TInput) => Promise<TResult>) {const qc = useQueryClient();return useMutation({mutationFn,- onSuccess: () => {- qc.invalidateQueries({ queryKey: qk.projectTemplates(teamId) });- qc.invalidateQueries({ queryKey: qk.teams });- },+ onSuccess: () => qc.invalidateQueries({ queryKey: qk.projectTemplates }),});}-// The team's project templates. Pass null where the caller has no use for them, to skip-// the request.-export function useProjectTemplatesQuery(teamId: number | null) {+// The templates a team sees, for creating its projects. Pass null where the caller has+// no use for them, to skip the request.+export function useTeamProjectTemplatesQuery(teamId: number | null) {return useQuery({- queryKey: qk.projectTemplates(teamId ?? 0),- queryFn: () => listProjectTemplates(teamId!),+ queryKey: qk.teamProjectTemplates(teamId ?? 0),+ queryFn: () => listTeamProjectTemplates(teamId!),enabled: teamId != null,});}-// What one template holds, read when its row is opened.-export function useProjectTemplateQuery(teamId: number, templateId: number) {+export function useWorkspaceProjectTemplatesQuery(workspaceId: number) {return useQuery({- queryKey: qk.projectTemplate(teamId, templateId),- queryFn: () => getProjectTemplate(teamId, templateId),+ queryKey: qk.workspaceProjectTemplates(workspaceId),+ queryFn: () => listWorkspaceProjectTemplates(workspaceId),});}-export function useSaveProjectTemplate(teamId: number) {- return useTemplateMutation(teamId, (input: Parameters<typeof saveProjectTemplate>[1]) =>- saveProjectTemplate(teamId, input),+// Where a template is read from: the team that creates a project from it, or the workspace+// that holds it.+export type TemplateScope = { teamId: number } | { workspaceId: number };++// What one template holds, read when it is opened.+export function useProjectTemplateQuery(scope: TemplateScope, templateId: number) {+ return useQuery<ProjectTemplateDetail, Error, ProjectTemplateDetail, readonly unknown[]>({+ queryKey:+ 'teamId' in scope+ ? qk.teamProjectTemplate(scope.teamId, templateId)+ : qk.workspaceProjectTemplate(scope.workspaceId, templateId),+ queryFn: () =>+ 'teamId' in scope+ ? getTeamProjectTemplate(scope.teamId, templateId)+ : getWorkspaceProjectTemplate(scope.workspaceId, templateId),+ });+}++// What a template of the project would hold with this selection. The previous answer+// stays on screen while the next one loads, so a toggled section does not blank it.+export function useProjectTemplatePreviewQuery(+ workspaceId: number,+ projectId: number | null,+ include: Record<string, boolean>,+) {+ return useQuery({+ queryKey: qk.projectTemplatePreview(workspaceId, projectId ?? 0, include),+ queryFn: () => previewProjectTemplate(workspaceId, { projectId: projectId!, include }),+ enabled: projectId != null,+ placeholderData: keepPreviousData,+ });+}++// What a pasted template would hold once imported. The server refuses one that is not a+// template or is damaged, which is an answer, not a failure to retry.+export function useImportedTemplatePreviewQuery(+ workspaceId: number,+ template: SharedProjectTemplate | null,+) {+ return useQuery({+ queryKey: qk.importedTemplatePreview(workspaceId, template),+ queryFn: () => previewImportedTemplate(workspaceId, template!),+ enabled: template !== null,+ retry: false,+ });+}++export function useImportProjectTemplate(workspaceId: number) {+ return useTemplateMutation((input: Parameters<typeof importProjectTemplate>[1]) =>+ importProjectTemplate(workspaceId, input),+ );+}++export function useSaveProjectTemplate(workspaceId: number) {+ return useTemplateMutation((input: Parameters<typeof saveProjectTemplate>[1]) =>+ saveProjectTemplate(workspaceId, input),);}-export function useDeleteProjectTemplate(teamId: number) {- return useTemplateMutation(teamId, (templateId: number) =>- deleteProjectTemplate(teamId, templateId),+export function useUpdateProjectTemplate(workspaceId: number) {+ return useTemplateMutation(+ ({+ templateId,+ patch,+ }: {+ templateId: number;+ patch: Parameters<typeof updateProjectTemplate>[2];+ }) => updateProjectTemplate(workspaceId, templateId, patch),+ );+}++export function useTemplatePublisherQuery(workspaceId: number) {+ return useQuery({+ queryKey: qk.templatePublisher(workspaceId),+ queryFn: () => getTemplatePublisher(workspaceId),+ });+}++export function useRequestPublisherCode(workspaceId: number) {+ return useMutation({ mutationFn: (email: string) => requestPublisherCode(workspaceId, email) });+}++// Each of these changes the publisher, the templates, or both.+function usePublisherMutation<TInput, TResult>(+ workspaceId: number,+ mutationFn: (input: TInput) => Promise<TResult>,+ meta?: { suppressErrorToast: true },+) {+ const qc = useQueryClient();+ return useMutation({+ mutationFn,+ meta,+ onSuccess: () =>+ Promise.all([+ qc.invalidateQueries({ queryKey: qk.projectTemplates }),+ qc.invalidateQueries({ queryKey: qk.templatePublisher(workspaceId) }),+ ]),+ });+}++// A refused code shows under the code cells.+export function useLinkTemplatePublisher(workspaceId: number) {+ return usePublisherMutation(+ workspaceId,+ (input: { email: string; code: string }) => linkTemplatePublisher(workspaceId, input),+ { suppressErrorToast: true },+ );+}++export function useUnlinkTemplatePublisher(workspaceId: number) {+ return usePublisherMutation(workspaceId, () => unlinkTemplatePublisher(workspaceId));+}++export function useSetPublisherAuthor(workspaceId: number) {+ return usePublisherMutation(+ workspaceId,+ (author: Parameters<typeof setTemplatePublisherAuthor>[1]) =>+ setTemplatePublisherAuthor(workspaceId, author),+ );+}++export function usePublishTemplate(workspaceId: number) {+ return usePublisherMutation(workspaceId, (templateId: number) =>+ publishTemplate(workspaceId, templateId),+ );+}++export function useUnpublishTemplate(workspaceId: number) {+ return useTemplateMutation((templateId: number) => unpublishTemplate(workspaceId, templateId));+}++export function useDeleteProjectTemplate(workspaceId: number) {+ return useTemplateMutation((templateId: number) =>+ deleteProjectTemplate(workspaceId, templateId),);}diff --git a/apps/web/src/services/queryKeys.ts b/apps/web/src/services/queryKeys.tsindex 26753828..9036b277 100644--- a/apps/web/src/services/queryKeys.ts+++ b/apps/web/src/services/queryKeys.ts@@ -34,9 +34,21 @@ export const qk = {scimGroups: (workspaceId: number | null) => [...scimKey(workspaceId), 'groups'] as const,scimProjects: (workspaceId: number | null) => [...scimKey(workspaceId), 'projects'] as const,teamProjectDefaults: (teamId: number) => ['team', teamId, 'project-defaults'] as const,- projectTemplates: (teamId: number) => ['team', teamId, 'project-templates'] as const,- projectTemplate: (teamId: number, templateId: number) =>- ['team', teamId, 'project-templates', templateId] as const,+ // The project templates of a workspace and those its teams see share one root, since+ // saving or deleting one changes the lists of every team.+ projectTemplates: ['project-templates'] as const,+ teamProjectTemplates: (teamId: number) => ['project-templates', 'team', teamId] as const,+ teamProjectTemplate: (teamId: number, templateId: number) =>+ ['project-templates', 'team', teamId, templateId] as const,+ workspaceProjectTemplates: (workspaceId: number) =>+ ['project-templates', 'workspace', workspaceId] as const,+ workspaceProjectTemplate: (workspaceId: number, templateId: number) =>+ ['project-templates', 'workspace', workspaceId, templateId] as const,+ importedTemplatePreview: (workspaceId: number, template: unknown) =>+ ['project-templates', 'workspace', workspaceId, 'import', template] as const,+ projectTemplatePreview: (workspaceId: number, projectId: number, include: unknown) =>+ ['project-templates', 'workspace', workspaceId, 'preview', projectId, include] as const,+ templatePublisher: (workspaceId: number) => ['template-publisher', workspaceId] as const,// The members of a team and the projects it owns, each read by its own section. A// page is scoped by the search term and the window it was read with.teamMembers: (teamId: number, params: unknown) => ['team', teamId, 'members', params] as const,diff --git a/apps/web/src/services/teams.service.ts b/apps/web/src/services/teams.service.tsindex 994c16ea..690cc96b 100644--- a/apps/web/src/services/teams.service.ts+++ b/apps/web/src/services/teams.service.ts@@ -87,12 +87,13 @@ export function useTeamProjectsQuery(teamId: number, params: TeamProjectListPara});}-// Every project the reader has in the team: the projects an agent is attached to,-// and the MCP switches, both of which act on all of them rather than on a page.-export function useTeamProjectOptionsQuery(teamId: number) {+// Every project the reader has in the team, for the pickers and switches that act on all+// of them rather than on a page. Null skips the request.+export function useTeamProjectOptionsQuery(teamId: number | null) {return useQuery({- queryKey: qk.teamProjectOptions(teamId),- queryFn: () => listTeamProjectOptions(teamId),+ queryKey: qk.teamProjectOptions(teamId ?? 0),+ queryFn: () => listTeamProjectOptions(teamId!),+ enabled: teamId != null,});}diff --git a/apps/web/src/utils/app.ts b/apps/web/src/utils/app.tsindex 6230a095..67eead53 100644--- a/apps/web/src/utils/app.ts+++ b/apps/web/src/utils/app.ts@@ -7,6 +7,9 @@ export const APP_NAME = "It's a Plan";// The product site. The product mark on the public share pages links to it.export const APP_SITE_URL = 'https://itsaplan.dev/';+// The rules a template published to the gallery at itsaplan.dev must follow.+export const TEMPLATE_GALLERY_RULES_URL = 'https://itsaplan.dev/terms#template-gallery';+// The page about the other editions, linked wherever the app names what they add.export const PRO_URL = 'https://itsaplan.dev/pro';diff --git a/apps/web/src/utils/download.ts b/apps/web/src/utils/download.tsnew file mode 100644index 00000000..717e9330--- /dev/null+++ b/apps/web/src/utils/download.ts@@ -0,0 +1,13 @@+// Saves text as a file in the browser, through a link to a blob URL. Characters a file+// name cannot hold become dashes.+export function saveTextFile(name: string, text: string, type = 'application/json'): void {+ const url = URL.createObjectURL(new Blob([text], { type }));+ const anchor = document.createElement('a');+ anchor.href = url;+ anchor.download = name.replace(/[\\/:*?"<>|]+/g, '-');+ anchor.hidden = true;+ document.body.append(anchor);+ anchor.click();+ anchor.remove();+ window.setTimeout(() => URL.revokeObjectURL(url), 1000);+}diff --git a/apps/web/src/utils/paths.ts b/apps/web/src/utils/paths.tsindex ddf8e099..81a1370c 100644--- a/apps/web/src/utils/paths.ts+++ b/apps/web/src/utils/paths.ts@@ -155,7 +155,6 @@ export const manageTeamsPath = () => '/account/teams';export type TeamSection =| 'info'| 'projects'- | 'templates'| 'members'| 'roles'| 'integrations'diff --git a/packages/db/drizzle/0172_workspace_project_templates.sql b/packages/db/drizzle/0172_workspace_project_templates.sqlnew file mode 100644index 00000000..6a230d30--- /dev/null+++ b/packages/db/drizzle/0172_workspace_project_templates.sql@@ -0,0 +1,147 @@+CREATE TABLE "project_template" (+ "id" serial PRIMARY KEY NOT NULL,+ "workspace_id" integer NOT NULL,+ "name" text NOT NULL,+ "description" text DEFAULT '' NOT NULL,+ "snapshot" jsonb NOT NULL,+ "all_teams" boolean DEFAULT true NOT NULL,+ "created_at" timestamp with time zone DEFAULT now() NOT NULL+);+--> statement-breakpoint+CREATE TABLE "project_template_team" (+ "template_id" integer NOT NULL,+ "team_id" integer NOT NULL,+ CONSTRAINT "project_template_team_template_id_team_id_pk" PRIMARY KEY("template_id","team_id")+);+--> statement-breakpoint+ALTER TABLE "project_template" ADD CONSTRAINT "project_template_workspace_id_workspace_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspace"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint+ALTER TABLE "project_template_team" ADD CONSTRAINT "project_template_team_template_id_project_template_id_fk" FOREIGN KEY ("template_id") REFERENCES "public"."project_template"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint+ALTER TABLE "project_template_team" ADD CONSTRAINT "project_template_team_team_id_team_id_fk" FOREIGN KEY ("team_id") REFERENCES "public"."team"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint+CREATE INDEX "project_template_workspace_idx" ON "project_template" USING btree ("workspace_id");--> statement-breakpoint+CREATE INDEX "project_template_team_team_idx" ON "project_template_team" USING btree ("team_id");--> statement-breakpoint+-- Moves each template stored as a project into a snapshot of the workspace, limited to the+-- team that held it. The snapshot has the shape of ProjectSnapshot (apps/api+-- modules/projects/copy.ts), without the sections an extension adds; the template project is+-- deleted below with everything it held. A workspace has one list of templates, so where two+-- teams of one workspace hold a template of the same name, each takes its team's name after it.+DO $$+DECLARE+ source record;+ moved integer;+BEGIN+ FOR source IN+ SELECT p.*, t."workspace_id" AS "template_workspace_id",+ CASE WHEN EXISTS (+ SELECT 1 FROM "project" o JOIN "team" ot ON ot."id" = o."team_id"+ WHERE o."is_template" AND ot."workspace_id" = t."workspace_id"+ AND o."team_id" <> p."team_id" AND lower(o."name") = lower(p."name")+ ) THEN p."name" || ' (' || t."name" || ')' ELSE p."name" END AS "template_name"+ FROM "project" p JOIN "team" t ON t."id" = p."team_id"+ WHERE p."is_template"+ LOOP+ INSERT INTO "project_template" ("workspace_id", "name", "description", "snapshot", "all_teams", "created_at")+ VALUES (+ source."template_workspace_id",+ source."template_name",+ source."description",+ jsonb_build_object(+ 'flags', jsonb_build_object(+ 'initiativesEnabled', source."initiatives_enabled",+ 'dashboardsEnabled', source."dashboards_enabled",+ 'documentsEnabled', source."documents_enabled",+ 'notesEnabled', source."notes_enabled",+ 'cyclesEnabled', source."cycles_enabled",+ 'subtasksEnabled', source."subtasks_enabled",+ 'checklistsEnabled', source."checklists_enabled",+ 'issueStatsEnabled', source."issue_stats_enabled",+ 'pointsEstimateEnabled', source."points_estimate_enabled",+ 'timeEstimateEnabled', source."time_estimate_enabled",+ 'timeLoggingEnabled', source."time_logging_enabled"+ ),+ 'columns', COALESCE((+ SELECT jsonb_agg(jsonb_build_object(+ 'id', c."id", 'name', c."name", 'stateType', c."state_type", 'color', c."color",+ 'position', c."position", 'wipLimit', c."wip_limit", 'wipMode', c."wip_mode"+ ) ORDER BY c."position")+ FROM "project_column" c WHERE c."project_id" = source."id"+ ), '[]'::jsonb),+ 'issueTypes', COALESCE((+ SELECT jsonb_agg(jsonb_build_object(+ 'id', x."id", 'name', x."name", 'icon', x."icon", 'color', x."color",+ 'isDefault', x."is_default", 'position', x."position"+ ) ORDER BY x."position")+ FROM "issue_type" x WHERE x."project_id" = source."id"+ ), '[]'::jsonb),+ 'labelGroups', COALESCE((+ SELECT jsonb_agg(jsonb_build_object('id', g."id", 'name', g."name", 'color', g."color") ORDER BY g."id")+ FROM "label_group" g WHERE g."project_id" = source."id"+ ), '[]'::jsonb),+ 'labels', COALESCE((+ SELECT jsonb_agg(jsonb_build_object(+ 'id', l."id", 'groupId', l."group_id", 'name', l."name", 'color', l."color"+ ) ORDER BY l."id")+ FROM "label" l WHERE l."project_id" = source."id"+ ), '[]'::jsonb),+ 'customFields', COALESCE((+ SELECT jsonb_agg(jsonb_build_object(+ 'id', f."id", 'issueTypeId', f."issue_type_id", 'name', f."name",+ 'fieldType', f."field_type", 'memberScope', f."member_scope",+ 'showInBody', f."show_in_body", 'position', f."position",+ 'options', COALESCE((+ SELECT jsonb_agg(jsonb_build_object(+ 'id', o."id", 'value', o."value", 'color', o."color", 'position', o."position"+ ) ORDER BY o."position")+ FROM "custom_field_option" o WHERE o."field_id" = f."id"+ ), '[]'::jsonb)+ ) ORDER BY f."position")+ FROM "custom_field" f WHERE f."project_id" = source."id"+ ), '[]'::jsonb),+ 'issueTemplates', COALESCE((+ SELECT jsonb_agg(jsonb_build_object(+ 'name', it."name", 'description', it."description",+ 'titleTemplate', it."title_template", 'descriptionTemplate', it."description_template",+ 'typeId', it."type_id", 'columnId', it."column_id", 'priority', it."priority",+ 'labelIds', COALESCE((+ SELECT jsonb_agg(itl."label_id") FROM "issue_template_label" itl+ WHERE itl."template_id" = it."id"+ ), '[]'::jsonb)+ ) ORDER BY it."id")+ FROM "issue_template" it WHERE it."project_id" = source."id"+ ), '[]'::jsonb),+ 'views', COALESCE((+ SELECT jsonb_agg(jsonb_build_object(+ 'name', v."name", 'icon', v."icon", 'filters', v."filters", 'display', v."display",+ 'position', v."position"+ ) ORDER BY v."position", v."id")+ FROM "project_view" v WHERE v."project_id" = source."id" AND NOT v."is_private"+ ), '[]'::jsonb),+ 'dashboards', COALESCE((+ SELECT jsonb_agg(jsonb_build_object(+ 'name', d."name", 'icon', d."icon", 'layout', d."layout", 'position', d."position"+ ) ORDER BY d."position", d."id")+ FROM "project_dashboard" d WHERE d."project_id" = source."id"+ ), '[]'::jsonb),+ 'actions', COALESCE((+ SELECT jsonb_agg(jsonb_build_object(+ 'name', a."name", 'icon', a."icon", 'condition', a."condition", 'effect', a."effect",+ 'position', a."position"+ ) ORDER BY a."position", a."id")+ FROM "project_action" a WHERE a."project_id" = source."id"+ ), '[]'::jsonb),+ 'settings', COALESCE((+ SELECT jsonb_agg(jsonb_build_object('key', s."key", 'value', s."value") ORDER BY s."key")+ FROM "project_setting" s WHERE s."project_id" = source."id" AND s."key" <> 'git'+ ), '[]'::jsonb),+ 'sections', '{}'::jsonb+ ),+ false,+ source."created_at"+ )+ RETURNING "id" INTO moved;+ INSERT INTO "project_template_team" ("template_id", "team_id") VALUES (moved, source."team_id");+ END LOOP;+END $$;--> statement-breakpoint+DELETE FROM "project" WHERE "is_template";--> statement-breakpoint+-- The delete leaves deferred trigger events, which would refuse the ALTER below.+SET CONSTRAINTS ALL IMMEDIATE;--> statement-breakpoint+ALTER TABLE "project" DROP COLUMN "is_template";\ No newline at end of filediff --git a/packages/db/drizzle/0173_template_gallery.sql b/packages/db/drizzle/0173_template_gallery.sqlnew file mode 100644index 00000000..5ba4bf04--- /dev/null+++ b/packages/db/drizzle/0173_template_gallery.sql@@ -0,0 +1,15 @@+CREATE TABLE "template_publisher" (+ "workspace_id" integer PRIMARY KEY NOT NULL,+ "email" text NOT NULL,+ "key_ciphertext" text NOT NULL,+ "key_iv" text NOT NULL,+ "key_auth_tag" text NOT NULL,+ "author_name" text DEFAULT '' NOT NULL,+ "author_url" text,+ "created_at" timestamp with time zone DEFAULT now() NOT NULL+);+--> statement-breakpoint+ALTER TABLE "project_template" ADD COLUMN "publication_id" text;--> statement-breakpoint+ALTER TABLE "project_template" ADD COLUMN "publication_url" text;--> statement-breakpoint+ALTER TABLE "project_template" ADD COLUMN "published_at" timestamp with time zone;--> statement-breakpoint+ALTER TABLE "template_publisher" ADD CONSTRAINT "template_publisher_workspace_id_workspace_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspace"("id") ON DELETE cascade ON UPDATE no action;\ No newline at end of filediff --git a/packages/db/drizzle/meta/0172_snapshot.json b/packages/db/drizzle/meta/0172_snapshot.jsonnew file mode 100644index 00000000..7056b578--- /dev/null+++ b/packages/db/drizzle/meta/0172_snapshot.json@@ -0,0 +1,13026 @@+{+ "id": "9d240549-0640-404e-963f-bab8fbfb9830",+ "prevId": "339ae826-47c7-40f2-9d48-08df4c222a4a",+ "version": "7",+ "dialect": "postgresql",+ "tables": {+ "public.account": {+ "name": "account",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "account_id": {+ "name": "account_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_id": {+ "name": "provider_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "access_token_expires_at": {+ "name": "access_token_expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token_expires_at": {+ "name": "refresh_token_expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "password": {+ "name": "password",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "account_userId_idx": {+ "name": "account_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "account_user_id_user_id_fk": {+ "name": "account_user_id_user_id_fk",+ "tableFrom": "account",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.apikey": {+ "name": "apikey",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "config_id": {+ "name": "config_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'default'"+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "start": {+ "name": "start",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reference_id": {+ "name": "reference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prefix": {+ "name": "prefix",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "refill_interval": {+ "name": "refill_interval",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "refill_amount": {+ "name": "refill_amount",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "last_refill_at": {+ "name": "last_refill_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "rate_limit_enabled": {+ "name": "rate_limit_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "rate_limit_time_window": {+ "name": "rate_limit_time_window",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 1000+ },+ "rate_limit_max": {+ "name": "rate_limit_max",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 100+ },+ "request_count": {+ "name": "request_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "remaining": {+ "name": "remaining",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "last_request": {+ "name": "last_request",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "permissions": {+ "name": "permissions",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "apikey_configId_idx": {+ "name": "apikey_configId_idx",+ "columns": [+ {+ "expression": "config_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "apikey_referenceId_idx": {+ "name": "apikey_referenceId_idx",+ "columns": [+ {+ "expression": "reference_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "apikey_key_idx": {+ "name": "apikey_key_idx",+ "columns": [+ {+ "expression": "key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.jwks": {+ "name": "jwks",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "public_key": {+ "name": "public_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "private_key": {+ "name": "private_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "alg": {+ "name": "alg",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "crv": {+ "name": "crv",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_access_token": {+ "name": "oauth_access_token",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reference_id": {+ "name": "reference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "authorization_code_id": {+ "name": "authorization_code_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resources": {+ "name": "resources",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "requested_user_info_claims": {+ "name": "requested_user_info_claims",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_id": {+ "name": "refresh_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "revoked": {+ "name": "revoked",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "confirmation": {+ "name": "confirmation",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "scopes": {+ "name": "scopes",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "oauthAccessToken_clientId_idx": {+ "name": "oauthAccessToken_clientId_idx",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthAccessToken_sessionId_idx": {+ "name": "oauthAccessToken_sessionId_idx",+ "columns": [+ {+ "expression": "session_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthAccessToken_userId_idx": {+ "name": "oauthAccessToken_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthAccessToken_authorizationCodeId_idx": {+ "name": "oauthAccessToken_authorizationCodeId_idx",+ "columns": [+ {+ "expression": "authorization_code_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthAccessToken_refreshId_idx": {+ "name": "oauthAccessToken_refreshId_idx",+ "columns": [+ {+ "expression": "refresh_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oauth_access_token_client_id_oauth_client_client_id_fk": {+ "name": "oauth_access_token_client_id_oauth_client_client_id_fk",+ "tableFrom": "oauth_access_token",+ "tableTo": "oauth_client",+ "columnsFrom": [+ "client_id"+ ],+ "columnsTo": [+ "client_id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oauth_access_token_session_id_session_id_fk": {+ "name": "oauth_access_token_session_id_session_id_fk",+ "tableFrom": "oauth_access_token",+ "tableTo": "session",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "oauth_access_token_user_id_user_id_fk": {+ "name": "oauth_access_token_user_id_user_id_fk",+ "tableFrom": "oauth_access_token",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oauth_access_token_refresh_id_oauth_refresh_token_id_fk": {+ "name": "oauth_access_token_refresh_id_oauth_refresh_token_id_fk",+ "tableFrom": "oauth_access_token",+ "tableTo": "oauth_refresh_token",+ "columnsFrom": [+ "refresh_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "oauth_access_token_token_unique": {+ "name": "oauth_access_token_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_client": {+ "name": "oauth_client",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_secret": {+ "name": "client_secret",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_discovery_id": {+ "name": "client_discovery_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "disabled": {+ "name": "disabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "skip_consent": {+ "name": "skip_consent",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "enable_end_session": {+ "name": "enable_end_session",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "subject_type": {+ "name": "subject_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "scopes": {+ "name": "scopes",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "client_credentials_scopes": {+ "name": "client_credentials_scopes",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "uri": {+ "name": "uri",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "contacts": {+ "name": "contacts",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "tos": {+ "name": "tos",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "policy": {+ "name": "policy",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "software_id": {+ "name": "software_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "software_version": {+ "name": "software_version",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "software_statement": {+ "name": "software_statement",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "redirect_uris": {+ "name": "redirect_uris",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ },+ "post_logout_redirect_uris": {+ "name": "post_logout_redirect_uris",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "backchannel_logout_uri": {+ "name": "backchannel_logout_uri",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "backchannel_logout_session_required": {+ "name": "backchannel_logout_session_required",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "token_endpoint_auth_method": {+ "name": "token_endpoint_auth_method",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "application_type": {+ "name": "application_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "jwks": {+ "name": "jwks",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "jwks_uri": {+ "name": "jwks_uri",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "grant_types": {+ "name": "grant_types",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "response_types": {+ "name": "response_types",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "require_pkce": {+ "name": "require_pkce",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "dpop_bound_access_tokens": {+ "name": "dpop_bound_access_tokens",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "reference_id": {+ "name": "reference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "oauthClient_userId_idx": {+ "name": "oauthClient_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oauth_client_user_id_user_id_fk": {+ "name": "oauth_client_user_id_user_id_fk",+ "tableFrom": "oauth_client",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "oauth_client_client_id_unique": {+ "name": "oauth_client_client_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "client_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_client_assertion": {+ "name": "oauth_client_assertion",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_client_resource": {+ "name": "oauth_client_resource",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resource_id": {+ "name": "resource_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "oauthClientResource_clientId_resourceId_uidx": {+ "name": "oauthClientResource_clientId_resourceId_uidx",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthClientResource_clientId_idx": {+ "name": "oauthClientResource_clientId_idx",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthClientResource_resourceId_idx": {+ "name": "oauthClientResource_resourceId_idx",+ "columns": [+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oauth_client_resource_client_id_oauth_client_client_id_fk": {+ "name": "oauth_client_resource_client_id_oauth_client_client_id_fk",+ "tableFrom": "oauth_client_resource",+ "tableTo": "oauth_client",+ "columnsFrom": [+ "client_id"+ ],+ "columnsTo": [+ "client_id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oauth_client_resource_resource_id_oauth_resource_identifier_fk": {+ "name": "oauth_client_resource_resource_id_oauth_resource_identifier_fk",+ "tableFrom": "oauth_client_resource",+ "tableTo": "oauth_resource",+ "columnsFrom": [+ "resource_id"+ ],+ "columnsTo": [+ "identifier"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_consent": {+ "name": "oauth_consent",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reference_id": {+ "name": "reference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resources": {+ "name": "resources",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "requested_user_info_claims": {+ "name": "requested_user_info_claims",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "scopes": {+ "name": "scopes",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "oauthConsent_clientId_idx": {+ "name": "oauthConsent_clientId_idx",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthConsent_userId_idx": {+ "name": "oauthConsent_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oauth_consent_client_id_oauth_client_client_id_fk": {+ "name": "oauth_consent_client_id_oauth_client_client_id_fk",+ "tableFrom": "oauth_consent",+ "tableTo": "oauth_client",+ "columnsFrom": [+ "client_id"+ ],+ "columnsTo": [+ "client_id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oauth_consent_user_id_user_id_fk": {+ "name": "oauth_consent_user_id_user_id_fk",+ "tableFrom": "oauth_consent",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_refresh_token": {+ "name": "oauth_refresh_token",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "reference_id": {+ "name": "reference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "authorization_code_id": {+ "name": "authorization_code_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resources": {+ "name": "resources",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "requested_user_info_claims": {+ "name": "requested_user_info_claims",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "revoked": {+ "name": "revoked",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "rotated_at": {+ "name": "rotated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "rotation_replay_response": {+ "name": "rotation_replay_response",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "rotation_replay_expires_at": {+ "name": "rotation_replay_expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "auth_time": {+ "name": "auth_time",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "confirmation": {+ "name": "confirmation",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "scopes": {+ "name": "scopes",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "oauthRefreshToken_clientId_idx": {+ "name": "oauthRefreshToken_clientId_idx",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthRefreshToken_sessionId_idx": {+ "name": "oauthRefreshToken_sessionId_idx",+ "columns": [+ {+ "expression": "session_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthRefreshToken_userId_idx": {+ "name": "oauthRefreshToken_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthRefreshToken_authorizationCodeId_idx": {+ "name": "oauthRefreshToken_authorizationCodeId_idx",+ "columns": [+ {+ "expression": "authorization_code_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oauth_refresh_token_client_id_oauth_client_client_id_fk": {+ "name": "oauth_refresh_token_client_id_oauth_client_client_id_fk",+ "tableFrom": "oauth_refresh_token",+ "tableTo": "oauth_client",+ "columnsFrom": [+ "client_id"+ ],+ "columnsTo": [+ "client_id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oauth_refresh_token_session_id_session_id_fk": {+ "name": "oauth_refresh_token_session_id_session_id_fk",+ "tableFrom": "oauth_refresh_token",+ "tableTo": "session",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "oauth_refresh_token_user_id_user_id_fk": {+ "name": "oauth_refresh_token_user_id_user_id_fk",+ "tableFrom": "oauth_refresh_token",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "oauth_refresh_token_token_unique": {+ "name": "oauth_refresh_token_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_resource": {+ "name": "oauth_resource",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "access_token_ttl": {+ "name": "access_token_ttl",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token_ttl": {+ "name": "refresh_token_ttl",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "signing_algorithm": {+ "name": "signing_algorithm",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "signing_key_id": {+ "name": "signing_key_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "allowed_scopes": {+ "name": "allowed_scopes",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "custom_claims": {+ "name": "custom_claims",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "dpop_bound_access_tokens_required": {+ "name": "dpop_bound_access_tokens_required",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "disabled": {+ "name": "disabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "policy_version": {+ "name": "policy_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 1+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "oauth_resource_identifier_unique": {+ "name": "oauth_resource_identifier_unique",+ "nullsNotDistinct": false,+ "columns": [+ "identifier"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.passkey": {+ "name": "passkey",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "public_key": {+ "name": "public_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "credential_id": {+ "name": "credential_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "counter": {+ "name": "counter",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "device_type": {+ "name": "device_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "backed_up": {+ "name": "backed_up",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true+ },+ "transports": {+ "name": "transports",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "aaguid": {+ "name": "aaguid",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "passkey_userId_idx": {+ "name": "passkey_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "passkey_credentialID_idx": {+ "name": "passkey_credentialID_idx",+ "columns": [+ {+ "expression": "credential_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "passkey_user_id_user_id_fk": {+ "name": "passkey_user_id_user_id_fk",+ "tableFrom": "passkey",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.session": {+ "name": "session",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "ip_address": {+ "name": "ip_address",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_agent": {+ "name": "user_agent",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "session_userId_idx": {+ "name": "session_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "session_user_id_user_id_fk": {+ "name": "session_user_id_user_id_fk",+ "tableFrom": "session",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "session_token_unique": {+ "name": "session_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user": {+ "name": "user",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email_verified": {+ "name": "email_verified",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "image": {+ "name": "image",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "username": {+ "name": "username",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "display_username": {+ "name": "display_username",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'user'"+ },+ "active": {+ "name": "active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "last_seen_at": {+ "name": "last_seen_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "user_email_unique": {+ "name": "user_email_unique",+ "nullsNotDistinct": false,+ "columns": [+ "email"+ ]+ },+ "user_username_unique": {+ "name": "user_username_unique",+ "nullsNotDistinct": false,+ "columns": [+ "username"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verification": {+ "name": "verification",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "verification_identifier_idx": {+ "name": "verification_identifier_idx",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_chat_event": {+ "name": "agent_chat_event",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigserial",+ "primaryKey": true,+ "notNull": true+ },+ "message_id": {+ "name": "message_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_chat_event_message_idx": {+ "name": "agent_chat_event_message_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_chat_event_message_id_agent_chat_message_id_fk": {+ "name": "agent_chat_event_message_id_agent_chat_message_id_fk",+ "tableFrom": "agent_chat_event",+ "tableTo": "agent_chat_message",+ "columnsFrom": [+ "message_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_chat_favorite": {+ "name": "agent_chat_favorite",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "agent_chat_favorite_user_id_user_id_fk": {+ "name": "agent_chat_favorite_user_id_user_id_fk",+ "tableFrom": "agent_chat_favorite",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_chat_favorite_agent_id_ai_agent_id_fk": {+ "name": "agent_chat_favorite_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_chat_favorite",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_chat_favorite_user_id_thread_id_pk": {+ "name": "agent_chat_favorite_user_id_thread_id_pk",+ "columns": [+ "user_id",+ "thread_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_chat_message": {+ "name": "agent_chat_message",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_chat_message_thread_idx": {+ "name": "agent_chat_message_thread_idx",+ "columns": [+ {+ "expression": "thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_chat_message_due_idx": {+ "name": "agent_chat_message_due_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"agent_chat_message\".\"status\" IN ('pending', 'streaming')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_chat_message_thread_id_agent_chat_thread_id_fk": {+ "name": "agent_chat_message_thread_id_agent_chat_thread_id_fk",+ "tableFrom": "agent_chat_message",+ "tableTo": "agent_chat_thread",+ "columnsFrom": [+ "thread_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_chat_message_agent_id_ai_agent_id_fk": {+ "name": "agent_chat_message_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_chat_message",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "agent_chat_message_role_check": {+ "name": "agent_chat_message_role_check",+ "value": "\"agent_chat_message\".\"role\" IN ('user', 'assistant')"+ },+ "agent_chat_message_status_check": {+ "name": "agent_chat_message_status_check",+ "value": "\"agent_chat_message\".\"status\" IN ('pending', 'streaming', 'success', 'failed', 'canceled')"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_chat_thread": {+ "name": "agent_chat_thread",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "cli_session_id": {+ "name": "cli_session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_chat_thread_agent_user_idx": {+ "name": "agent_chat_thread_agent_user_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_chat_thread_agent_id_ai_agent_id_fk": {+ "name": "agent_chat_thread_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_chat_thread",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_chat_thread_user_id_user_id_fk": {+ "name": "agent_chat_thread_user_id_user_id_fk",+ "tableFrom": "agent_chat_thread",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_chat_usage": {+ "name": "agent_chat_usage",+ "schema": "",+ "columns": {+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "input_tokens": {+ "name": "input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "output_tokens": {+ "name": "output_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_chat_usage_agent_idx": {+ "name": "agent_chat_usage_agent_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_chat_usage_agent_id_ai_agent_id_fk": {+ "name": "agent_chat_usage_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_chat_usage",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_field_trigger": {+ "name": "agent_field_trigger",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "field_id": {+ "name": "field_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "delay_sec": {+ "name": "delay_sec",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 120+ }+ },+ "indexes": {+ "agent_field_trigger_field_idx": {+ "name": "agent_field_trigger_field_idx",+ "columns": [+ {+ "expression": "field_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_field_trigger_agent_id_ai_agent_id_fk": {+ "name": "agent_field_trigger_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_field_trigger",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_field_trigger_field_id_custom_field_id_fk": {+ "name": "agent_field_trigger_field_id_custom_field_id_fk",+ "tableFrom": "agent_field_trigger",+ "tableTo": "custom_field",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_field_trigger_agent_id_field_id_pk": {+ "name": "agent_field_trigger_agent_id_field_id_pk",+ "columns": [+ "agent_id",+ "field_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "agent_field_trigger_delay_check": {+ "name": "agent_field_trigger_delay_check",+ "value": "\"agent_field_trigger\".\"delay_sec\" >= 0 AND \"agent_field_trigger\".\"delay_sec\" <= 86400"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_run": {+ "name": "agent_run",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "schedule_id": {+ "name": "schedule_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "trigger": {+ "name": "trigger",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'delegation'"+ },+ "scheduled_for": {+ "name": "scheduled_for",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "source_activity_id": {+ "name": "source_activity_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "source_document_comment_id": {+ "name": "source_document_comment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "prompt": {+ "name": "prompt",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "output": {+ "name": "output",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "input_tokens": {+ "name": "input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "output_tokens": {+ "name": "output_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "execution_started_at": {+ "name": "execution_started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "claimed_at": {+ "name": "claimed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_run_schedule_fire_uq": {+ "name": "agent_run_schedule_fire_uq",+ "columns": [+ {+ "expression": "schedule_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scheduled_for",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_run_due_idx": {+ "name": "agent_run_due_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_run_schedule_idx": {+ "name": "agent_run_schedule_idx",+ "columns": [+ {+ "expression": "schedule_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_run_project_idx": {+ "name": "agent_run_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_run_issue_idx": {+ "name": "agent_run_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"agent_run\".\"issue_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_run_source_activity_idx": {+ "name": "agent_run_source_activity_idx",+ "columns": [+ {+ "expression": "source_activity_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"agent_run\".\"source_activity_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_run_agent_id_ai_agent_id_fk": {+ "name": "agent_run_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_run_project_id_project_id_fk": {+ "name": "agent_run_project_id_project_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_run_issue_id_issue_id_fk": {+ "name": "agent_run_issue_id_issue_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_run_schedule_id_agent_schedule_id_fk": {+ "name": "agent_run_schedule_id_agent_schedule_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "agent_schedule",+ "columnsFrom": [+ "schedule_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_run_source_activity_id_issue_activity_id_fk": {+ "name": "agent_run_source_activity_id_issue_activity_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "issue_activity",+ "columnsFrom": [+ "source_activity_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_run_document_id_project_document_id_fk": {+ "name": "agent_run_document_id_project_document_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_run_source_document_comment_id_document_comment_id_fk": {+ "name": "agent_run_source_document_comment_id_document_comment_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "document_comment",+ "columnsFrom": [+ "source_document_comment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "agent_run_status_check": {+ "name": "agent_run_status_check",+ "value": "\"agent_run\".\"status\" IN ('pending', 'success', 'failed', 'canceled')"+ },+ "agent_run_trigger_check": {+ "name": "agent_run_trigger_check",+ "value": "\"agent_run\".\"trigger\" IN ('mention', 'delegation', 'field', 'schedule', 'manual', 'status', 'event')"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_run_trace": {+ "name": "agent_run_trace",+ "schema": "",+ "columns": {+ "run_id": {+ "name": "run_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "attempt": {+ "name": "attempt",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "events": {+ "name": "events",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "next_offset": {+ "name": "next_offset",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "truncated": {+ "name": "truncated",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "agent_run_trace_run_id_agent_run_id_fk": {+ "name": "agent_run_trace_run_id_agent_run_id_fk",+ "tableFrom": "agent_run_trace",+ "tableTo": "agent_run",+ "columnsFrom": [+ "run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_run_trace_run_id_attempt_pk": {+ "name": "agent_run_trace_run_id_attempt_pk",+ "columns": [+ "run_id",+ "attempt"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_schedule": {+ "name": "agent_schedule",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prompt": {+ "name": "prompt",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'cron'"+ },+ "cron": {+ "name": "cron",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "timezone": {+ "name": "timezone",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "next_run_at": {+ "name": "next_run_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "column_id": {+ "name": "column_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "delay_sec": {+ "name": "delay_sec",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "options": {+ "name": "options",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "last_run_at": {+ "name": "last_run_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_schedule_due_idx": {+ "name": "agent_schedule_due_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_run_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_schedule_agent_idx": {+ "name": "agent_schedule_agent_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_schedule_project_idx": {+ "name": "agent_schedule_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_schedule_column_idx": {+ "name": "agent_schedule_column_idx",+ "columns": [+ {+ "expression": "column_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_schedule_agent_id_ai_agent_id_fk": {+ "name": "agent_schedule_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_schedule",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_schedule_project_id_project_id_fk": {+ "name": "agent_schedule_project_id_project_id_fk",+ "tableFrom": "agent_schedule",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_schedule_column_id_project_column_id_fk": {+ "name": "agent_schedule_column_id_project_column_id_fk",+ "tableFrom": "agent_schedule",+ "tableTo": "project_column",+ "columnsFrom": [+ "column_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "agent_schedule_project_id_agent_id_name_unique": {+ "name": "agent_schedule_project_id_agent_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "agent_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "agent_schedule_status_check": {+ "name": "agent_schedule_status_check",+ "value": "\"agent_schedule\".\"status\" IN ('active', 'paused')"+ },+ "agent_schedule_type_check": {+ "name": "agent_schedule_type_check",+ "value": "(\"agent_schedule\".\"type\" = 'cron' AND \"agent_schedule\".\"cron\" IS NOT NULL AND \"agent_schedule\".\"next_run_at\" IS NOT NULL AND \"agent_schedule\".\"column_id\" IS NULL)\n OR (\"agent_schedule\".\"type\" = 'status' AND \"agent_schedule\".\"column_id\" IS NOT NULL AND \"agent_schedule\".\"cron\" IS NULL AND \"agent_schedule\".\"next_run_at\" IS NULL)\n OR (\"agent_schedule\".\"type\" NOT IN ('cron', 'status') AND \"agent_schedule\".\"cron\" IS NULL AND \"agent_schedule\".\"next_run_at\" IS NULL AND \"agent_schedule\".\"column_id\" IS NULL)"+ },+ "agent_schedule_delay_check": {+ "name": "agent_schedule_delay_check",+ "value": "\"agent_schedule\".\"delay_sec\" >= 0 AND \"agent_schedule\".\"delay_sec\" <= 86400"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_skill": {+ "name": "agent_skill",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_url": {+ "name": "source_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "s3_prefix": {+ "name": "s3_prefix",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "files": {+ "name": "files",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_skill_team_idx": {+ "name": "agent_skill_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_skill_team_id_team_id_fk": {+ "name": "agent_skill_team_id_team_id_fk",+ "tableFrom": "agent_skill",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "agent_skill_team_id_name_unique": {+ "name": "agent_skill_team_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "team_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "agent_skill_source_check": {+ "name": "agent_skill_source_check",+ "value": "\"agent_skill\".\"source\" IN ('upload', 'inline', 'github')"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_skill_link": {+ "name": "agent_skill_link",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "skill_id": {+ "name": "skill_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "agent_skill_link_skill_idx": {+ "name": "agent_skill_link_skill_idx",+ "columns": [+ {+ "expression": "skill_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_skill_link_agent_id_ai_agent_id_fk": {+ "name": "agent_skill_link_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_skill_link",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_skill_link_skill_id_agent_skill_id_fk": {+ "name": "agent_skill_link_skill_id_agent_skill_id_fk",+ "tableFrom": "agent_skill_link",+ "tableTo": "agent_skill",+ "columnsFrom": [+ "skill_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_skill_link_agent_id_skill_id_pk": {+ "name": "agent_skill_link_agent_id_skill_id_pk",+ "columns": [+ "agent_id",+ "skill_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_tool": {+ "name": "agent_tool",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "tool_key": {+ "name": "tool_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "credential_id": {+ "name": "credential_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_tool_team_tool_keyless_uq": {+ "name": "agent_tool_team_tool_keyless_uq",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tool_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_tool\".\"credential_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_tool_team_idx": {+ "name": "agent_tool_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_tool_credential_idx": {+ "name": "agent_tool_credential_idx",+ "columns": [+ {+ "expression": "credential_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_tool_team_id_team_id_fk": {+ "name": "agent_tool_team_id_team_id_fk",+ "tableFrom": "agent_tool",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_tool_credential_id_integration_credential_id_fk": {+ "name": "agent_tool_credential_id_integration_credential_id_fk",+ "tableFrom": "agent_tool",+ "tableTo": "integration_credential",+ "columnsFrom": [+ "credential_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "agent_tool_team_id_tool_key_credential_id_unique": {+ "name": "agent_tool_team_id_tool_key_credential_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "team_id",+ "tool_key",+ "credential_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_tool_link": {+ "name": "agent_tool_link",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "agent_tool_id": {+ "name": "agent_tool_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "agent_tool_link_tool_idx": {+ "name": "agent_tool_link_tool_idx",+ "columns": [+ {+ "expression": "agent_tool_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_tool_link_agent_id_ai_agent_id_fk": {+ "name": "agent_tool_link_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_tool_link",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_tool_link_agent_tool_id_agent_tool_id_fk": {+ "name": "agent_tool_link_agent_tool_id_agent_tool_id_fk",+ "tableFrom": "agent_tool_link",+ "tableTo": "agent_tool",+ "columnsFrom": [+ "agent_tool_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_tool_link_agent_id_agent_tool_id_pk": {+ "name": "agent_tool_link_agent_id_agent_tool_id_pk",+ "columns": [+ "agent_id",+ "agent_tool_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.ai_agent": {+ "name": "ai_agent",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "username": {+ "name": "username",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "model_credential_id": {+ "name": "model_credential_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "instructions": {+ "name": "instructions",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tools": {+ "name": "tools",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "temperature": {+ "name": "temperature",+ "type": "double precision",+ "primaryKey": false,+ "notNull": false+ },+ "reasoning_effort": {+ "name": "reasoning_effort",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "max_steps": {+ "name": "max_steps",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "run_timeout_sec": {+ "name": "run_timeout_sec",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "trigger_on_mention": {+ "name": "trigger_on_mention",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "trigger_on_assign": {+ "name": "trigger_on_assign",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "chat_enabled": {+ "name": "chat_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "delegation_delay_sec": {+ "name": "delegation_delay_sec",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 120+ },+ "api_key_ciphertext": {+ "name": "api_key_ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "api_key_iv": {+ "name": "api_key_iv",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "api_key_auth_tag": {+ "name": "api_key_auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "memory_enabled": {+ "name": "memory_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "memory_last_messages": {+ "name": "memory_last_messages",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "runner_scope": {+ "name": "runner_scope",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'team'"+ },+ "last_seen_at": {+ "name": "last_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "invocation_url": {+ "name": "invocation_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "invocation_secret_ciphertext": {+ "name": "invocation_secret_ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "invocation_secret_iv": {+ "name": "invocation_secret_iv",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "invocation_secret_auth_tag": {+ "name": "invocation_secret_auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "ai_agent_team_username_uq": {+ "name": "ai_agent_team_username_uq",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "lower(\"username\")",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "ai_agent_team_idx": {+ "name": "ai_agent_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "ai_agent_team_id_team_id_fk": {+ "name": "ai_agent_team_id_team_id_fk",+ "tableFrom": "ai_agent",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "ai_agent_user_id_user_id_fk": {+ "name": "ai_agent_user_id_user_id_fk",+ "tableFrom": "ai_agent",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "ai_agent_model_credential_id_integration_credential_id_fk": {+ "name": "ai_agent_model_credential_id_integration_credential_id_fk",+ "tableFrom": "ai_agent",+ "tableTo": "integration_credential",+ "columnsFrom": [+ "model_credential_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "ai_agent_owner_user_id_user_id_fk": {+ "name": "ai_agent_owner_user_id_user_id_fk",+ "tableFrom": "ai_agent",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "ai_agent_user_id_unique": {+ "name": "ai_agent_user_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "user_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "ai_agent_kind_check": {+ "name": "ai_agent_kind_check",+ "value": "\"ai_agent\".\"kind\" IN ('external', 'internal')"+ },+ "ai_agent_runner_scope_check": {+ "name": "ai_agent_runner_scope_check",+ "value": "\"ai_agent\".\"runner_scope\" IN ('owner', 'team')"+ },+ "ai_agent_reasoning_effort_check": {+ "name": "ai_agent_reasoning_effort_check",+ "value": "\"ai_agent\".\"reasoning_effort\" IN ('low', 'medium', 'high')"+ },+ "ai_agent_delegation_delay_check": {+ "name": "ai_agent_delegation_delay_check",+ "value": "\"ai_agent\".\"delegation_delay_sec\" >= 0 AND \"ai_agent\".\"delegation_delay_sec\" <= 86400"+ }+ },+ "isRLSEnabled": false+ },+ "public.app_secret": {+ "name": "app_secret",+ "schema": "",+ "columns": {+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "ciphertext": {+ "name": "ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "iv": {+ "name": "iv",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "auth_tag": {+ "name": "auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "redacted": {+ "name": "redacted",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.app_setting": {+ "name": "app_setting",+ "schema": "",+ "columns": {+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.chat_attachment": {+ "name": "chat_attachment",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "public_id": {+ "name": "public_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "uploaded_by_user_id": {+ "name": "uploaded_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "s3_key": {+ "name": "s3_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "filename": {+ "name": "filename",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size_bytes": {+ "name": "size_bytes",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_attachment_project_idx": {+ "name": "chat_attachment_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_attachment_project_id_project_id_fk": {+ "name": "chat_attachment_project_id_project_id_fk",+ "tableFrom": "chat_attachment",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_attachment_uploaded_by_user_id_user_id_fk": {+ "name": "chat_attachment_uploaded_by_user_id_user_id_fk",+ "tableFrom": "chat_attachment",+ "tableTo": "user",+ "columnsFrom": [+ "uploaded_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "chat_attachment_public_id_unique": {+ "name": "chat_attachment_public_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "public_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.custom_field": {+ "name": "custom_field",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "issue_type_id": {+ "name": "issue_type_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "field_type": {+ "name": "field_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "member_scope": {+ "name": "member_scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "show_in_body": {+ "name": "show_in_body",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "custom_field_project_id_project_id_fk": {+ "name": "custom_field_project_id_project_id_fk",+ "tableFrom": "custom_field",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "custom_field_issue_type_id_issue_type_id_fk": {+ "name": "custom_field_issue_type_id_issue_type_id_fk",+ "tableFrom": "custom_field",+ "tableTo": "issue_type",+ "columnsFrom": [+ "issue_type_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "custom_field_field_type_check": {+ "name": "custom_field_field_type_check",+ "value": "\"custom_field\".\"field_type\" IN ('text', 'markdown', 'url', 'number', 'boolean', 'date', 'datetime', 'datetime_range', 'select', 'multi_select', 'member')"+ },+ "custom_field_member_scope_check": {+ "name": "custom_field_member_scope_check",+ "value": "(\"custom_field\".\"field_type\" = 'member') = (\"custom_field\".\"member_scope\" IS NOT NULL) AND (\"custom_field\".\"member_scope\" IS NULL OR \"custom_field\".\"member_scope\" IN ('all', 'humans', 'agents'))"+ }+ },+ "isRLSEnabled": false+ },+ "public.custom_field_option": {+ "name": "custom_field_option",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "field_id": {+ "name": "field_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ }+ },+ "indexes": {},+ "foreignKeys": {+ "custom_field_option_field_id_custom_field_id_fk": {+ "name": "custom_field_option_field_id_custom_field_id_fk",+ "tableFrom": "custom_field_option",+ "tableTo": "custom_field",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "custom_field_option_field_id_value_unique": {+ "name": "custom_field_option_field_id_value_unique",+ "nullsNotDistinct": false,+ "columns": [+ "field_id",+ "value"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.cycle": {+ "name": "cycle",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "goal": {+ "name": "goal",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "start_date": {+ "name": "start_date",+ "type": "date",+ "primaryKey": false,+ "notNull": true+ },+ "end_date": {+ "name": "end_date",+ "type": "date",+ "primaryKey": false,+ "notNull": true+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "cycle_project_idx": {+ "name": "cycle_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "start_date",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "cycle_project_id_project_id_fk": {+ "name": "cycle_project_id_project_id_fk",+ "tableFrom": "cycle",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "cycle_dates_check": {+ "name": "cycle_dates_check",+ "value": "\"cycle\".\"end_date\" >= \"cycle\".\"start_date\""+ }+ },+ "isRLSEnabled": false+ },+ "public.document_asset": {+ "name": "document_asset",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "public_id": {+ "name": "public_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "uploaded_by_user_id": {+ "name": "uploaded_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "s3_key": {+ "name": "s3_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "filename": {+ "name": "filename",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size_bytes": {+ "name": "size_bytes",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "document_asset_document_idx": {+ "name": "document_asset_document_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_asset_document_id_project_document_id_fk": {+ "name": "document_asset_document_id_project_document_id_fk",+ "tableFrom": "document_asset",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_asset_uploaded_by_user_id_user_id_fk": {+ "name": "document_asset_uploaded_by_user_id_user_id_fk",+ "tableFrom": "document_asset",+ "tableTo": "user",+ "columnsFrom": [+ "uploaded_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "document_asset_public_id_unique": {+ "name": "document_asset_public_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "public_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_collaboration": {+ "name": "document_collaboration",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true+ },+ "epoch": {+ "name": "epoch",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "content_json": {+ "name": "content_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "document_collaboration_document_id_project_document_id_fk": {+ "name": "document_collaboration_document_id_project_document_id_fk",+ "tableFrom": "document_collaboration",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_comment": {+ "name": "document_comment",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "parent_id": {+ "name": "parent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "author_id": {+ "name": "author_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "quote": {+ "name": "quote",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "selection_from": {+ "name": "selection_from",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "selection_to": {+ "name": "selection_to",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "orphaned": {+ "name": "orphaned",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "document_comment_document_idx": {+ "name": "document_comment_document_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_comment_document_id_project_document_id_fk": {+ "name": "document_comment_document_id_project_document_id_fk",+ "tableFrom": "document_comment",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_comment_parent_id_document_comment_id_fk": {+ "name": "document_comment_parent_id_document_comment_id_fk",+ "tableFrom": "document_comment",+ "tableTo": "document_comment",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_comment_author_id_user_id_fk": {+ "name": "document_comment_author_id_user_id_fk",+ "tableFrom": "document_comment",+ "tableTo": "user",+ "columnsFrom": [+ "author_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_step": {+ "name": "document_step",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "step": {+ "name": "step",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "document_step_document_id_project_document_id_fk": {+ "name": "document_step_document_id_project_document_id_fk",+ "tableFrom": "document_step",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "document_step_document_id_version_pk": {+ "name": "document_step_document_id_version_pk",+ "columns": [+ "document_id",+ "version"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.git_managed_repository": {+ "name": "git_managed_repository",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "connection_id": {+ "name": "connection_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "full_name": {+ "name": "full_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "web_url": {+ "name": "web_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "webhook_external_id": {+ "name": "webhook_external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'connected'"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "git_managed_repository_project_connection_idx": {+ "name": "git_managed_repository_project_connection_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "git_managed_repository_project_id_project_id_fk": {+ "name": "git_managed_repository_project_id_project_id_fk",+ "tableFrom": "git_managed_repository",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "git_managed_repository_connection_id_git_provider_connection_id_fk": {+ "name": "git_managed_repository_connection_id_git_provider_connection_id_fk",+ "tableFrom": "git_managed_repository",+ "tableTo": "git_provider_connection",+ "columnsFrom": [+ "connection_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "git_managed_repository_project_connection_external_unique": {+ "name": "git_managed_repository_project_connection_external_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "connection_id",+ "external_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.git_provider_connection": {+ "name": "git_provider_connection",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "base_url": {+ "name": "base_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "account_login": {+ "name": "account_login",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "ciphertext": {+ "name": "ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "iv": {+ "name": "iv",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "auth_tag": {+ "name": "auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "git_provider_connection_team_idx": {+ "name": "git_provider_connection_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "git_provider_connection_team_id_team_id_fk": {+ "name": "git_provider_connection_team_id_team_id_fk",+ "tableFrom": "git_provider_connection",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.import_job": {+ "name": "import_job",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "phase": {+ "name": "phase",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'discover'"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "cursor": {+ "name": "cursor",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "credential_ciphertext": {+ "name": "credential_ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "credential_iv": {+ "name": "credential_iv",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "credential_auth_tag": {+ "name": "credential_auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "import_job_project_idx": {+ "name": "import_job_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "import_job_due_idx": {+ "name": "import_job_due_idx",+ "columns": [+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"import_job\".\"status\" = 'pending'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "import_job_project_id_project_id_fk": {+ "name": "import_job_project_id_project_id_fk",+ "tableFrom": "import_job",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "import_job_created_by_user_id_user_id_fk": {+ "name": "import_job_created_by_user_id_user_id_fk",+ "tableFrom": "import_job",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "import_job_phase_check": {+ "name": "import_job_phase_check",+ "value": "\"import_job\".\"phase\" IN ('discover', 'create', 'link', 'rewrite', 'attachments', 'done')"+ },+ "import_job_status_check": {+ "name": "import_job_status_check",+ "value": "\"import_job\".\"status\" IN ('pending', 'running', 'paused', 'completed', 'failed')"+ }+ },+ "isRLSEnabled": false+ },+ "public.import_record": {+ "name": "import_record",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "import_job_id": {+ "name": "import_job_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "source_entity_type": {+ "name": "source_entity_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_id": {+ "name": "source_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_display_id": {+ "name": "source_display_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "local_entity_type": {+ "name": "local_entity_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "local_id": {+ "name": "local_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "import_record_job_source_uq": {+ "name": "import_record_job_source_uq",+ "columns": [+ {+ "expression": "import_job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_entity_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "import_record_job_local_idx": {+ "name": "import_record_job_local_idx",+ "columns": [+ {+ "expression": "import_job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "local_entity_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "local_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "import_record_job_display_idx": {+ "name": "import_record_job_display_idx",+ "columns": [+ {+ "expression": "import_job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_entity_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_display_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "import_record_import_job_id_import_job_id_fk": {+ "name": "import_record_import_job_id_import_job_id_fk",+ "tableFrom": "import_record",+ "tableTo": "import_job",+ "columnsFrom": [+ "import_job_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "import_record_source_entity_type_check": {+ "name": "import_record_source_entity_type_check",+ "value": "\"import_record\".\"source_entity_type\" IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment', 'checklist', 'custom_field')"+ },+ "import_record_local_entity_type_check": {+ "name": "import_record_local_entity_type_check",+ "value": "\"import_record\".\"local_entity_type\" IS NULL OR \"import_record\".\"local_entity_type\" IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment', 'checklist', 'custom_field')"+ }+ },+ "isRLSEnabled": false+ },+ "public.initiative": {+ "name": "initiative",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'planned'"+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "priority": {+ "name": "priority",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "start_date": {+ "name": "start_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "target_date": {+ "name": "target_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "initiative_project_idx": {+ "name": "initiative_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "initiative_project_id_project_id_fk": {+ "name": "initiative_project_id_project_id_fk",+ "tableFrom": "initiative",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "initiative_owner_user_id_user_id_fk": {+ "name": "initiative_owner_user_id_user_id_fk",+ "tableFrom": "initiative",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "initiative_status_check": {+ "name": "initiative_status_check",+ "value": "\"initiative\".\"status\" IN ('proposed', 'planned', 'active', 'completed', 'canceled')"+ }+ },+ "isRLSEnabled": false+ },+ "public.initiative_attachment": {+ "name": "initiative_attachment",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "public_id": {+ "name": "public_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "s3_key": {+ "name": "s3_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "filename": {+ "name": "filename",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size_bytes": {+ "name": "size_bytes",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "initiative_attachment_initiative_idx": {+ "name": "initiative_attachment_initiative_idx",+ "columns": [+ {+ "expression": "initiative_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "initiative_attachment_initiative_id_initiative_id_fk": {+ "name": "initiative_attachment_initiative_id_initiative_id_fk",+ "tableFrom": "initiative_attachment",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "initiative_attachment_public_id_unique": {+ "name": "initiative_attachment_public_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "public_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.initiative_label": {+ "name": "initiative_label",+ "schema": "",+ "columns": {+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "label_id": {+ "name": "label_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "initiative_label_initiative_id_initiative_id_fk": {+ "name": "initiative_label_initiative_id_initiative_id_fk",+ "tableFrom": "initiative_label",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "initiative_label_label_id_label_id_fk": {+ "name": "initiative_label_label_id_label_id_fk",+ "tableFrom": "initiative_label",+ "tableTo": "label",+ "columnsFrom": [+ "label_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "initiative_label_initiative_id_label_id_pk": {+ "name": "initiative_label_initiative_id_label_id_pk",+ "columns": [+ "initiative_id",+ "label_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.integration_credential": {+ "name": "integration_credential",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "integration_key": {+ "name": "integration_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "label": {+ "name": "label",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "ciphertext": {+ "name": "ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "iv": {+ "name": "iv",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "auth_tag": {+ "name": "auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "redacted": {+ "name": "redacted",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "integration_credential_team_idx": {+ "name": "integration_credential_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "integration_credential_team_id_team_id_fk": {+ "name": "integration_credential_team_id_team_id_fk",+ "tableFrom": "integration_credential",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue": {+ "name": "issue",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "sequence_number": {+ "name": "sequence_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "type_id": {+ "name": "type_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "cycle_id": {+ "name": "cycle_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "column_id": {+ "name": "column_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "parent_id": {+ "name": "parent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_user_id": {+ "name": "assignee_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "delegate_user_id": {+ "name": "delegate_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "priority": {+ "name": "priority",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "estimate_points": {+ "name": "estimate_points",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "estimate_minutes": {+ "name": "estimate_minutes",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "start_date": {+ "name": "start_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "due_date": {+ "name": "due_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "share_token": {+ "name": "share_token",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "share_extended": {+ "name": "share_extended",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "share_expires_at": {+ "name": "share_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_project_active_idx": {+ "name": "issue_project_active_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "column_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue\".\"archived_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_project_title_idx": {+ "name": "issue_project_title_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "lower(btrim(\"title\"))",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_parent_idx": {+ "name": "issue_parent_idx",+ "columns": [+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue\".\"parent_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_cycle_idx": {+ "name": "issue_cycle_idx",+ "columns": [+ {+ "expression": "cycle_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue\".\"cycle_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_initiative_idx": {+ "name": "issue_initiative_idx",+ "columns": [+ {+ "expression": "initiative_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue\".\"initiative_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_project_id_project_id_fk": {+ "name": "issue_project_id_project_id_fk",+ "tableFrom": "issue",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_type_id_issue_type_id_fk": {+ "name": "issue_type_id_issue_type_id_fk",+ "tableFrom": "issue",+ "tableTo": "issue_type",+ "columnsFrom": [+ "type_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_initiative_id_initiative_id_fk": {+ "name": "issue_initiative_id_initiative_id_fk",+ "tableFrom": "issue",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_cycle_id_cycle_id_fk": {+ "name": "issue_cycle_id_cycle_id_fk",+ "tableFrom": "issue",+ "tableTo": "cycle",+ "columnsFrom": [+ "cycle_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_column_id_project_column_id_fk": {+ "name": "issue_column_id_project_column_id_fk",+ "tableFrom": "issue",+ "tableTo": "project_column",+ "columnsFrom": [+ "column_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_parent_id_issue_id_fk": {+ "name": "issue_parent_id_issue_id_fk",+ "tableFrom": "issue",+ "tableTo": "issue",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_assignee_user_id_user_id_fk": {+ "name": "issue_assignee_user_id_user_id_fk",+ "tableFrom": "issue",+ "tableTo": "user",+ "columnsFrom": [+ "assignee_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_delegate_user_id_user_id_fk": {+ "name": "issue_delegate_user_id_user_id_fk",+ "tableFrom": "issue",+ "tableTo": "user",+ "columnsFrom": [+ "delegate_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_share_token_unique": {+ "name": "issue_share_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "share_token"+ ]+ },+ "issue_project_id_sequence_number_unique": {+ "name": "issue_project_id_sequence_number_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "sequence_number"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "issue_estimate_points_check": {+ "name": "issue_estimate_points_check",+ "value": "\"issue\".\"estimate_points\" >= 0"+ },+ "issue_estimate_minutes_check": {+ "name": "issue_estimate_minutes_check",+ "value": "\"issue\".\"estimate_minutes\" >= 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.issue_activity": {+ "name": "issue_activity",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "reply_to_id": {+ "name": "reply_to_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "actor_user_id": {+ "name": "actor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "actor_name": {+ "name": "actor_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "edited_at": {+ "name": "edited_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_activity_issue_idx": {+ "name": "issue_activity_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_activity_reply_idx": {+ "name": "issue_activity_reply_idx",+ "columns": [+ {+ "expression": "reply_to_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_activity_initiative_idx": {+ "name": "issue_activity_initiative_idx",+ "columns": [+ {+ "expression": "initiative_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_activity_issue_id_issue_id_fk": {+ "name": "issue_activity_issue_id_issue_id_fk",+ "tableFrom": "issue_activity",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_activity_initiative_id_initiative_id_fk": {+ "name": "issue_activity_initiative_id_initiative_id_fk",+ "tableFrom": "issue_activity",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_activity_reply_to_id_issue_activity_id_fk": {+ "name": "issue_activity_reply_to_id_issue_activity_id_fk",+ "tableFrom": "issue_activity",+ "tableTo": "issue_activity",+ "columnsFrom": [+ "reply_to_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_activity_actor_user_id_user_id_fk": {+ "name": "issue_activity_actor_user_id_user_id_fk",+ "tableFrom": "issue_activity",+ "tableTo": "user",+ "columnsFrom": [+ "actor_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "issue_activity_kind_check": {+ "name": "issue_activity_kind_check",+ "value": "\"issue_activity\".\"kind\" IN ('comment', 'activity')"+ },+ "issue_activity_owner_check": {+ "name": "issue_activity_owner_check",+ "value": "(\"issue_activity\".\"issue_id\" IS NOT NULL) <> (\"issue_activity\".\"initiative_id\" IS NOT NULL)"+ }+ },+ "isRLSEnabled": false+ },+ "public.issue_attachment": {+ "name": "issue_attachment",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "public_id": {+ "name": "public_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "s3_key": {+ "name": "s3_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "filename": {+ "name": "filename",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size_bytes": {+ "name": "size_bytes",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_attachment_issue_idx": {+ "name": "issue_attachment_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_attachment_issue_id_issue_id_fk": {+ "name": "issue_attachment_issue_id_issue_id_fk",+ "tableFrom": "issue_attachment",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_attachment_public_id_unique": {+ "name": "issue_attachment_public_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "public_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_checklist": {+ "name": "issue_checklist",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_checklist_issue_idx": {+ "name": "issue_checklist_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_checklist_issue_id_issue_id_fk": {+ "name": "issue_checklist_issue_id_issue_id_fk",+ "tableFrom": "issue_checklist",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_checklist_item": {+ "name": "issue_checklist_item",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "checklist_id": {+ "name": "checklist_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "done": {+ "name": "done",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_checklist_item_checklist_idx": {+ "name": "issue_checklist_item_checklist_idx",+ "columns": [+ {+ "expression": "checklist_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_checklist_item_checklist_id_issue_checklist_id_fk": {+ "name": "issue_checklist_item_checklist_id_issue_checklist_id_fk",+ "tableFrom": "issue_checklist_item",+ "tableTo": "issue_checklist",+ "columnsFrom": [+ "checklist_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_cycle": {+ "name": "issue_cycle",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "cycle_id": {+ "name": "cycle_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "entered_at": {+ "name": "entered_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "left_at": {+ "name": "left_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "issue_cycle_issue_idx": {+ "name": "issue_cycle_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "entered_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_cycle_cycle_idx": {+ "name": "issue_cycle_cycle_idx",+ "columns": [+ {+ "expression": "cycle_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_cycle_open_idx": {+ "name": "issue_cycle_open_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "cycle_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issue_cycle\".\"left_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_cycle_issue_id_issue_id_fk": {+ "name": "issue_cycle_issue_id_issue_id_fk",+ "tableFrom": "issue_cycle",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_cycle_cycle_id_cycle_id_fk": {+ "name": "issue_cycle_cycle_id_cycle_id_fk",+ "tableFrom": "issue_cycle",+ "tableTo": "cycle",+ "columnsFrom": [+ "cycle_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_development_check": {+ "name": "issue_development_check",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "development_link_id": {+ "name": "development_link_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "app_id": {+ "name": "app_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "head_sha": {+ "name": "head_sha",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_development_check_link_sha_idx": {+ "name": "issue_development_check_link_sha_idx",+ "columns": [+ {+ "expression": "development_link_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "head_sha",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_development_check_development_link_id_issue_development_link_id_fk": {+ "name": "issue_development_check_development_link_id_issue_development_link_id_fk",+ "tableFrom": "issue_development_check",+ "tableTo": "issue_development_link",+ "columnsFrom": [+ "development_link_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_development_check_development_link_id_app_id_name_unique": {+ "name": "issue_development_check_development_link_id_app_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "development_link_id",+ "app_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_development_link": {+ "name": "issue_development_link",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "repository": {+ "name": "repository",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pull_request'"+ },+ "external_key": {+ "name": "external_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "number": {+ "name": "number",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "state": {+ "name": "state",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "draft": {+ "name": "draft",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "source_branch": {+ "name": "source_branch",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "target_branch": {+ "name": "target_branch",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "head_sha": {+ "name": "head_sha",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "pipeline_status": {+ "name": "pipeline_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "pipeline_url": {+ "name": "pipeline_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_development_link_issue_idx": {+ "name": "issue_development_link_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_development_link_pr_idx": {+ "name": "issue_development_link_pr_idx",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "repository",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "number",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_development_link_sha_idx": {+ "name": "issue_development_link_sha_idx",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "repository",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "head_sha",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_development_link_issue_id_issue_id_fk": {+ "name": "issue_development_link_issue_id_issue_id_fk",+ "tableFrom": "issue_development_link",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_development_link_issue_id_provider_repository_external_key_unique": {+ "name": "issue_development_link_issue_id_provider_repository_external_key_unique",+ "nullsNotDistinct": false,+ "columns": [+ "issue_id",+ "provider",+ "repository",+ "external_key"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_field_option": {+ "name": "issue_field_option",+ "schema": "",+ "columns": {+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "field_id": {+ "name": "field_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "option_id": {+ "name": "option_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_field_option_issue_id_issue_id_fk": {+ "name": "issue_field_option_issue_id_issue_id_fk",+ "tableFrom": "issue_field_option",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_field_option_field_id_custom_field_id_fk": {+ "name": "issue_field_option_field_id_custom_field_id_fk",+ "tableFrom": "issue_field_option",+ "tableTo": "custom_field",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_field_option_option_id_custom_field_option_id_fk": {+ "name": "issue_field_option_option_id_custom_field_option_id_fk",+ "tableFrom": "issue_field_option",+ "tableTo": "custom_field_option",+ "columnsFrom": [+ "option_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_field_option_issue_id_field_id_option_id_pk": {+ "name": "issue_field_option_issue_id_field_id_option_id_pk",+ "columns": [+ "issue_id",+ "field_id",+ "option_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_field_value": {+ "name": "issue_field_value",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "field_id": {+ "name": "field_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "value_text": {+ "name": "value_text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "value_number": {+ "name": "value_number",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "value_bool": {+ "name": "value_bool",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "value_date": {+ "name": "value_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "value_datetime": {+ "name": "value_datetime",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "value_datetime_end": {+ "name": "value_datetime_end",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "value_user_id": {+ "name": "value_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_field_value_issue_id_issue_id_fk": {+ "name": "issue_field_value_issue_id_issue_id_fk",+ "tableFrom": "issue_field_value",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_field_value_field_id_custom_field_id_fk": {+ "name": "issue_field_value_field_id_custom_field_id_fk",+ "tableFrom": "issue_field_value",+ "tableTo": "custom_field",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_field_value_value_user_id_user_id_fk": {+ "name": "issue_field_value_value_user_id_user_id_fk",+ "tableFrom": "issue_field_value",+ "tableTo": "user",+ "columnsFrom": [+ "value_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_field_value_issue_id_field_id_unique": {+ "name": "issue_field_value_issue_id_field_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "issue_id",+ "field_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_import": {+ "name": "issue_import",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "public_id": {+ "name": "public_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "attachment_id": {+ "name": "attachment_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'mapped'"+ },+ "mapping": {+ "name": "mapping",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "error_text": {+ "name": "error_text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_import_project_idx": {+ "name": "issue_import_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_import_project_id_project_id_fk": {+ "name": "issue_import_project_id_project_id_fk",+ "tableFrom": "issue_import",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_import_attachment_id_chat_attachment_id_fk": {+ "name": "issue_import_attachment_id_chat_attachment_id_fk",+ "tableFrom": "issue_import",+ "tableTo": "chat_attachment",+ "columnsFrom": [+ "attachment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_import_public_id_unique": {+ "name": "issue_import_public_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "public_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_key_alias": {+ "name": "issue_key_alias",+ "schema": "",+ "columns": {+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "sequence_number": {+ "name": "sequence_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "issue_key_alias_issue_idx": {+ "name": "issue_key_alias_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_key_alias_project_id_project_id_fk": {+ "name": "issue_key_alias_project_id_project_id_fk",+ "tableFrom": "issue_key_alias",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_key_alias_issue_id_issue_id_fk": {+ "name": "issue_key_alias_issue_id_issue_id_fk",+ "tableFrom": "issue_key_alias",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_key_alias_project_id_sequence_number_pk": {+ "name": "issue_key_alias_project_id_sequence_number_pk",+ "columns": [+ "project_id",+ "sequence_number"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_label": {+ "name": "issue_label",+ "schema": "",+ "columns": {+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "label_id": {+ "name": "label_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_label_issue_id_issue_id_fk": {+ "name": "issue_label_issue_id_issue_id_fk",+ "tableFrom": "issue_label",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_label_label_id_label_id_fk": {+ "name": "issue_label_label_id_label_id_fk",+ "tableFrom": "issue_label",+ "tableTo": "label",+ "columnsFrom": [+ "label_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_label_issue_id_label_id_pk": {+ "name": "issue_label_issue_id_label_id_pk",+ "columns": [+ "issue_id",+ "label_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_link": {+ "name": "issue_link",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "source_issue_id": {+ "name": "source_issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "target_issue_id": {+ "name": "target_issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_link_pair_kind_idx": {+ "name": "issue_link_pair_kind_idx",+ "columns": [+ {+ "expression": "least(\"source_issue_id\", \"target_issue_id\")",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ },+ {+ "expression": "greatest(\"source_issue_id\", \"target_issue_id\")",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ },+ {+ "expression": "kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_link_source_idx": {+ "name": "issue_link_source_idx",+ "columns": [+ {+ "expression": "source_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_link_target_idx": {+ "name": "issue_link_target_idx",+ "columns": [+ {+ "expression": "target_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_link_source_issue_id_issue_id_fk": {+ "name": "issue_link_source_issue_id_issue_id_fk",+ "tableFrom": "issue_link",+ "tableTo": "issue",+ "columnsFrom": [+ "source_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_link_target_issue_id_issue_id_fk": {+ "name": "issue_link_target_issue_id_issue_id_fk",+ "tableFrom": "issue_link",+ "tableTo": "issue",+ "columnsFrom": [+ "target_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "issue_link_kind_check": {+ "name": "issue_link_kind_check",+ "value": "\"issue_link\".\"kind\" IN ('blocks', 'relates', 'duplicates')"+ },+ "issue_link_self_check": {+ "name": "issue_link_self_check",+ "value": "\"issue_link\".\"source_issue_id\" <> \"issue_link\".\"target_issue_id\""+ }+ },+ "isRLSEnabled": false+ },+ "public.issue_status": {+ "name": "issue_status",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "column_id": {+ "name": "column_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "column_name": {+ "name": "column_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "state_type": {+ "name": "state_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "entered_at": {+ "name": "entered_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "left_at": {+ "name": "left_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "issue_status_issue_idx": {+ "name": "issue_status_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "entered_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_status_column_idx": {+ "name": "issue_status_column_idx",+ "columns": [+ {+ "expression": "column_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue_status\".\"column_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_status_open_idx": {+ "name": "issue_status_open_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issue_status\".\"left_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_status_issue_id_issue_id_fk": {+ "name": "issue_status_issue_id_issue_id_fk",+ "tableFrom": "issue_status",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_status_column_id_project_column_id_fk": {+ "name": "issue_status_column_id_project_column_id_fk",+ "tableFrom": "issue_status",+ "tableTo": "project_column",+ "columnsFrom": [+ "column_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_template": {+ "name": "issue_template",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "title_template": {+ "name": "title_template",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "description_template": {+ "name": "description_template",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "type_id": {+ "name": "type_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "column_id": {+ "name": "column_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "priority": {+ "name": "priority",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_user_id": {+ "name": "assignee_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_template_project_id_project_id_fk": {+ "name": "issue_template_project_id_project_id_fk",+ "tableFrom": "issue_template",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_template_type_id_issue_type_id_fk": {+ "name": "issue_template_type_id_issue_type_id_fk",+ "tableFrom": "issue_template",+ "tableTo": "issue_type",+ "columnsFrom": [+ "type_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_template_column_id_project_column_id_fk": {+ "name": "issue_template_column_id_project_column_id_fk",+ "tableFrom": "issue_template",+ "tableTo": "project_column",+ "columnsFrom": [+ "column_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_template_assignee_user_id_user_id_fk": {+ "name": "issue_template_assignee_user_id_user_id_fk",+ "tableFrom": "issue_template",+ "tableTo": "user",+ "columnsFrom": [+ "assignee_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_template_project_id_name_unique": {+ "name": "issue_template_project_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_template_label": {+ "name": "issue_template_label",+ "schema": "",+ "columns": {+ "template_id": {+ "name": "template_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "label_id": {+ "name": "label_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_template_label_template_id_issue_template_id_fk": {+ "name": "issue_template_label_template_id_issue_template_id_fk",+ "tableFrom": "issue_template_label",+ "tableTo": "issue_template",+ "columnsFrom": [+ "template_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_template_label_label_id_label_id_fk": {+ "name": "issue_template_label_label_id_label_id_fk",+ "tableFrom": "issue_template_label",+ "tableTo": "label",+ "columnsFrom": [+ "label_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_template_label_template_id_label_id_pk": {+ "name": "issue_template_label_template_id_label_id_pk",+ "columns": [+ "template_id",+ "label_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_type": {+ "name": "issue_type",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "is_default": {+ "name": "is_default",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_type_project_id_project_id_fk": {+ "name": "issue_type_project_id_project_id_fk",+ "tableFrom": "issue_type",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_type_project_id_name_unique": {+ "name": "issue_type_project_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_watcher": {+ "name": "issue_watcher",+ "schema": "",+ "columns": {+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "subscribed": {+ "name": "subscribed",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_watcher_issue_id_issue_id_fk": {+ "name": "issue_watcher_issue_id_issue_id_fk",+ "tableFrom": "issue_watcher",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_watcher_user_id_user_id_fk": {+ "name": "issue_watcher_user_id_user_id_fk",+ "tableFrom": "issue_watcher",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_watcher_issue_id_user_id_pk": {+ "name": "issue_watcher_issue_id_user_id_pk",+ "columns": [+ "issue_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_worklog": {+ "name": "issue_worklog",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "minutes": {+ "name": "minutes",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "spent_on": {+ "name": "spent_on",+ "type": "date",+ "primaryKey": false,+ "notNull": true+ },+ "note": {+ "name": "note",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_worklog_issue_idx": {+ "name": "issue_worklog_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "spent_on",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_worklog_issue_id_issue_id_fk": {+ "name": "issue_worklog_issue_id_issue_id_fk",+ "tableFrom": "issue_worklog",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_worklog_user_id_user_id_fk": {+ "name": "issue_worklog_user_id_user_id_fk",+ "tableFrom": "issue_worklog",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "issue_worklog_minutes_check": {+ "name": "issue_worklog_minutes_check",+ "value": "\"issue_worklog\".\"minutes\" > 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.label": {+ "name": "label",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "group_id": {+ "name": "group_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "label_project_id_project_id_fk": {+ "name": "label_project_id_project_id_fk",+ "tableFrom": "label",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "label_group_id_label_group_id_fk": {+ "name": "label_group_id_label_group_id_fk",+ "tableFrom": "label",+ "tableTo": "label_group",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "label_project_id_name_unique": {+ "name": "label_project_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.label_group": {+ "name": "label_group",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "label_group_project_id_project_id_fk": {+ "name": "label_group_project_id_project_id_fk",+ "tableFrom": "label_group",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "label_group_project_id_name_unique": {+ "name": "label_group_project_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.model_price": {+ "name": "model_price",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "input": {+ "name": "input",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true+ },+ "output": {+ "name": "output",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true+ },+ "cache_read": {+ "name": "cache_read",+ "type": "double precision",+ "primaryKey": false,+ "notNull": false+ },+ "cache_write": {+ "name": "cache_write",+ "type": "double precision",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "model_price_workspace_id_workspace_id_fk": {+ "name": "model_price_workspace_id_workspace_id_fk",+ "tableFrom": "model_price",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "model_price_workspace_id_provider_model_unique": {+ "name": "model_price_workspace_id_provider_model_unique",+ "nullsNotDistinct": false,+ "columns": [+ "workspace_id",+ "provider",+ "model"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "model_price_rates_check": {+ "name": "model_price_rates_check",+ "value": "\"model_price\".\"input\" >= 0 AND \"model_price\".\"output\" >= 0 AND coalesce(\"model_price\".\"cache_read\", 0) >= 0 AND coalesce(\"model_price\".\"cache_write\", 0) >= 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.note_board": {+ "name": "note_board",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "canvas": {+ "name": "canvas",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "note_board_project_idx": {+ "name": "note_board_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "note_board_project_id_project_id_fk": {+ "name": "note_board_project_id_project_id_fk",+ "tableFrom": "note_board",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "note_board_owner_user_id_user_id_fk": {+ "name": "note_board_owner_user_id_user_id_fk",+ "tableFrom": "note_board",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "note_board_created_by_user_id_user_id_fk": {+ "name": "note_board_created_by_user_id_user_id_fk",+ "tableFrom": "note_board",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.note_board_member": {+ "name": "note_board_member",+ "schema": "",+ "columns": {+ "board_id": {+ "name": "board_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "note_board_member_user_idx": {+ "name": "note_board_member_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "note_board_member_board_id_note_board_id_fk": {+ "name": "note_board_member_board_id_note_board_id_fk",+ "tableFrom": "note_board_member",+ "tableTo": "note_board",+ "columnsFrom": [+ "board_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "note_board_member_user_id_user_id_fk": {+ "name": "note_board_member_user_id_user_id_fk",+ "tableFrom": "note_board_member",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "note_board_member_board_id_user_id_pk": {+ "name": "note_board_member_board_id_user_id_pk",+ "columns": [+ "board_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.notification": {+ "name": "notification",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "source_activity_id": {+ "name": "source_activity_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "document_comment_id": {+ "name": "document_comment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_user_id": {+ "name": "actor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "actor_name": {+ "name": "actor_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "read_at": {+ "name": "read_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "snoozed_until": {+ "name": "snoozed_until",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "notification_user_idx": {+ "name": "notification_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "notification_user_unread_idx": {+ "name": "notification_user_unread_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notification\".\"read_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "notification_issue_idx": {+ "name": "notification_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notification\".\"issue_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "notification_source_activity_idx": {+ "name": "notification_source_activity_idx",+ "columns": [+ {+ "expression": "source_activity_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notification\".\"source_activity_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "notification_user_id_user_id_fk": {+ "name": "notification_user_id_user_id_fk",+ "tableFrom": "notification",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notification_project_id_project_id_fk": {+ "name": "notification_project_id_project_id_fk",+ "tableFrom": "notification",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notification_issue_id_issue_id_fk": {+ "name": "notification_issue_id_issue_id_fk",+ "tableFrom": "notification",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notification_source_activity_id_issue_activity_id_fk": {+ "name": "notification_source_activity_id_issue_activity_id_fk",+ "tableFrom": "notification",+ "tableTo": "issue_activity",+ "columnsFrom": [+ "source_activity_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "notification_document_id_project_document_id_fk": {+ "name": "notification_document_id_project_document_id_fk",+ "tableFrom": "notification",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notification_document_comment_id_document_comment_id_fk": {+ "name": "notification_document_comment_id_document_comment_id_fk",+ "tableFrom": "notification",+ "tableTo": "document_comment",+ "columnsFrom": [+ "document_comment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "notification_actor_user_id_user_id_fk": {+ "name": "notification_actor_user_id_user_id_fk",+ "tableFrom": "notification",+ "tableTo": "user",+ "columnsFrom": [+ "actor_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "notification_type_check": {+ "name": "notification_type_check",+ "value": "\"notification\".\"type\" IN ('assigned', 'mentioned', 'commented', 'state_changed')"+ },+ "notification_target_check": {+ "name": "notification_target_check",+ "value": "(\"notification\".\"issue_id\" IS NULL) <> (\"notification\".\"document_id\" IS NULL)"+ }+ },+ "isRLSEnabled": false+ },+ "public.notification_delivery": {+ "name": "notification_delivery",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "channel": {+ "name": "channel",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "recipient": {+ "name": "recipient",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "notification_delivery_due_idx": {+ "name": "notification_delivery_due_idx",+ "columns": [+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notification_delivery\".\"status\" = 'pending'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "notification_delivery_project_id_project_id_fk": {+ "name": "notification_delivery_project_id_project_id_fk",+ "tableFrom": "notification_delivery",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "notification_delivery_channel_check": {+ "name": "notification_delivery_channel_check",+ "value": "\"notification_delivery\".\"channel\" IN ('email', 'telegram')"+ }+ },+ "isRLSEnabled": false+ },+ "public.project": {+ "name": "project",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "next_sequence": {+ "name": "next_sequence",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "mcp_enabled": {+ "name": "mcp_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "initiatives_enabled": {+ "name": "initiatives_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "dashboards_enabled": {+ "name": "dashboards_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "documents_enabled": {+ "name": "documents_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "notes_enabled": {+ "name": "notes_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "cycles_enabled": {+ "name": "cycles_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "subtasks_enabled": {+ "name": "subtasks_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "checklists_enabled": {+ "name": "checklists_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "issue_stats_enabled": {+ "name": "issue_stats_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "points_estimate_enabled": {+ "name": "points_estimate_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "time_estimate_enabled": {+ "name": "time_estimate_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "time_logging_enabled": {+ "name": "time_logging_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_team_id_team_id_fk": {+ "name": "project_team_id_team_id_fk",+ "tableFrom": "project",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "project_team_key_uq": {+ "name": "project_team_key_uq",+ "nullsNotDistinct": false,+ "columns": [+ "team_id",+ "key"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_action": {+ "name": "project_action",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "condition": {+ "name": "condition",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "effect": {+ "name": "effect",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_action_project_idx": {+ "name": "project_action_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_action_project_id_project_id_fk": {+ "name": "project_action_project_id_project_id_fk",+ "tableFrom": "project_action",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_column": {+ "name": "project_column",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "state_type": {+ "name": "state_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'unstarted'"+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "wip_limit": {+ "name": "wip_limit",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "wip_mode": {+ "name": "wip_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'soft'"+ },+ "auto_assign_user_id": {+ "name": "auto_assign_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_column_project_id_project_id_fk": {+ "name": "project_column_project_id_project_id_fk",+ "tableFrom": "project_column",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_column_auto_assign_user_id_user_id_fk": {+ "name": "project_column_auto_assign_user_id_user_id_fk",+ "tableFrom": "project_column",+ "tableTo": "user",+ "columnsFrom": [+ "auto_assign_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "project_column_project_id_position_unique": {+ "name": "project_column_project_id_position_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "position"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "project_column_state_type_check": {+ "name": "project_column_state_type_check",+ "value": "\"project_column\".\"state_type\" IN ('backlog', 'unstarted', 'started', 'completed', 'canceled')"+ },+ "project_column_wip_mode_check": {+ "name": "project_column_wip_mode_check",+ "value": "\"project_column\".\"wip_mode\" IN ('soft', 'hard')"+ },+ "project_column_wip_limit_check": {+ "name": "project_column_wip_limit_check",+ "value": "\"project_column\".\"wip_limit\" IS NULL OR \"project_column\".\"wip_limit\" > 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.project_dashboard": {+ "name": "project_dashboard",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "layout": {+ "name": "layout",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_dashboard_project_idx": {+ "name": "project_dashboard_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_dashboard_project_id_project_id_fk": {+ "name": "project_dashboard_project_id_project_id_fk",+ "tableFrom": "project_dashboard",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_document": {+ "name": "project_document",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "parent_id": {+ "name": "parent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "content_json": {+ "name": "content_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "full_width": {+ "name": "full_width",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_private": {+ "name": "is_private",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_locked": {+ "name": "is_locked",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "archived_by_ancestor_id": {+ "name": "archived_by_ancestor_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by_user_id": {+ "name": "updated_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_document_project_tree_idx": {+ "name": "project_document_project_tree_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_document_owner_idx": {+ "name": "project_document_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_document_project_archive_idx": {+ "name": "project_document_project_archive_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "archived_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_document_project_id_project_id_fk": {+ "name": "project_document_project_id_project_id_fk",+ "tableFrom": "project_document",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_parent_id_project_document_id_fk": {+ "name": "project_document_parent_id_project_document_id_fk",+ "tableFrom": "project_document",+ "tableTo": "project_document",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_document_archived_by_ancestor_id_project_document_id_fk": {+ "name": "project_document_archived_by_ancestor_id_project_document_id_fk",+ "tableFrom": "project_document",+ "tableTo": "project_document",+ "columnsFrom": [+ "archived_by_ancestor_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_document_owner_user_id_user_id_fk": {+ "name": "project_document_owner_user_id_user_id_fk",+ "tableFrom": "project_document",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_document_created_by_user_id_user_id_fk": {+ "name": "project_document_created_by_user_id_user_id_fk",+ "tableFrom": "project_document",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_document_updated_by_user_id_user_id_fk": {+ "name": "project_document_updated_by_user_id_user_id_fk",+ "tableFrom": "project_document",+ "tableTo": "user",+ "columnsFrom": [+ "updated_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "project_document_version_check": {+ "name": "project_document_version_check",+ "value": "\"project_document\".\"version\" > 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.project_document_initiative": {+ "name": "project_document_initiative",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_document_initiative_initiative_idx": {+ "name": "project_document_initiative_initiative_idx",+ "columns": [+ {+ "expression": "initiative_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_document_initiative_document_id_project_document_id_fk": {+ "name": "project_document_initiative_document_id_project_document_id_fk",+ "tableFrom": "project_document_initiative",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_initiative_initiative_id_initiative_id_fk": {+ "name": "project_document_initiative_initiative_id_initiative_id_fk",+ "tableFrom": "project_document_initiative",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_initiative_created_by_user_id_user_id_fk": {+ "name": "project_document_initiative_created_by_user_id_user_id_fk",+ "tableFrom": "project_document_initiative",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_document_initiative_document_id_initiative_id_pk": {+ "name": "project_document_initiative_document_id_initiative_id_pk",+ "columns": [+ "document_id",+ "initiative_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_document_issue": {+ "name": "project_document_issue",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_document_issue_issue_idx": {+ "name": "project_document_issue_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_document_issue_document_id_project_document_id_fk": {+ "name": "project_document_issue_document_id_project_document_id_fk",+ "tableFrom": "project_document_issue",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_issue_issue_id_issue_id_fk": {+ "name": "project_document_issue_issue_id_issue_id_fk",+ "tableFrom": "project_document_issue",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_issue_created_by_user_id_user_id_fk": {+ "name": "project_document_issue_created_by_user_id_user_id_fk",+ "tableFrom": "project_document_issue",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_document_issue_document_id_issue_id_pk": {+ "name": "project_document_issue_document_id_issue_id_pk",+ "columns": [+ "document_id",+ "issue_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_document_preference": {+ "name": "project_document_preference",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "is_favorite": {+ "name": "is_favorite",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_document_preference_user_idx": {+ "name": "project_document_preference_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_document_preference_document_id_project_document_id_fk": {+ "name": "project_document_preference_document_id_project_document_id_fk",+ "tableFrom": "project_document_preference",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_preference_user_id_user_id_fk": {+ "name": "project_document_preference_user_id_user_id_fk",+ "tableFrom": "project_document_preference",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_document_preference_document_id_user_id_pk": {+ "name": "project_document_preference_document_id_user_id_pk",+ "columns": [+ "document_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_document_revision": {+ "name": "project_document_revision",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "parent_id": {+ "name": "parent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_json": {+ "name": "content_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "full_width": {+ "name": "full_width",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_private": {+ "name": "is_private",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_locked": {+ "name": "is_locked",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_document_revision_document_idx": {+ "name": "project_document_revision_document_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "version",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_document_revision_document_id_project_document_id_fk": {+ "name": "project_document_revision_document_id_project_document_id_fk",+ "tableFrom": "project_document_revision",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_revision_owner_user_id_user_id_fk": {+ "name": "project_document_revision_owner_user_id_user_id_fk",+ "tableFrom": "project_document_revision",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_document_revision_created_by_user_id_user_id_fk": {+ "name": "project_document_revision_created_by_user_id_user_id_fk",+ "tableFrom": "project_document_revision",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "project_document_revision_document_version_unique": {+ "name": "project_document_revision_document_version_unique",+ "nullsNotDistinct": false,+ "columns": [+ "document_id",+ "version"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_member": {+ "name": "project_member",+ "schema": "",+ "columns": {+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "role_id": {+ "name": "role_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'invite'"+ },+ "is_favorite": {+ "name": "is_favorite",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_hidden": {+ "name": "is_hidden",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_member_user_idx": {+ "name": "project_member_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_member_project_id_project_id_fk": {+ "name": "project_member_project_id_project_id_fk",+ "tableFrom": "project_member",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_member_user_id_user_id_fk": {+ "name": "project_member_user_id_user_id_fk",+ "tableFrom": "project_member",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_member_role_id_team_role_id_fk": {+ "name": "project_member_role_id_team_role_id_fk",+ "tableFrom": "project_member",+ "tableTo": "team_role",+ "columnsFrom": [+ "role_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_member_project_id_user_id_pk": {+ "name": "project_member_project_id_user_id_pk",+ "columns": [+ "project_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "project_member_role_check": {+ "name": "project_member_role_check",+ "value": "\"project_member\".\"role\" IN ('owner', 'member')"+ },+ "project_member_source_check": {+ "name": "project_member_source_check",+ "value": "\"project_member\".\"source\" IN ('invite', 'scim')"+ }+ },+ "isRLSEnabled": false+ },+ "public.project_setting": {+ "name": "project_setting",+ "schema": "",+ "columns": {+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_setting_project_id_project_id_fk": {+ "name": "project_setting_project_id_project_id_fk",+ "tableFrom": "project_setting",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_setting_project_id_key_pk": {+ "name": "project_setting_project_id_key_pk",+ "columns": [+ "project_id",+ "key"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_template": {+ "name": "project_template",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "snapshot": {+ "name": "snapshot",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "all_teams": {+ "name": "all_teams",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_template_workspace_idx": {+ "name": "project_template_workspace_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_template_workspace_id_workspace_id_fk": {+ "name": "project_template_workspace_id_workspace_id_fk",+ "tableFrom": "project_template",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_template_team": {+ "name": "project_template_team",+ "schema": "",+ "columns": {+ "template_id": {+ "name": "template_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "project_template_team_team_idx": {+ "name": "project_template_team_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_template_team_template_id_project_template_id_fk": {+ "name": "project_template_team_template_id_project_template_id_fk",+ "tableFrom": "project_template_team",+ "tableTo": "project_template",+ "columnsFrom": [+ "template_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_template_team_team_id_team_id_fk": {+ "name": "project_template_team_team_id_team_id_fk",+ "tableFrom": "project_template_team",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_template_team_template_id_team_id_pk": {+ "name": "project_template_team_template_id_team_id_pk",+ "columns": [+ "template_id",+ "team_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_view": {+ "name": "project_view",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "filters": {+ "name": "filters",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "display": {+ "name": "display",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "share_token": {+ "name": "share_token",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "share_extended": {+ "name": "share_extended",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "share_expires_at": {+ "name": "share_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_private": {+ "name": "is_private",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_view_project_idx": {+ "name": "project_view_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_view_owner_idx": {+ "name": "project_view_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_view_project_id_project_id_fk": {+ "name": "project_view_project_id_project_id_fk",+ "tableFrom": "project_view",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_view_owner_user_id_user_id_fk": {+ "name": "project_view_owner_user_id_user_id_fk",+ "tableFrom": "project_view",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "project_view_share_token_unique": {+ "name": "project_view_share_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "share_token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "project_view_private_owner_check": {+ "name": "project_view_private_owner_check",+ "value": "\"project_view\".\"is_private\" = (\"project_view\".\"owner_user_id\" is not null)"+ }+ },+ "isRLSEnabled": false+ },+ "public.project_view_favorite": {+ "name": "project_view_favorite",+ "schema": "",+ "columns": {+ "view_id": {+ "name": "view_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_view_favorite_view_id_project_view_id_fk": {+ "name": "project_view_favorite_view_id_project_view_id_fk",+ "tableFrom": "project_view_favorite",+ "tableTo": "project_view",+ "columnsFrom": [+ "view_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_view_favorite_user_id_user_id_fk": {+ "name": "project_view_favorite_user_id_user_id_fk",+ "tableFrom": "project_view_favorite",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_view_favorite_view_id_user_id_pk": {+ "name": "project_view_favorite_view_id_user_id_pk",+ "columns": [+ "view_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_view_preference": {+ "name": "project_view_preference",+ "schema": "",+ "columns": {+ "view_id": {+ "name": "view_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "is_hidden": {+ "name": "is_hidden",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_view_preference_view_id_project_view_id_fk": {+ "name": "project_view_preference_view_id_project_view_id_fk",+ "tableFrom": "project_view_preference",+ "tableTo": "project_view",+ "columnsFrom": [+ "view_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_view_preference_user_id_user_id_fk": {+ "name": "project_view_preference_user_id_user_id_fk",+ "tableFrom": "project_view_preference",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_view_preference_view_id_user_id_pk": {+ "name": "project_view_preference_view_id_user_id_pk",+ "columns": [+ "view_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.revision": {+ "name": "revision",+ "schema": "",+ "columns": {+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "rev": {+ "name": "rev",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ }+ },+ "indexes": {+ "revision_project_idx": {+ "name": "revision_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.team": {+ "name": "team",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "slug": {+ "name": "slug",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "mcp_enabled": {+ "name": "mcp_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "default_agent_ids": {+ "name": "default_agent_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "team_workspace_idx": {+ "name": "team_workspace_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "team_workspace_id_workspace_id_fk": {+ "name": "team_workspace_id_workspace_id_fk",+ "tableFrom": "team",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "team_slug_unique": {+ "name": "team_slug_unique",+ "nullsNotDistinct": false,+ "columns": [+ "slug"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.team_invite": {+ "name": "team_invite",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "team_role": {+ "name": "team_role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "project_role": {+ "name": "project_role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "role_id": {+ "name": "role_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "invited_by_user_id": {+ "name": "invited_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accepted_by_user_id": {+ "name": "accepted_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "responded_at": {+ "name": "responded_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "team_invite_team_pending_uq": {+ "name": "team_invite_team_pending_uq",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "email",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"team_invite\".\"status\" = 'pending' AND \"team_invite\".\"project_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "team_invite_project_pending_uq": {+ "name": "team_invite_project_pending_uq",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "email",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"team_invite\".\"status\" = 'pending' AND \"team_invite\".\"project_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "team_invite_team_idx": {+ "name": "team_invite_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "team_invite_project_idx": {+ "name": "team_invite_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "team_invite_team_id_team_id_fk": {+ "name": "team_invite_team_id_team_id_fk",+ "tableFrom": "team_invite",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "team_invite_project_id_project_id_fk": {+ "name": "team_invite_project_id_project_id_fk",+ "tableFrom": "team_invite",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "team_invite_role_id_team_role_id_fk": {+ "name": "team_invite_role_id_team_role_id_fk",+ "tableFrom": "team_invite",+ "tableTo": "team_role",+ "columnsFrom": [+ "role_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "team_invite_invited_by_user_id_user_id_fk": {+ "name": "team_invite_invited_by_user_id_user_id_fk",+ "tableFrom": "team_invite",+ "tableTo": "user",+ "columnsFrom": [+ "invited_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "team_invite_accepted_by_user_id_user_id_fk": {+ "name": "team_invite_accepted_by_user_id_user_id_fk",+ "tableFrom": "team_invite",+ "tableTo": "user",+ "columnsFrom": [+ "accepted_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "team_invite_token_unique": {+ "name": "team_invite_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "team_invite_team_role_check": {+ "name": "team_invite_team_role_check",+ "value": "\"team_invite\".\"team_role\" IN ('owner', 'manager', 'member')"+ },+ "team_invite_project_role_check": {+ "name": "team_invite_project_role_check",+ "value": "(\"team_invite\".\"project_id\" IS NULL AND \"team_invite\".\"project_role\" IS NULL)\n OR (\"team_invite\".\"project_id\" IS NOT NULL AND \"team_invite\".\"project_role\" IN ('owner', 'member'))"+ },+ "team_invite_status_check": {+ "name": "team_invite_status_check",+ "value": "\"team_invite\".\"status\" IN ('pending', 'accepted', 'rejected')"+ }+ },+ "isRLSEnabled": false+ },+ "public.team_member": {+ "name": "team_member",+ "schema": "",+ "columns": {+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'invite'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "team_member_user_idx": {+ "name": "team_member_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "team_member_team_id_team_id_fk": {+ "name": "team_member_team_id_team_id_fk",+ "tableFrom": "team_member",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "team_member_user_id_user_id_fk": {+ "name": "team_member_user_id_user_id_fk",+ "tableFrom": "team_member",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "team_member_team_id_user_id_pk": {+ "name": "team_member_team_id_user_id_pk",+ "columns": [+ "team_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "team_member_role_check": {+ "name": "team_member_role_check",+ "value": "\"team_member\".\"role\" IN ('owner', 'manager', 'member', 'agent')"+ },+ "team_member_source_check": {+ "name": "team_member_source_check",+ "value": "\"team_member\".\"source\" IN ('invite', 'scim')"+ }+ },+ "isRLSEnabled": false+ },+ "public.team_notification_setting": {+ "name": "team_notification_setting",+ "schema": "",+ "columns": {+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true+ },+ "ciphertext": {+ "name": "ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "iv": {+ "name": "iv",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "auth_tag": {+ "name": "auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "redacted": {+ "name": "redacted",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "team_notification_setting_team_id_team_id_fk": {+ "name": "team_notification_setting_team_id_team_id_fk",+ "tableFrom": "team_notification_setting",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.team_role": {+ "name": "team_role",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "is_default": {+ "name": "is_default",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "permissions": {+ "name": "permissions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "team_role_system_name_uq": {+ "name": "team_role_system_name_uq",+ "columns": [+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"team_role\".\"team_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "team_role_system_default_uq": {+ "name": "team_role_system_default_uq",+ "columns": [+ {+ "expression": "is_default",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"team_role\".\"team_id\" IS NULL AND \"team_role\".\"is_default\"",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "team_role_team_idx": {+ "name": "team_role_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "team_role_team_id_team_id_fk": {+ "name": "team_role_team_id_team_id_fk",+ "tableFrom": "team_role",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "team_role_team_id_name_unique": {+ "name": "team_role_team_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "team_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "team_role_default_system_check": {+ "name": "team_role_default_system_check",+ "value": "\"team_role\".\"team_id\" IS NULL OR NOT \"team_role\".\"is_default\""+ }+ },+ "isRLSEnabled": false+ },+ "public.user_notification_preference": {+ "name": "user_notification_preference",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "email_events": {+ "name": "email_events",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "telegram_events": {+ "name": "telegram_events",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "user_notification_preference_user_id_user_id_fk": {+ "name": "user_notification_preference_user_id_user_id_fk",+ "tableFrom": "user_notification_preference",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_notification_preference_project_id_project_id_fk": {+ "name": "user_notification_preference_project_id_project_id_fk",+ "tableFrom": "user_notification_preference",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "user_notification_pref_user_project_unique": {+ "name": "user_notification_pref_user_project_unique",+ "nullsNotDistinct": false,+ "columns": [+ "user_id",+ "project_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_preference": {+ "name": "user_preference",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "timezone": {+ "name": "timezone",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'UTC'"+ },+ "locale": {+ "name": "locale",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'en'"+ },+ "theme": {+ "name": "theme",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'system'"+ },+ "issue_open_mode": {+ "name": "issue_open_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'panel'"+ },+ "start_page": {+ "name": "start_page",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'work-items'"+ },+ "show_chat_by_default": {+ "name": "show_chat_by_default",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "issue_stats_open": {+ "name": "issue_stats_open",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "issue_stats_view": {+ "name": "issue_stats_view",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'compact'"+ },+ "issue_activity_view": {+ "name": "issue_activity_view",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'flat'"+ },+ "auto_watch": {+ "name": "auto_watch",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "hotkeys": {+ "name": "hotkeys",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "last_project_id": {+ "name": "last_project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "seen_version": {+ "name": "seen_version",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "user_preference_user_id_user_id_fk": {+ "name": "user_preference_user_id_user_id_fk",+ "tableFrom": "user_preference",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_preference_last_project_id_project_id_fk": {+ "name": "user_preference_last_project_id_project_id_fk",+ "tableFrom": "user_preference",+ "tableTo": "project",+ "columnsFrom": [+ "last_project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "user_preference_theme_check": {+ "name": "user_preference_theme_check",+ "value": "\"user_preference\".\"theme\" IN ('light', 'dark', 'system')"+ },+ "user_preference_issue_open_mode_check": {+ "name": "user_preference_issue_open_mode_check",+ "value": "\"user_preference\".\"issue_open_mode\" IN ('panel', 'page')"+ },+ "user_preference_start_page_check": {+ "name": "user_preference_start_page_check",+ "value": "\"user_preference\".\"start_page\" IN ('inbox', 'dashboard', 'work-items', 'initiatives')"+ },+ "user_preference_issue_stats_view_check": {+ "name": "user_preference_issue_stats_view_check",+ "value": "\"user_preference\".\"issue_stats_view\" IN ('compact', 'timeline')"+ },+ "user_preference_issue_activity_view_check": {+ "name": "user_preference_issue_activity_view_check",+ "value": "\"user_preference\".\"issue_activity_view\" IN ('flat', 'grouped')"+ }+ },+ "isRLSEnabled": false+ },+ "public.user_telegram_account": {+ "name": "user_telegram_account",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "chat_id": {+ "name": "chat_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "username": {+ "name": "username",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "first_name": {+ "name": "first_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "link_code": {+ "name": "link_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "link_code_expires_at": {+ "name": "link_code_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "linked_at": {+ "name": "linked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_telegram_account_chat_id_unique": {+ "name": "user_telegram_account_chat_id_unique",+ "columns": [+ {+ "expression": "chat_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"user_telegram_account\".\"chat_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_telegram_account_link_code_unique": {+ "name": "user_telegram_account_link_code_unique",+ "columns": [+ {+ "expression": "link_code",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"user_telegram_account\".\"link_code\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_telegram_account_user_id_user_id_fk": {+ "name": "user_telegram_account_user_id_user_id_fk",+ "tableFrom": "user_telegram_account",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.webhook": {+ "name": "webhook",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "secret": {+ "name": "secret",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "events": {+ "name": "events",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "is_active": {+ "name": "is_active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "consecutive_failures": {+ "name": "consecutive_failures",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "webhook_project_idx": {+ "name": "webhook_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "webhook_project_id_project_id_fk": {+ "name": "webhook_project_id_project_id_fk",+ "tableFrom": "webhook",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.webhook_delivery": {+ "name": "webhook_delivery",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "webhook_id": {+ "name": "webhook_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "event_id": {+ "name": "event_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "event_type": {+ "name": "event_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "response_status": {+ "name": "response_status",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "response_body": {+ "name": "response_body",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "webhook_delivery_due_idx": {+ "name": "webhook_delivery_due_idx",+ "columns": [+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"webhook_delivery\".\"status\" = 'pending'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "webhook_delivery_webhook_idx": {+ "name": "webhook_delivery_webhook_idx",+ "columns": [+ {+ "expression": "webhook_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "webhook_delivery_webhook_id_webhook_id_fk": {+ "name": "webhook_delivery_webhook_id_webhook_id_fk",+ "tableFrom": "webhook_delivery",+ "tableTo": "webhook",+ "columnsFrom": [+ "webhook_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.workspace": {+ "name": "workspace",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "team_creation": {+ "name": "team_creation",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'owner'"+ },+ "max_concurrent_runs": {+ "name": "max_concurrent_runs",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "workspace_team_creation_check": {+ "name": "workspace_team_creation_check",+ "value": "\"workspace\".\"team_creation\" IN ('owner', 'managers', 'members')"+ },+ "workspace_max_concurrent_runs_check": {+ "name": "workspace_max_concurrent_runs_check",+ "value": "\"workspace\".\"max_concurrent_runs\" >= 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.workspace_manager": {+ "name": "workspace_manager",+ "schema": "",+ "columns": {+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'admin'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "workspace_manager_owner_uq": {+ "name": "workspace_manager_owner_uq",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"workspace_manager\".\"role\" = 'owner'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_manager_user_idx": {+ "name": "workspace_manager_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "workspace_manager_workspace_id_workspace_id_fk": {+ "name": "workspace_manager_workspace_id_workspace_id_fk",+ "tableFrom": "workspace_manager",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "workspace_manager_user_id_user_id_fk": {+ "name": "workspace_manager_user_id_user_id_fk",+ "tableFrom": "workspace_manager",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "workspace_manager_workspace_id_user_id_pk": {+ "name": "workspace_manager_workspace_id_user_id_pk",+ "columns": [+ "workspace_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "workspace_manager_role_check": {+ "name": "workspace_manager_role_check",+ "value": "\"workspace_manager\".\"role\" IN ('owner', 'admin')"+ }+ },+ "isRLSEnabled": false+ },+ "public.scim_group": {+ "name": "scim_group",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "display_name": {+ "name": "display_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "scim_group_instance_display_name_uq": {+ "name": "scim_group_instance_display_name_uq",+ "columns": [+ {+ "expression": "display_name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"scim_group\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "scim_group_workspace_id_workspace_id_fk": {+ "name": "scim_group_workspace_id_workspace_id_fk",+ "tableFrom": "scim_group",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "scim_group_workspace_id_display_name_unique": {+ "name": "scim_group_workspace_id_display_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "workspace_id",+ "display_name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.scim_group_mapping": {+ "name": "scim_group_mapping",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "group_id": {+ "name": "group_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "role_id": {+ "name": "role_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "scim_group_mapping_project_idx": {+ "name": "scim_group_mapping_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "scim_group_mapping_group_id_scim_group_id_fk": {+ "name": "scim_group_mapping_group_id_scim_group_id_fk",+ "tableFrom": "scim_group_mapping",+ "tableTo": "scim_group",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "scim_group_mapping_project_id_project_id_fk": {+ "name": "scim_group_mapping_project_id_project_id_fk",+ "tableFrom": "scim_group_mapping",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "scim_group_mapping_role_id_team_role_id_fk": {+ "name": "scim_group_mapping_role_id_team_role_id_fk",+ "tableFrom": "scim_group_mapping",+ "tableTo": "team_role",+ "columnsFrom": [+ "role_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "scim_group_mapping_group_id_project_id_unique": {+ "name": "scim_group_mapping_group_id_project_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "group_id",+ "project_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "scim_group_mapping_role_check": {+ "name": "scim_group_mapping_role_check",+ "value": "\"scim_group_mapping\".\"role\" IN ('owner', 'member')"+ }+ },+ "isRLSEnabled": false+ },+ "public.scim_group_member": {+ "name": "scim_group_member",+ "schema": "",+ "columns": {+ "group_id": {+ "name": "group_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "scim_group_member_user_idx": {+ "name": "scim_group_member_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "scim_group_member_group_id_scim_group_id_fk": {+ "name": "scim_group_member_group_id_scim_group_id_fk",+ "tableFrom": "scim_group_member",+ "tableTo": "scim_group",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "scim_group_member_user_id_user_id_fk": {+ "name": "scim_group_member_user_id_user_id_fk",+ "tableFrom": "scim_group_member",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "scim_group_member_group_id_user_id_pk": {+ "name": "scim_group_member_group_id_user_id_pk",+ "columns": [+ "group_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.scim_user": {+ "name": "scim_user",+ "schema": "",+ "columns": {+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "active": {+ "name": "active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "scim_user_instance_user_uq": {+ "name": "scim_user_instance_user_uq",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"scim_user\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "scim_user_user_idx": {+ "name": "scim_user_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "scim_user_workspace_id_workspace_id_fk": {+ "name": "scim_user_workspace_id_workspace_id_fk",+ "tableFrom": "scim_user",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "scim_user_user_id_user_id_fk": {+ "name": "scim_user_user_id_user_id_fk",+ "tableFrom": "scim_user",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "scim_user_workspace_id_user_id_unique": {+ "name": "scim_user_workspace_id_user_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "workspace_id",+ "user_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ }+ },+ "enums": {},+ "schemas": {},+ "sequences": {},+ "roles": {},+ "policies": {},+ "views": {},+ "_meta": {+ "columns": {},+ "schemas": {},+ "tables": {}+ }+}\ No newline at end of filediff --git a/packages/db/drizzle/meta/0173_snapshot.json b/packages/db/drizzle/meta/0173_snapshot.jsonnew file mode 100644index 00000000..66afc1ee--- /dev/null+++ b/packages/db/drizzle/meta/0173_snapshot.json@@ -0,0 +1,13121 @@+{+ "id": "3dec5873-79d6-437e-8e01-6cfc581b1999",+ "prevId": "9d240549-0640-404e-963f-bab8fbfb9830",+ "version": "7",+ "dialect": "postgresql",+ "tables": {+ "public.account": {+ "name": "account",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "account_id": {+ "name": "account_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_id": {+ "name": "provider_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "access_token_expires_at": {+ "name": "access_token_expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token_expires_at": {+ "name": "refresh_token_expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "password": {+ "name": "password",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "account_userId_idx": {+ "name": "account_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "account_user_id_user_id_fk": {+ "name": "account_user_id_user_id_fk",+ "tableFrom": "account",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.apikey": {+ "name": "apikey",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "config_id": {+ "name": "config_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'default'"+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "start": {+ "name": "start",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reference_id": {+ "name": "reference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prefix": {+ "name": "prefix",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "refill_interval": {+ "name": "refill_interval",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "refill_amount": {+ "name": "refill_amount",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "last_refill_at": {+ "name": "last_refill_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "rate_limit_enabled": {+ "name": "rate_limit_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "rate_limit_time_window": {+ "name": "rate_limit_time_window",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 1000+ },+ "rate_limit_max": {+ "name": "rate_limit_max",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 100+ },+ "request_count": {+ "name": "request_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "remaining": {+ "name": "remaining",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "last_request": {+ "name": "last_request",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "permissions": {+ "name": "permissions",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "apikey_configId_idx": {+ "name": "apikey_configId_idx",+ "columns": [+ {+ "expression": "config_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "apikey_referenceId_idx": {+ "name": "apikey_referenceId_idx",+ "columns": [+ {+ "expression": "reference_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "apikey_key_idx": {+ "name": "apikey_key_idx",+ "columns": [+ {+ "expression": "key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.jwks": {+ "name": "jwks",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "public_key": {+ "name": "public_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "private_key": {+ "name": "private_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "alg": {+ "name": "alg",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "crv": {+ "name": "crv",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_access_token": {+ "name": "oauth_access_token",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reference_id": {+ "name": "reference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "authorization_code_id": {+ "name": "authorization_code_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resources": {+ "name": "resources",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "requested_user_info_claims": {+ "name": "requested_user_info_claims",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_id": {+ "name": "refresh_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "revoked": {+ "name": "revoked",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "confirmation": {+ "name": "confirmation",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "scopes": {+ "name": "scopes",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "oauthAccessToken_clientId_idx": {+ "name": "oauthAccessToken_clientId_idx",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthAccessToken_sessionId_idx": {+ "name": "oauthAccessToken_sessionId_idx",+ "columns": [+ {+ "expression": "session_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthAccessToken_userId_idx": {+ "name": "oauthAccessToken_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthAccessToken_authorizationCodeId_idx": {+ "name": "oauthAccessToken_authorizationCodeId_idx",+ "columns": [+ {+ "expression": "authorization_code_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthAccessToken_refreshId_idx": {+ "name": "oauthAccessToken_refreshId_idx",+ "columns": [+ {+ "expression": "refresh_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oauth_access_token_client_id_oauth_client_client_id_fk": {+ "name": "oauth_access_token_client_id_oauth_client_client_id_fk",+ "tableFrom": "oauth_access_token",+ "tableTo": "oauth_client",+ "columnsFrom": [+ "client_id"+ ],+ "columnsTo": [+ "client_id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oauth_access_token_session_id_session_id_fk": {+ "name": "oauth_access_token_session_id_session_id_fk",+ "tableFrom": "oauth_access_token",+ "tableTo": "session",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "oauth_access_token_user_id_user_id_fk": {+ "name": "oauth_access_token_user_id_user_id_fk",+ "tableFrom": "oauth_access_token",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oauth_access_token_refresh_id_oauth_refresh_token_id_fk": {+ "name": "oauth_access_token_refresh_id_oauth_refresh_token_id_fk",+ "tableFrom": "oauth_access_token",+ "tableTo": "oauth_refresh_token",+ "columnsFrom": [+ "refresh_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "oauth_access_token_token_unique": {+ "name": "oauth_access_token_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_client": {+ "name": "oauth_client",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_secret": {+ "name": "client_secret",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_discovery_id": {+ "name": "client_discovery_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "disabled": {+ "name": "disabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "skip_consent": {+ "name": "skip_consent",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "enable_end_session": {+ "name": "enable_end_session",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "subject_type": {+ "name": "subject_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "scopes": {+ "name": "scopes",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "client_credentials_scopes": {+ "name": "client_credentials_scopes",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "uri": {+ "name": "uri",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "contacts": {+ "name": "contacts",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "tos": {+ "name": "tos",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "policy": {+ "name": "policy",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "software_id": {+ "name": "software_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "software_version": {+ "name": "software_version",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "software_statement": {+ "name": "software_statement",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "redirect_uris": {+ "name": "redirect_uris",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ },+ "post_logout_redirect_uris": {+ "name": "post_logout_redirect_uris",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "backchannel_logout_uri": {+ "name": "backchannel_logout_uri",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "backchannel_logout_session_required": {+ "name": "backchannel_logout_session_required",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "token_endpoint_auth_method": {+ "name": "token_endpoint_auth_method",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "application_type": {+ "name": "application_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "jwks": {+ "name": "jwks",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "jwks_uri": {+ "name": "jwks_uri",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "grant_types": {+ "name": "grant_types",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "response_types": {+ "name": "response_types",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "require_pkce": {+ "name": "require_pkce",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "dpop_bound_access_tokens": {+ "name": "dpop_bound_access_tokens",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "reference_id": {+ "name": "reference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "oauthClient_userId_idx": {+ "name": "oauthClient_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oauth_client_user_id_user_id_fk": {+ "name": "oauth_client_user_id_user_id_fk",+ "tableFrom": "oauth_client",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "oauth_client_client_id_unique": {+ "name": "oauth_client_client_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "client_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_client_assertion": {+ "name": "oauth_client_assertion",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_client_resource": {+ "name": "oauth_client_resource",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resource_id": {+ "name": "resource_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "oauthClientResource_clientId_resourceId_uidx": {+ "name": "oauthClientResource_clientId_resourceId_uidx",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthClientResource_clientId_idx": {+ "name": "oauthClientResource_clientId_idx",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthClientResource_resourceId_idx": {+ "name": "oauthClientResource_resourceId_idx",+ "columns": [+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oauth_client_resource_client_id_oauth_client_client_id_fk": {+ "name": "oauth_client_resource_client_id_oauth_client_client_id_fk",+ "tableFrom": "oauth_client_resource",+ "tableTo": "oauth_client",+ "columnsFrom": [+ "client_id"+ ],+ "columnsTo": [+ "client_id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oauth_client_resource_resource_id_oauth_resource_identifier_fk": {+ "name": "oauth_client_resource_resource_id_oauth_resource_identifier_fk",+ "tableFrom": "oauth_client_resource",+ "tableTo": "oauth_resource",+ "columnsFrom": [+ "resource_id"+ ],+ "columnsTo": [+ "identifier"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_consent": {+ "name": "oauth_consent",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reference_id": {+ "name": "reference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resources": {+ "name": "resources",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "requested_user_info_claims": {+ "name": "requested_user_info_claims",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "scopes": {+ "name": "scopes",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "oauthConsent_clientId_idx": {+ "name": "oauthConsent_clientId_idx",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthConsent_userId_idx": {+ "name": "oauthConsent_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oauth_consent_client_id_oauth_client_client_id_fk": {+ "name": "oauth_consent_client_id_oauth_client_client_id_fk",+ "tableFrom": "oauth_consent",+ "tableTo": "oauth_client",+ "columnsFrom": [+ "client_id"+ ],+ "columnsTo": [+ "client_id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oauth_consent_user_id_user_id_fk": {+ "name": "oauth_consent_user_id_user_id_fk",+ "tableFrom": "oauth_consent",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_refresh_token": {+ "name": "oauth_refresh_token",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "reference_id": {+ "name": "reference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "authorization_code_id": {+ "name": "authorization_code_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resources": {+ "name": "resources",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "requested_user_info_claims": {+ "name": "requested_user_info_claims",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "revoked": {+ "name": "revoked",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "rotated_at": {+ "name": "rotated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "rotation_replay_response": {+ "name": "rotation_replay_response",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "rotation_replay_expires_at": {+ "name": "rotation_replay_expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "auth_time": {+ "name": "auth_time",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "confirmation": {+ "name": "confirmation",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "scopes": {+ "name": "scopes",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "oauthRefreshToken_clientId_idx": {+ "name": "oauthRefreshToken_clientId_idx",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthRefreshToken_sessionId_idx": {+ "name": "oauthRefreshToken_sessionId_idx",+ "columns": [+ {+ "expression": "session_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthRefreshToken_userId_idx": {+ "name": "oauthRefreshToken_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthRefreshToken_authorizationCodeId_idx": {+ "name": "oauthRefreshToken_authorizationCodeId_idx",+ "columns": [+ {+ "expression": "authorization_code_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oauth_refresh_token_client_id_oauth_client_client_id_fk": {+ "name": "oauth_refresh_token_client_id_oauth_client_client_id_fk",+ "tableFrom": "oauth_refresh_token",+ "tableTo": "oauth_client",+ "columnsFrom": [+ "client_id"+ ],+ "columnsTo": [+ "client_id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oauth_refresh_token_session_id_session_id_fk": {+ "name": "oauth_refresh_token_session_id_session_id_fk",+ "tableFrom": "oauth_refresh_token",+ "tableTo": "session",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "oauth_refresh_token_user_id_user_id_fk": {+ "name": "oauth_refresh_token_user_id_user_id_fk",+ "tableFrom": "oauth_refresh_token",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "oauth_refresh_token_token_unique": {+ "name": "oauth_refresh_token_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_resource": {+ "name": "oauth_resource",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "access_token_ttl": {+ "name": "access_token_ttl",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token_ttl": {+ "name": "refresh_token_ttl",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "signing_algorithm": {+ "name": "signing_algorithm",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "signing_key_id": {+ "name": "signing_key_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "allowed_scopes": {+ "name": "allowed_scopes",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "custom_claims": {+ "name": "custom_claims",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "dpop_bound_access_tokens_required": {+ "name": "dpop_bound_access_tokens_required",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "disabled": {+ "name": "disabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "policy_version": {+ "name": "policy_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 1+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "oauth_resource_identifier_unique": {+ "name": "oauth_resource_identifier_unique",+ "nullsNotDistinct": false,+ "columns": [+ "identifier"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.passkey": {+ "name": "passkey",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "public_key": {+ "name": "public_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "credential_id": {+ "name": "credential_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "counter": {+ "name": "counter",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "device_type": {+ "name": "device_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "backed_up": {+ "name": "backed_up",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true+ },+ "transports": {+ "name": "transports",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "aaguid": {+ "name": "aaguid",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "passkey_userId_idx": {+ "name": "passkey_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "passkey_credentialID_idx": {+ "name": "passkey_credentialID_idx",+ "columns": [+ {+ "expression": "credential_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "passkey_user_id_user_id_fk": {+ "name": "passkey_user_id_user_id_fk",+ "tableFrom": "passkey",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.session": {+ "name": "session",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "ip_address": {+ "name": "ip_address",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_agent": {+ "name": "user_agent",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "session_userId_idx": {+ "name": "session_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "session_user_id_user_id_fk": {+ "name": "session_user_id_user_id_fk",+ "tableFrom": "session",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "session_token_unique": {+ "name": "session_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user": {+ "name": "user",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email_verified": {+ "name": "email_verified",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "image": {+ "name": "image",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "username": {+ "name": "username",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "display_username": {+ "name": "display_username",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'user'"+ },+ "active": {+ "name": "active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "last_seen_at": {+ "name": "last_seen_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "user_email_unique": {+ "name": "user_email_unique",+ "nullsNotDistinct": false,+ "columns": [+ "email"+ ]+ },+ "user_username_unique": {+ "name": "user_username_unique",+ "nullsNotDistinct": false,+ "columns": [+ "username"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verification": {+ "name": "verification",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "verification_identifier_idx": {+ "name": "verification_identifier_idx",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_chat_event": {+ "name": "agent_chat_event",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigserial",+ "primaryKey": true,+ "notNull": true+ },+ "message_id": {+ "name": "message_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_chat_event_message_idx": {+ "name": "agent_chat_event_message_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_chat_event_message_id_agent_chat_message_id_fk": {+ "name": "agent_chat_event_message_id_agent_chat_message_id_fk",+ "tableFrom": "agent_chat_event",+ "tableTo": "agent_chat_message",+ "columnsFrom": [+ "message_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_chat_favorite": {+ "name": "agent_chat_favorite",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "agent_chat_favorite_user_id_user_id_fk": {+ "name": "agent_chat_favorite_user_id_user_id_fk",+ "tableFrom": "agent_chat_favorite",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_chat_favorite_agent_id_ai_agent_id_fk": {+ "name": "agent_chat_favorite_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_chat_favorite",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_chat_favorite_user_id_thread_id_pk": {+ "name": "agent_chat_favorite_user_id_thread_id_pk",+ "columns": [+ "user_id",+ "thread_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_chat_message": {+ "name": "agent_chat_message",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_chat_message_thread_idx": {+ "name": "agent_chat_message_thread_idx",+ "columns": [+ {+ "expression": "thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_chat_message_due_idx": {+ "name": "agent_chat_message_due_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"agent_chat_message\".\"status\" IN ('pending', 'streaming')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_chat_message_thread_id_agent_chat_thread_id_fk": {+ "name": "agent_chat_message_thread_id_agent_chat_thread_id_fk",+ "tableFrom": "agent_chat_message",+ "tableTo": "agent_chat_thread",+ "columnsFrom": [+ "thread_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_chat_message_agent_id_ai_agent_id_fk": {+ "name": "agent_chat_message_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_chat_message",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "agent_chat_message_role_check": {+ "name": "agent_chat_message_role_check",+ "value": "\"agent_chat_message\".\"role\" IN ('user', 'assistant')"+ },+ "agent_chat_message_status_check": {+ "name": "agent_chat_message_status_check",+ "value": "\"agent_chat_message\".\"status\" IN ('pending', 'streaming', 'success', 'failed', 'canceled')"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_chat_thread": {+ "name": "agent_chat_thread",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "cli_session_id": {+ "name": "cli_session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_chat_thread_agent_user_idx": {+ "name": "agent_chat_thread_agent_user_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_chat_thread_agent_id_ai_agent_id_fk": {+ "name": "agent_chat_thread_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_chat_thread",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_chat_thread_user_id_user_id_fk": {+ "name": "agent_chat_thread_user_id_user_id_fk",+ "tableFrom": "agent_chat_thread",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_chat_usage": {+ "name": "agent_chat_usage",+ "schema": "",+ "columns": {+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "input_tokens": {+ "name": "input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "output_tokens": {+ "name": "output_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_chat_usage_agent_idx": {+ "name": "agent_chat_usage_agent_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_chat_usage_agent_id_ai_agent_id_fk": {+ "name": "agent_chat_usage_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_chat_usage",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_field_trigger": {+ "name": "agent_field_trigger",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "field_id": {+ "name": "field_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "delay_sec": {+ "name": "delay_sec",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 120+ }+ },+ "indexes": {+ "agent_field_trigger_field_idx": {+ "name": "agent_field_trigger_field_idx",+ "columns": [+ {+ "expression": "field_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_field_trigger_agent_id_ai_agent_id_fk": {+ "name": "agent_field_trigger_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_field_trigger",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_field_trigger_field_id_custom_field_id_fk": {+ "name": "agent_field_trigger_field_id_custom_field_id_fk",+ "tableFrom": "agent_field_trigger",+ "tableTo": "custom_field",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_field_trigger_agent_id_field_id_pk": {+ "name": "agent_field_trigger_agent_id_field_id_pk",+ "columns": [+ "agent_id",+ "field_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "agent_field_trigger_delay_check": {+ "name": "agent_field_trigger_delay_check",+ "value": "\"agent_field_trigger\".\"delay_sec\" >= 0 AND \"agent_field_trigger\".\"delay_sec\" <= 86400"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_run": {+ "name": "agent_run",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "schedule_id": {+ "name": "schedule_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "trigger": {+ "name": "trigger",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'delegation'"+ },+ "scheduled_for": {+ "name": "scheduled_for",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "source_activity_id": {+ "name": "source_activity_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "source_document_comment_id": {+ "name": "source_document_comment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "prompt": {+ "name": "prompt",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "output": {+ "name": "output",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "input_tokens": {+ "name": "input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "output_tokens": {+ "name": "output_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "execution_started_at": {+ "name": "execution_started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "claimed_at": {+ "name": "claimed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_run_schedule_fire_uq": {+ "name": "agent_run_schedule_fire_uq",+ "columns": [+ {+ "expression": "schedule_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scheduled_for",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_run_due_idx": {+ "name": "agent_run_due_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_run_schedule_idx": {+ "name": "agent_run_schedule_idx",+ "columns": [+ {+ "expression": "schedule_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_run_project_idx": {+ "name": "agent_run_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_run_issue_idx": {+ "name": "agent_run_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"agent_run\".\"issue_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_run_source_activity_idx": {+ "name": "agent_run_source_activity_idx",+ "columns": [+ {+ "expression": "source_activity_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"agent_run\".\"source_activity_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_run_agent_id_ai_agent_id_fk": {+ "name": "agent_run_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_run_project_id_project_id_fk": {+ "name": "agent_run_project_id_project_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_run_issue_id_issue_id_fk": {+ "name": "agent_run_issue_id_issue_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_run_schedule_id_agent_schedule_id_fk": {+ "name": "agent_run_schedule_id_agent_schedule_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "agent_schedule",+ "columnsFrom": [+ "schedule_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_run_source_activity_id_issue_activity_id_fk": {+ "name": "agent_run_source_activity_id_issue_activity_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "issue_activity",+ "columnsFrom": [+ "source_activity_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_run_document_id_project_document_id_fk": {+ "name": "agent_run_document_id_project_document_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_run_source_document_comment_id_document_comment_id_fk": {+ "name": "agent_run_source_document_comment_id_document_comment_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "document_comment",+ "columnsFrom": [+ "source_document_comment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "agent_run_status_check": {+ "name": "agent_run_status_check",+ "value": "\"agent_run\".\"status\" IN ('pending', 'success', 'failed', 'canceled')"+ },+ "agent_run_trigger_check": {+ "name": "agent_run_trigger_check",+ "value": "\"agent_run\".\"trigger\" IN ('mention', 'delegation', 'field', 'schedule', 'manual', 'status', 'event')"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_run_trace": {+ "name": "agent_run_trace",+ "schema": "",+ "columns": {+ "run_id": {+ "name": "run_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "attempt": {+ "name": "attempt",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "events": {+ "name": "events",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "next_offset": {+ "name": "next_offset",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "truncated": {+ "name": "truncated",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "agent_run_trace_run_id_agent_run_id_fk": {+ "name": "agent_run_trace_run_id_agent_run_id_fk",+ "tableFrom": "agent_run_trace",+ "tableTo": "agent_run",+ "columnsFrom": [+ "run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_run_trace_run_id_attempt_pk": {+ "name": "agent_run_trace_run_id_attempt_pk",+ "columns": [+ "run_id",+ "attempt"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_schedule": {+ "name": "agent_schedule",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prompt": {+ "name": "prompt",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'cron'"+ },+ "cron": {+ "name": "cron",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "timezone": {+ "name": "timezone",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "next_run_at": {+ "name": "next_run_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "column_id": {+ "name": "column_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "delay_sec": {+ "name": "delay_sec",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "options": {+ "name": "options",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "last_run_at": {+ "name": "last_run_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_schedule_due_idx": {+ "name": "agent_schedule_due_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_run_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_schedule_agent_idx": {+ "name": "agent_schedule_agent_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_schedule_project_idx": {+ "name": "agent_schedule_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_schedule_column_idx": {+ "name": "agent_schedule_column_idx",+ "columns": [+ {+ "expression": "column_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_schedule_agent_id_ai_agent_id_fk": {+ "name": "agent_schedule_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_schedule",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_schedule_project_id_project_id_fk": {+ "name": "agent_schedule_project_id_project_id_fk",+ "tableFrom": "agent_schedule",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_schedule_column_id_project_column_id_fk": {+ "name": "agent_schedule_column_id_project_column_id_fk",+ "tableFrom": "agent_schedule",+ "tableTo": "project_column",+ "columnsFrom": [+ "column_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "agent_schedule_project_id_agent_id_name_unique": {+ "name": "agent_schedule_project_id_agent_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "agent_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "agent_schedule_status_check": {+ "name": "agent_schedule_status_check",+ "value": "\"agent_schedule\".\"status\" IN ('active', 'paused')"+ },+ "agent_schedule_type_check": {+ "name": "agent_schedule_type_check",+ "value": "(\"agent_schedule\".\"type\" = 'cron' AND \"agent_schedule\".\"cron\" IS NOT NULL AND \"agent_schedule\".\"next_run_at\" IS NOT NULL AND \"agent_schedule\".\"column_id\" IS NULL)\n OR (\"agent_schedule\".\"type\" = 'status' AND \"agent_schedule\".\"column_id\" IS NOT NULL AND \"agent_schedule\".\"cron\" IS NULL AND \"agent_schedule\".\"next_run_at\" IS NULL)\n OR (\"agent_schedule\".\"type\" NOT IN ('cron', 'status') AND \"agent_schedule\".\"cron\" IS NULL AND \"agent_schedule\".\"next_run_at\" IS NULL AND \"agent_schedule\".\"column_id\" IS NULL)"+ },+ "agent_schedule_delay_check": {+ "name": "agent_schedule_delay_check",+ "value": "\"agent_schedule\".\"delay_sec\" >= 0 AND \"agent_schedule\".\"delay_sec\" <= 86400"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_skill": {+ "name": "agent_skill",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_url": {+ "name": "source_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "s3_prefix": {+ "name": "s3_prefix",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "files": {+ "name": "files",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_skill_team_idx": {+ "name": "agent_skill_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_skill_team_id_team_id_fk": {+ "name": "agent_skill_team_id_team_id_fk",+ "tableFrom": "agent_skill",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "agent_skill_team_id_name_unique": {+ "name": "agent_skill_team_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "team_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "agent_skill_source_check": {+ "name": "agent_skill_source_check",+ "value": "\"agent_skill\".\"source\" IN ('upload', 'inline', 'github')"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_skill_link": {+ "name": "agent_skill_link",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "skill_id": {+ "name": "skill_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "agent_skill_link_skill_idx": {+ "name": "agent_skill_link_skill_idx",+ "columns": [+ {+ "expression": "skill_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_skill_link_agent_id_ai_agent_id_fk": {+ "name": "agent_skill_link_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_skill_link",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_skill_link_skill_id_agent_skill_id_fk": {+ "name": "agent_skill_link_skill_id_agent_skill_id_fk",+ "tableFrom": "agent_skill_link",+ "tableTo": "agent_skill",+ "columnsFrom": [+ "skill_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_skill_link_agent_id_skill_id_pk": {+ "name": "agent_skill_link_agent_id_skill_id_pk",+ "columns": [+ "agent_id",+ "skill_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_tool": {+ "name": "agent_tool",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "tool_key": {+ "name": "tool_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "credential_id": {+ "name": "credential_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_tool_team_tool_keyless_uq": {+ "name": "agent_tool_team_tool_keyless_uq",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tool_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_tool\".\"credential_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_tool_team_idx": {+ "name": "agent_tool_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_tool_credential_idx": {+ "name": "agent_tool_credential_idx",+ "columns": [+ {+ "expression": "credential_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_tool_team_id_team_id_fk": {+ "name": "agent_tool_team_id_team_id_fk",+ "tableFrom": "agent_tool",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_tool_credential_id_integration_credential_id_fk": {+ "name": "agent_tool_credential_id_integration_credential_id_fk",+ "tableFrom": "agent_tool",+ "tableTo": "integration_credential",+ "columnsFrom": [+ "credential_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "agent_tool_team_id_tool_key_credential_id_unique": {+ "name": "agent_tool_team_id_tool_key_credential_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "team_id",+ "tool_key",+ "credential_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_tool_link": {+ "name": "agent_tool_link",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "agent_tool_id": {+ "name": "agent_tool_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "agent_tool_link_tool_idx": {+ "name": "agent_tool_link_tool_idx",+ "columns": [+ {+ "expression": "agent_tool_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_tool_link_agent_id_ai_agent_id_fk": {+ "name": "agent_tool_link_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_tool_link",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_tool_link_agent_tool_id_agent_tool_id_fk": {+ "name": "agent_tool_link_agent_tool_id_agent_tool_id_fk",+ "tableFrom": "agent_tool_link",+ "tableTo": "agent_tool",+ "columnsFrom": [+ "agent_tool_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_tool_link_agent_id_agent_tool_id_pk": {+ "name": "agent_tool_link_agent_id_agent_tool_id_pk",+ "columns": [+ "agent_id",+ "agent_tool_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.ai_agent": {+ "name": "ai_agent",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "username": {+ "name": "username",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "model_credential_id": {+ "name": "model_credential_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "instructions": {+ "name": "instructions",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tools": {+ "name": "tools",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "temperature": {+ "name": "temperature",+ "type": "double precision",+ "primaryKey": false,+ "notNull": false+ },+ "reasoning_effort": {+ "name": "reasoning_effort",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "max_steps": {+ "name": "max_steps",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "run_timeout_sec": {+ "name": "run_timeout_sec",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "trigger_on_mention": {+ "name": "trigger_on_mention",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "trigger_on_assign": {+ "name": "trigger_on_assign",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "chat_enabled": {+ "name": "chat_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "delegation_delay_sec": {+ "name": "delegation_delay_sec",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 120+ },+ "api_key_ciphertext": {+ "name": "api_key_ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "api_key_iv": {+ "name": "api_key_iv",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "api_key_auth_tag": {+ "name": "api_key_auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "memory_enabled": {+ "name": "memory_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "memory_last_messages": {+ "name": "memory_last_messages",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "runner_scope": {+ "name": "runner_scope",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'team'"+ },+ "last_seen_at": {+ "name": "last_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "invocation_url": {+ "name": "invocation_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "invocation_secret_ciphertext": {+ "name": "invocation_secret_ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "invocation_secret_iv": {+ "name": "invocation_secret_iv",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "invocation_secret_auth_tag": {+ "name": "invocation_secret_auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "ai_agent_team_username_uq": {+ "name": "ai_agent_team_username_uq",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "lower(\"username\")",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "ai_agent_team_idx": {+ "name": "ai_agent_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "ai_agent_team_id_team_id_fk": {+ "name": "ai_agent_team_id_team_id_fk",+ "tableFrom": "ai_agent",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "ai_agent_user_id_user_id_fk": {+ "name": "ai_agent_user_id_user_id_fk",+ "tableFrom": "ai_agent",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "ai_agent_model_credential_id_integration_credential_id_fk": {+ "name": "ai_agent_model_credential_id_integration_credential_id_fk",+ "tableFrom": "ai_agent",+ "tableTo": "integration_credential",+ "columnsFrom": [+ "model_credential_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "ai_agent_owner_user_id_user_id_fk": {+ "name": "ai_agent_owner_user_id_user_id_fk",+ "tableFrom": "ai_agent",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "ai_agent_user_id_unique": {+ "name": "ai_agent_user_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "user_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "ai_agent_kind_check": {+ "name": "ai_agent_kind_check",+ "value": "\"ai_agent\".\"kind\" IN ('external', 'internal')"+ },+ "ai_agent_runner_scope_check": {+ "name": "ai_agent_runner_scope_check",+ "value": "\"ai_agent\".\"runner_scope\" IN ('owner', 'team')"+ },+ "ai_agent_reasoning_effort_check": {+ "name": "ai_agent_reasoning_effort_check",+ "value": "\"ai_agent\".\"reasoning_effort\" IN ('low', 'medium', 'high')"+ },+ "ai_agent_delegation_delay_check": {+ "name": "ai_agent_delegation_delay_check",+ "value": "\"ai_agent\".\"delegation_delay_sec\" >= 0 AND \"ai_agent\".\"delegation_delay_sec\" <= 86400"+ }+ },+ "isRLSEnabled": false+ },+ "public.app_secret": {+ "name": "app_secret",+ "schema": "",+ "columns": {+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "ciphertext": {+ "name": "ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "iv": {+ "name": "iv",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "auth_tag": {+ "name": "auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "redacted": {+ "name": "redacted",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.app_setting": {+ "name": "app_setting",+ "schema": "",+ "columns": {+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.chat_attachment": {+ "name": "chat_attachment",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "public_id": {+ "name": "public_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "uploaded_by_user_id": {+ "name": "uploaded_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "s3_key": {+ "name": "s3_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "filename": {+ "name": "filename",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size_bytes": {+ "name": "size_bytes",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_attachment_project_idx": {+ "name": "chat_attachment_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_attachment_project_id_project_id_fk": {+ "name": "chat_attachment_project_id_project_id_fk",+ "tableFrom": "chat_attachment",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_attachment_uploaded_by_user_id_user_id_fk": {+ "name": "chat_attachment_uploaded_by_user_id_user_id_fk",+ "tableFrom": "chat_attachment",+ "tableTo": "user",+ "columnsFrom": [+ "uploaded_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "chat_attachment_public_id_unique": {+ "name": "chat_attachment_public_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "public_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.custom_field": {+ "name": "custom_field",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "issue_type_id": {+ "name": "issue_type_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "field_type": {+ "name": "field_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "member_scope": {+ "name": "member_scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "show_in_body": {+ "name": "show_in_body",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "custom_field_project_id_project_id_fk": {+ "name": "custom_field_project_id_project_id_fk",+ "tableFrom": "custom_field",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "custom_field_issue_type_id_issue_type_id_fk": {+ "name": "custom_field_issue_type_id_issue_type_id_fk",+ "tableFrom": "custom_field",+ "tableTo": "issue_type",+ "columnsFrom": [+ "issue_type_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "custom_field_field_type_check": {+ "name": "custom_field_field_type_check",+ "value": "\"custom_field\".\"field_type\" IN ('text', 'markdown', 'url', 'number', 'boolean', 'date', 'datetime', 'datetime_range', 'select', 'multi_select', 'member')"+ },+ "custom_field_member_scope_check": {+ "name": "custom_field_member_scope_check",+ "value": "(\"custom_field\".\"field_type\" = 'member') = (\"custom_field\".\"member_scope\" IS NOT NULL) AND (\"custom_field\".\"member_scope\" IS NULL OR \"custom_field\".\"member_scope\" IN ('all', 'humans', 'agents'))"+ }+ },+ "isRLSEnabled": false+ },+ "public.custom_field_option": {+ "name": "custom_field_option",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "field_id": {+ "name": "field_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ }+ },+ "indexes": {},+ "foreignKeys": {+ "custom_field_option_field_id_custom_field_id_fk": {+ "name": "custom_field_option_field_id_custom_field_id_fk",+ "tableFrom": "custom_field_option",+ "tableTo": "custom_field",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "custom_field_option_field_id_value_unique": {+ "name": "custom_field_option_field_id_value_unique",+ "nullsNotDistinct": false,+ "columns": [+ "field_id",+ "value"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.cycle": {+ "name": "cycle",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "goal": {+ "name": "goal",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "start_date": {+ "name": "start_date",+ "type": "date",+ "primaryKey": false,+ "notNull": true+ },+ "end_date": {+ "name": "end_date",+ "type": "date",+ "primaryKey": false,+ "notNull": true+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "cycle_project_idx": {+ "name": "cycle_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "start_date",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "cycle_project_id_project_id_fk": {+ "name": "cycle_project_id_project_id_fk",+ "tableFrom": "cycle",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "cycle_dates_check": {+ "name": "cycle_dates_check",+ "value": "\"cycle\".\"end_date\" >= \"cycle\".\"start_date\""+ }+ },+ "isRLSEnabled": false+ },+ "public.document_asset": {+ "name": "document_asset",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "public_id": {+ "name": "public_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "uploaded_by_user_id": {+ "name": "uploaded_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "s3_key": {+ "name": "s3_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "filename": {+ "name": "filename",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size_bytes": {+ "name": "size_bytes",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "document_asset_document_idx": {+ "name": "document_asset_document_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_asset_document_id_project_document_id_fk": {+ "name": "document_asset_document_id_project_document_id_fk",+ "tableFrom": "document_asset",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_asset_uploaded_by_user_id_user_id_fk": {+ "name": "document_asset_uploaded_by_user_id_user_id_fk",+ "tableFrom": "document_asset",+ "tableTo": "user",+ "columnsFrom": [+ "uploaded_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "document_asset_public_id_unique": {+ "name": "document_asset_public_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "public_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_collaboration": {+ "name": "document_collaboration",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true+ },+ "epoch": {+ "name": "epoch",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "content_json": {+ "name": "content_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "document_collaboration_document_id_project_document_id_fk": {+ "name": "document_collaboration_document_id_project_document_id_fk",+ "tableFrom": "document_collaboration",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_comment": {+ "name": "document_comment",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "parent_id": {+ "name": "parent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "author_id": {+ "name": "author_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "quote": {+ "name": "quote",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "selection_from": {+ "name": "selection_from",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "selection_to": {+ "name": "selection_to",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "orphaned": {+ "name": "orphaned",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "document_comment_document_idx": {+ "name": "document_comment_document_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_comment_document_id_project_document_id_fk": {+ "name": "document_comment_document_id_project_document_id_fk",+ "tableFrom": "document_comment",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_comment_parent_id_document_comment_id_fk": {+ "name": "document_comment_parent_id_document_comment_id_fk",+ "tableFrom": "document_comment",+ "tableTo": "document_comment",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_comment_author_id_user_id_fk": {+ "name": "document_comment_author_id_user_id_fk",+ "tableFrom": "document_comment",+ "tableTo": "user",+ "columnsFrom": [+ "author_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_step": {+ "name": "document_step",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "step": {+ "name": "step",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "document_step_document_id_project_document_id_fk": {+ "name": "document_step_document_id_project_document_id_fk",+ "tableFrom": "document_step",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "document_step_document_id_version_pk": {+ "name": "document_step_document_id_version_pk",+ "columns": [+ "document_id",+ "version"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.git_managed_repository": {+ "name": "git_managed_repository",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "connection_id": {+ "name": "connection_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "full_name": {+ "name": "full_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "web_url": {+ "name": "web_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "webhook_external_id": {+ "name": "webhook_external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'connected'"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "git_managed_repository_project_connection_idx": {+ "name": "git_managed_repository_project_connection_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "git_managed_repository_project_id_project_id_fk": {+ "name": "git_managed_repository_project_id_project_id_fk",+ "tableFrom": "git_managed_repository",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "git_managed_repository_connection_id_git_provider_connection_id_fk": {+ "name": "git_managed_repository_connection_id_git_provider_connection_id_fk",+ "tableFrom": "git_managed_repository",+ "tableTo": "git_provider_connection",+ "columnsFrom": [+ "connection_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "git_managed_repository_project_connection_external_unique": {+ "name": "git_managed_repository_project_connection_external_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "connection_id",+ "external_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.git_provider_connection": {+ "name": "git_provider_connection",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "base_url": {+ "name": "base_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "account_login": {+ "name": "account_login",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "ciphertext": {+ "name": "ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "iv": {+ "name": "iv",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "auth_tag": {+ "name": "auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "git_provider_connection_team_idx": {+ "name": "git_provider_connection_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "git_provider_connection_team_id_team_id_fk": {+ "name": "git_provider_connection_team_id_team_id_fk",+ "tableFrom": "git_provider_connection",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.import_job": {+ "name": "import_job",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "phase": {+ "name": "phase",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'discover'"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "cursor": {+ "name": "cursor",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "credential_ciphertext": {+ "name": "credential_ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "credential_iv": {+ "name": "credential_iv",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "credential_auth_tag": {+ "name": "credential_auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "import_job_project_idx": {+ "name": "import_job_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "import_job_due_idx": {+ "name": "import_job_due_idx",+ "columns": [+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"import_job\".\"status\" = 'pending'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "import_job_project_id_project_id_fk": {+ "name": "import_job_project_id_project_id_fk",+ "tableFrom": "import_job",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "import_job_created_by_user_id_user_id_fk": {+ "name": "import_job_created_by_user_id_user_id_fk",+ "tableFrom": "import_job",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "import_job_phase_check": {+ "name": "import_job_phase_check",+ "value": "\"import_job\".\"phase\" IN ('discover', 'create', 'link', 'rewrite', 'attachments', 'done')"+ },+ "import_job_status_check": {+ "name": "import_job_status_check",+ "value": "\"import_job\".\"status\" IN ('pending', 'running', 'paused', 'completed', 'failed')"+ }+ },+ "isRLSEnabled": false+ },+ "public.import_record": {+ "name": "import_record",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "import_job_id": {+ "name": "import_job_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "source_entity_type": {+ "name": "source_entity_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_id": {+ "name": "source_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_display_id": {+ "name": "source_display_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "local_entity_type": {+ "name": "local_entity_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "local_id": {+ "name": "local_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "import_record_job_source_uq": {+ "name": "import_record_job_source_uq",+ "columns": [+ {+ "expression": "import_job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_entity_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "import_record_job_local_idx": {+ "name": "import_record_job_local_idx",+ "columns": [+ {+ "expression": "import_job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "local_entity_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "local_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "import_record_job_display_idx": {+ "name": "import_record_job_display_idx",+ "columns": [+ {+ "expression": "import_job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_entity_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_display_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "import_record_import_job_id_import_job_id_fk": {+ "name": "import_record_import_job_id_import_job_id_fk",+ "tableFrom": "import_record",+ "tableTo": "import_job",+ "columnsFrom": [+ "import_job_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "import_record_source_entity_type_check": {+ "name": "import_record_source_entity_type_check",+ "value": "\"import_record\".\"source_entity_type\" IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment', 'checklist', 'custom_field')"+ },+ "import_record_local_entity_type_check": {+ "name": "import_record_local_entity_type_check",+ "value": "\"import_record\".\"local_entity_type\" IS NULL OR \"import_record\".\"local_entity_type\" IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment', 'checklist', 'custom_field')"+ }+ },+ "isRLSEnabled": false+ },+ "public.initiative": {+ "name": "initiative",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'planned'"+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "priority": {+ "name": "priority",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "start_date": {+ "name": "start_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "target_date": {+ "name": "target_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "initiative_project_idx": {+ "name": "initiative_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "initiative_project_id_project_id_fk": {+ "name": "initiative_project_id_project_id_fk",+ "tableFrom": "initiative",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "initiative_owner_user_id_user_id_fk": {+ "name": "initiative_owner_user_id_user_id_fk",+ "tableFrom": "initiative",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "initiative_status_check": {+ "name": "initiative_status_check",+ "value": "\"initiative\".\"status\" IN ('proposed', 'planned', 'active', 'completed', 'canceled')"+ }+ },+ "isRLSEnabled": false+ },+ "public.initiative_attachment": {+ "name": "initiative_attachment",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "public_id": {+ "name": "public_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "s3_key": {+ "name": "s3_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "filename": {+ "name": "filename",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size_bytes": {+ "name": "size_bytes",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "initiative_attachment_initiative_idx": {+ "name": "initiative_attachment_initiative_idx",+ "columns": [+ {+ "expression": "initiative_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "initiative_attachment_initiative_id_initiative_id_fk": {+ "name": "initiative_attachment_initiative_id_initiative_id_fk",+ "tableFrom": "initiative_attachment",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "initiative_attachment_public_id_unique": {+ "name": "initiative_attachment_public_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "public_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.initiative_label": {+ "name": "initiative_label",+ "schema": "",+ "columns": {+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "label_id": {+ "name": "label_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "initiative_label_initiative_id_initiative_id_fk": {+ "name": "initiative_label_initiative_id_initiative_id_fk",+ "tableFrom": "initiative_label",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "initiative_label_label_id_label_id_fk": {+ "name": "initiative_label_label_id_label_id_fk",+ "tableFrom": "initiative_label",+ "tableTo": "label",+ "columnsFrom": [+ "label_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "initiative_label_initiative_id_label_id_pk": {+ "name": "initiative_label_initiative_id_label_id_pk",+ "columns": [+ "initiative_id",+ "label_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.integration_credential": {+ "name": "integration_credential",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "integration_key": {+ "name": "integration_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "label": {+ "name": "label",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "ciphertext": {+ "name": "ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "iv": {+ "name": "iv",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "auth_tag": {+ "name": "auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "redacted": {+ "name": "redacted",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "integration_credential_team_idx": {+ "name": "integration_credential_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "integration_credential_team_id_team_id_fk": {+ "name": "integration_credential_team_id_team_id_fk",+ "tableFrom": "integration_credential",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue": {+ "name": "issue",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "sequence_number": {+ "name": "sequence_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "type_id": {+ "name": "type_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "cycle_id": {+ "name": "cycle_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "column_id": {+ "name": "column_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "parent_id": {+ "name": "parent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_user_id": {+ "name": "assignee_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "delegate_user_id": {+ "name": "delegate_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "priority": {+ "name": "priority",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "estimate_points": {+ "name": "estimate_points",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "estimate_minutes": {+ "name": "estimate_minutes",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "start_date": {+ "name": "start_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "due_date": {+ "name": "due_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "share_token": {+ "name": "share_token",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "share_extended": {+ "name": "share_extended",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "share_expires_at": {+ "name": "share_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_project_active_idx": {+ "name": "issue_project_active_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "column_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue\".\"archived_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_project_title_idx": {+ "name": "issue_project_title_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "lower(btrim(\"title\"))",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_parent_idx": {+ "name": "issue_parent_idx",+ "columns": [+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue\".\"parent_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_cycle_idx": {+ "name": "issue_cycle_idx",+ "columns": [+ {+ "expression": "cycle_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue\".\"cycle_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_initiative_idx": {+ "name": "issue_initiative_idx",+ "columns": [+ {+ "expression": "initiative_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue\".\"initiative_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_project_id_project_id_fk": {+ "name": "issue_project_id_project_id_fk",+ "tableFrom": "issue",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_type_id_issue_type_id_fk": {+ "name": "issue_type_id_issue_type_id_fk",+ "tableFrom": "issue",+ "tableTo": "issue_type",+ "columnsFrom": [+ "type_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_initiative_id_initiative_id_fk": {+ "name": "issue_initiative_id_initiative_id_fk",+ "tableFrom": "issue",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_cycle_id_cycle_id_fk": {+ "name": "issue_cycle_id_cycle_id_fk",+ "tableFrom": "issue",+ "tableTo": "cycle",+ "columnsFrom": [+ "cycle_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_column_id_project_column_id_fk": {+ "name": "issue_column_id_project_column_id_fk",+ "tableFrom": "issue",+ "tableTo": "project_column",+ "columnsFrom": [+ "column_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_parent_id_issue_id_fk": {+ "name": "issue_parent_id_issue_id_fk",+ "tableFrom": "issue",+ "tableTo": "issue",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_assignee_user_id_user_id_fk": {+ "name": "issue_assignee_user_id_user_id_fk",+ "tableFrom": "issue",+ "tableTo": "user",+ "columnsFrom": [+ "assignee_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_delegate_user_id_user_id_fk": {+ "name": "issue_delegate_user_id_user_id_fk",+ "tableFrom": "issue",+ "tableTo": "user",+ "columnsFrom": [+ "delegate_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_share_token_unique": {+ "name": "issue_share_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "share_token"+ ]+ },+ "issue_project_id_sequence_number_unique": {+ "name": "issue_project_id_sequence_number_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "sequence_number"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "issue_estimate_points_check": {+ "name": "issue_estimate_points_check",+ "value": "\"issue\".\"estimate_points\" >= 0"+ },+ "issue_estimate_minutes_check": {+ "name": "issue_estimate_minutes_check",+ "value": "\"issue\".\"estimate_minutes\" >= 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.issue_activity": {+ "name": "issue_activity",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "reply_to_id": {+ "name": "reply_to_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "actor_user_id": {+ "name": "actor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "actor_name": {+ "name": "actor_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "edited_at": {+ "name": "edited_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_activity_issue_idx": {+ "name": "issue_activity_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_activity_reply_idx": {+ "name": "issue_activity_reply_idx",+ "columns": [+ {+ "expression": "reply_to_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_activity_initiative_idx": {+ "name": "issue_activity_initiative_idx",+ "columns": [+ {+ "expression": "initiative_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_activity_issue_id_issue_id_fk": {+ "name": "issue_activity_issue_id_issue_id_fk",+ "tableFrom": "issue_activity",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_activity_initiative_id_initiative_id_fk": {+ "name": "issue_activity_initiative_id_initiative_id_fk",+ "tableFrom": "issue_activity",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_activity_reply_to_id_issue_activity_id_fk": {+ "name": "issue_activity_reply_to_id_issue_activity_id_fk",+ "tableFrom": "issue_activity",+ "tableTo": "issue_activity",+ "columnsFrom": [+ "reply_to_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_activity_actor_user_id_user_id_fk": {+ "name": "issue_activity_actor_user_id_user_id_fk",+ "tableFrom": "issue_activity",+ "tableTo": "user",+ "columnsFrom": [+ "actor_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "issue_activity_kind_check": {+ "name": "issue_activity_kind_check",+ "value": "\"issue_activity\".\"kind\" IN ('comment', 'activity')"+ },+ "issue_activity_owner_check": {+ "name": "issue_activity_owner_check",+ "value": "(\"issue_activity\".\"issue_id\" IS NOT NULL) <> (\"issue_activity\".\"initiative_id\" IS NOT NULL)"+ }+ },+ "isRLSEnabled": false+ },+ "public.issue_attachment": {+ "name": "issue_attachment",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "public_id": {+ "name": "public_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "s3_key": {+ "name": "s3_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "filename": {+ "name": "filename",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size_bytes": {+ "name": "size_bytes",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_attachment_issue_idx": {+ "name": "issue_attachment_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_attachment_issue_id_issue_id_fk": {+ "name": "issue_attachment_issue_id_issue_id_fk",+ "tableFrom": "issue_attachment",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_attachment_public_id_unique": {+ "name": "issue_attachment_public_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "public_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_checklist": {+ "name": "issue_checklist",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_checklist_issue_idx": {+ "name": "issue_checklist_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_checklist_issue_id_issue_id_fk": {+ "name": "issue_checklist_issue_id_issue_id_fk",+ "tableFrom": "issue_checklist",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_checklist_item": {+ "name": "issue_checklist_item",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "checklist_id": {+ "name": "checklist_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "done": {+ "name": "done",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_checklist_item_checklist_idx": {+ "name": "issue_checklist_item_checklist_idx",+ "columns": [+ {+ "expression": "checklist_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_checklist_item_checklist_id_issue_checklist_id_fk": {+ "name": "issue_checklist_item_checklist_id_issue_checklist_id_fk",+ "tableFrom": "issue_checklist_item",+ "tableTo": "issue_checklist",+ "columnsFrom": [+ "checklist_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_cycle": {+ "name": "issue_cycle",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "cycle_id": {+ "name": "cycle_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "entered_at": {+ "name": "entered_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "left_at": {+ "name": "left_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "issue_cycle_issue_idx": {+ "name": "issue_cycle_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "entered_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_cycle_cycle_idx": {+ "name": "issue_cycle_cycle_idx",+ "columns": [+ {+ "expression": "cycle_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_cycle_open_idx": {+ "name": "issue_cycle_open_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "cycle_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issue_cycle\".\"left_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_cycle_issue_id_issue_id_fk": {+ "name": "issue_cycle_issue_id_issue_id_fk",+ "tableFrom": "issue_cycle",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_cycle_cycle_id_cycle_id_fk": {+ "name": "issue_cycle_cycle_id_cycle_id_fk",+ "tableFrom": "issue_cycle",+ "tableTo": "cycle",+ "columnsFrom": [+ "cycle_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_development_check": {+ "name": "issue_development_check",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "development_link_id": {+ "name": "development_link_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "app_id": {+ "name": "app_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "head_sha": {+ "name": "head_sha",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_development_check_link_sha_idx": {+ "name": "issue_development_check_link_sha_idx",+ "columns": [+ {+ "expression": "development_link_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "head_sha",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_development_check_development_link_id_issue_development_link_id_fk": {+ "name": "issue_development_check_development_link_id_issue_development_link_id_fk",+ "tableFrom": "issue_development_check",+ "tableTo": "issue_development_link",+ "columnsFrom": [+ "development_link_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_development_check_development_link_id_app_id_name_unique": {+ "name": "issue_development_check_development_link_id_app_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "development_link_id",+ "app_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_development_link": {+ "name": "issue_development_link",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "repository": {+ "name": "repository",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pull_request'"+ },+ "external_key": {+ "name": "external_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "number": {+ "name": "number",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "state": {+ "name": "state",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "draft": {+ "name": "draft",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "source_branch": {+ "name": "source_branch",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "target_branch": {+ "name": "target_branch",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "head_sha": {+ "name": "head_sha",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "pipeline_status": {+ "name": "pipeline_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "pipeline_url": {+ "name": "pipeline_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_development_link_issue_idx": {+ "name": "issue_development_link_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_development_link_pr_idx": {+ "name": "issue_development_link_pr_idx",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "repository",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "number",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_development_link_sha_idx": {+ "name": "issue_development_link_sha_idx",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "repository",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "head_sha",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_development_link_issue_id_issue_id_fk": {+ "name": "issue_development_link_issue_id_issue_id_fk",+ "tableFrom": "issue_development_link",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_development_link_issue_id_provider_repository_external_key_unique": {+ "name": "issue_development_link_issue_id_provider_repository_external_key_unique",+ "nullsNotDistinct": false,+ "columns": [+ "issue_id",+ "provider",+ "repository",+ "external_key"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_field_option": {+ "name": "issue_field_option",+ "schema": "",+ "columns": {+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "field_id": {+ "name": "field_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "option_id": {+ "name": "option_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_field_option_issue_id_issue_id_fk": {+ "name": "issue_field_option_issue_id_issue_id_fk",+ "tableFrom": "issue_field_option",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_field_option_field_id_custom_field_id_fk": {+ "name": "issue_field_option_field_id_custom_field_id_fk",+ "tableFrom": "issue_field_option",+ "tableTo": "custom_field",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_field_option_option_id_custom_field_option_id_fk": {+ "name": "issue_field_option_option_id_custom_field_option_id_fk",+ "tableFrom": "issue_field_option",+ "tableTo": "custom_field_option",+ "columnsFrom": [+ "option_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_field_option_issue_id_field_id_option_id_pk": {+ "name": "issue_field_option_issue_id_field_id_option_id_pk",+ "columns": [+ "issue_id",+ "field_id",+ "option_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_field_value": {+ "name": "issue_field_value",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "field_id": {+ "name": "field_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "value_text": {+ "name": "value_text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "value_number": {+ "name": "value_number",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "value_bool": {+ "name": "value_bool",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "value_date": {+ "name": "value_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "value_datetime": {+ "name": "value_datetime",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "value_datetime_end": {+ "name": "value_datetime_end",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "value_user_id": {+ "name": "value_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_field_value_issue_id_issue_id_fk": {+ "name": "issue_field_value_issue_id_issue_id_fk",+ "tableFrom": "issue_field_value",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_field_value_field_id_custom_field_id_fk": {+ "name": "issue_field_value_field_id_custom_field_id_fk",+ "tableFrom": "issue_field_value",+ "tableTo": "custom_field",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_field_value_value_user_id_user_id_fk": {+ "name": "issue_field_value_value_user_id_user_id_fk",+ "tableFrom": "issue_field_value",+ "tableTo": "user",+ "columnsFrom": [+ "value_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_field_value_issue_id_field_id_unique": {+ "name": "issue_field_value_issue_id_field_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "issue_id",+ "field_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_import": {+ "name": "issue_import",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "public_id": {+ "name": "public_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "attachment_id": {+ "name": "attachment_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'mapped'"+ },+ "mapping": {+ "name": "mapping",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "error_text": {+ "name": "error_text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_import_project_idx": {+ "name": "issue_import_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_import_project_id_project_id_fk": {+ "name": "issue_import_project_id_project_id_fk",+ "tableFrom": "issue_import",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_import_attachment_id_chat_attachment_id_fk": {+ "name": "issue_import_attachment_id_chat_attachment_id_fk",+ "tableFrom": "issue_import",+ "tableTo": "chat_attachment",+ "columnsFrom": [+ "attachment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_import_public_id_unique": {+ "name": "issue_import_public_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "public_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_key_alias": {+ "name": "issue_key_alias",+ "schema": "",+ "columns": {+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "sequence_number": {+ "name": "sequence_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "issue_key_alias_issue_idx": {+ "name": "issue_key_alias_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_key_alias_project_id_project_id_fk": {+ "name": "issue_key_alias_project_id_project_id_fk",+ "tableFrom": "issue_key_alias",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_key_alias_issue_id_issue_id_fk": {+ "name": "issue_key_alias_issue_id_issue_id_fk",+ "tableFrom": "issue_key_alias",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_key_alias_project_id_sequence_number_pk": {+ "name": "issue_key_alias_project_id_sequence_number_pk",+ "columns": [+ "project_id",+ "sequence_number"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_label": {+ "name": "issue_label",+ "schema": "",+ "columns": {+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "label_id": {+ "name": "label_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_label_issue_id_issue_id_fk": {+ "name": "issue_label_issue_id_issue_id_fk",+ "tableFrom": "issue_label",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_label_label_id_label_id_fk": {+ "name": "issue_label_label_id_label_id_fk",+ "tableFrom": "issue_label",+ "tableTo": "label",+ "columnsFrom": [+ "label_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_label_issue_id_label_id_pk": {+ "name": "issue_label_issue_id_label_id_pk",+ "columns": [+ "issue_id",+ "label_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_link": {+ "name": "issue_link",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "source_issue_id": {+ "name": "source_issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "target_issue_id": {+ "name": "target_issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_link_pair_kind_idx": {+ "name": "issue_link_pair_kind_idx",+ "columns": [+ {+ "expression": "least(\"source_issue_id\", \"target_issue_id\")",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ },+ {+ "expression": "greatest(\"source_issue_id\", \"target_issue_id\")",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ },+ {+ "expression": "kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_link_source_idx": {+ "name": "issue_link_source_idx",+ "columns": [+ {+ "expression": "source_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_link_target_idx": {+ "name": "issue_link_target_idx",+ "columns": [+ {+ "expression": "target_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_link_source_issue_id_issue_id_fk": {+ "name": "issue_link_source_issue_id_issue_id_fk",+ "tableFrom": "issue_link",+ "tableTo": "issue",+ "columnsFrom": [+ "source_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_link_target_issue_id_issue_id_fk": {+ "name": "issue_link_target_issue_id_issue_id_fk",+ "tableFrom": "issue_link",+ "tableTo": "issue",+ "columnsFrom": [+ "target_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "issue_link_kind_check": {+ "name": "issue_link_kind_check",+ "value": "\"issue_link\".\"kind\" IN ('blocks', 'relates', 'duplicates')"+ },+ "issue_link_self_check": {+ "name": "issue_link_self_check",+ "value": "\"issue_link\".\"source_issue_id\" <> \"issue_link\".\"target_issue_id\""+ }+ },+ "isRLSEnabled": false+ },+ "public.issue_status": {+ "name": "issue_status",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "column_id": {+ "name": "column_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "column_name": {+ "name": "column_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "state_type": {+ "name": "state_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "entered_at": {+ "name": "entered_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "left_at": {+ "name": "left_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "issue_status_issue_idx": {+ "name": "issue_status_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "entered_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_status_column_idx": {+ "name": "issue_status_column_idx",+ "columns": [+ {+ "expression": "column_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue_status\".\"column_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_status_open_idx": {+ "name": "issue_status_open_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issue_status\".\"left_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_status_issue_id_issue_id_fk": {+ "name": "issue_status_issue_id_issue_id_fk",+ "tableFrom": "issue_status",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_status_column_id_project_column_id_fk": {+ "name": "issue_status_column_id_project_column_id_fk",+ "tableFrom": "issue_status",+ "tableTo": "project_column",+ "columnsFrom": [+ "column_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_template": {+ "name": "issue_template",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "title_template": {+ "name": "title_template",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "description_template": {+ "name": "description_template",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "type_id": {+ "name": "type_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "column_id": {+ "name": "column_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "priority": {+ "name": "priority",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_user_id": {+ "name": "assignee_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_template_project_id_project_id_fk": {+ "name": "issue_template_project_id_project_id_fk",+ "tableFrom": "issue_template",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_template_type_id_issue_type_id_fk": {+ "name": "issue_template_type_id_issue_type_id_fk",+ "tableFrom": "issue_template",+ "tableTo": "issue_type",+ "columnsFrom": [+ "type_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_template_column_id_project_column_id_fk": {+ "name": "issue_template_column_id_project_column_id_fk",+ "tableFrom": "issue_template",+ "tableTo": "project_column",+ "columnsFrom": [+ "column_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_template_assignee_user_id_user_id_fk": {+ "name": "issue_template_assignee_user_id_user_id_fk",+ "tableFrom": "issue_template",+ "tableTo": "user",+ "columnsFrom": [+ "assignee_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_template_project_id_name_unique": {+ "name": "issue_template_project_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_template_label": {+ "name": "issue_template_label",+ "schema": "",+ "columns": {+ "template_id": {+ "name": "template_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "label_id": {+ "name": "label_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_template_label_template_id_issue_template_id_fk": {+ "name": "issue_template_label_template_id_issue_template_id_fk",+ "tableFrom": "issue_template_label",+ "tableTo": "issue_template",+ "columnsFrom": [+ "template_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_template_label_label_id_label_id_fk": {+ "name": "issue_template_label_label_id_label_id_fk",+ "tableFrom": "issue_template_label",+ "tableTo": "label",+ "columnsFrom": [+ "label_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_template_label_template_id_label_id_pk": {+ "name": "issue_template_label_template_id_label_id_pk",+ "columns": [+ "template_id",+ "label_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_type": {+ "name": "issue_type",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "is_default": {+ "name": "is_default",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_type_project_id_project_id_fk": {+ "name": "issue_type_project_id_project_id_fk",+ "tableFrom": "issue_type",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_type_project_id_name_unique": {+ "name": "issue_type_project_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_watcher": {+ "name": "issue_watcher",+ "schema": "",+ "columns": {+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "subscribed": {+ "name": "subscribed",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_watcher_issue_id_issue_id_fk": {+ "name": "issue_watcher_issue_id_issue_id_fk",+ "tableFrom": "issue_watcher",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_watcher_user_id_user_id_fk": {+ "name": "issue_watcher_user_id_user_id_fk",+ "tableFrom": "issue_watcher",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_watcher_issue_id_user_id_pk": {+ "name": "issue_watcher_issue_id_user_id_pk",+ "columns": [+ "issue_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_worklog": {+ "name": "issue_worklog",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "minutes": {+ "name": "minutes",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "spent_on": {+ "name": "spent_on",+ "type": "date",+ "primaryKey": false,+ "notNull": true+ },+ "note": {+ "name": "note",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_worklog_issue_idx": {+ "name": "issue_worklog_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "spent_on",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_worklog_issue_id_issue_id_fk": {+ "name": "issue_worklog_issue_id_issue_id_fk",+ "tableFrom": "issue_worklog",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_worklog_user_id_user_id_fk": {+ "name": "issue_worklog_user_id_user_id_fk",+ "tableFrom": "issue_worklog",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "issue_worklog_minutes_check": {+ "name": "issue_worklog_minutes_check",+ "value": "\"issue_worklog\".\"minutes\" > 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.label": {+ "name": "label",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "group_id": {+ "name": "group_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "label_project_id_project_id_fk": {+ "name": "label_project_id_project_id_fk",+ "tableFrom": "label",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "label_group_id_label_group_id_fk": {+ "name": "label_group_id_label_group_id_fk",+ "tableFrom": "label",+ "tableTo": "label_group",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "label_project_id_name_unique": {+ "name": "label_project_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.label_group": {+ "name": "label_group",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "label_group_project_id_project_id_fk": {+ "name": "label_group_project_id_project_id_fk",+ "tableFrom": "label_group",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "label_group_project_id_name_unique": {+ "name": "label_group_project_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.model_price": {+ "name": "model_price",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "input": {+ "name": "input",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true+ },+ "output": {+ "name": "output",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true+ },+ "cache_read": {+ "name": "cache_read",+ "type": "double precision",+ "primaryKey": false,+ "notNull": false+ },+ "cache_write": {+ "name": "cache_write",+ "type": "double precision",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "model_price_workspace_id_workspace_id_fk": {+ "name": "model_price_workspace_id_workspace_id_fk",+ "tableFrom": "model_price",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "model_price_workspace_id_provider_model_unique": {+ "name": "model_price_workspace_id_provider_model_unique",+ "nullsNotDistinct": false,+ "columns": [+ "workspace_id",+ "provider",+ "model"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "model_price_rates_check": {+ "name": "model_price_rates_check",+ "value": "\"model_price\".\"input\" >= 0 AND \"model_price\".\"output\" >= 0 AND coalesce(\"model_price\".\"cache_read\", 0) >= 0 AND coalesce(\"model_price\".\"cache_write\", 0) >= 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.note_board": {+ "name": "note_board",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "canvas": {+ "name": "canvas",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "note_board_project_idx": {+ "name": "note_board_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "note_board_project_id_project_id_fk": {+ "name": "note_board_project_id_project_id_fk",+ "tableFrom": "note_board",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "note_board_owner_user_id_user_id_fk": {+ "name": "note_board_owner_user_id_user_id_fk",+ "tableFrom": "note_board",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "note_board_created_by_user_id_user_id_fk": {+ "name": "note_board_created_by_user_id_user_id_fk",+ "tableFrom": "note_board",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.note_board_member": {+ "name": "note_board_member",+ "schema": "",+ "columns": {+ "board_id": {+ "name": "board_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "note_board_member_user_idx": {+ "name": "note_board_member_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "note_board_member_board_id_note_board_id_fk": {+ "name": "note_board_member_board_id_note_board_id_fk",+ "tableFrom": "note_board_member",+ "tableTo": "note_board",+ "columnsFrom": [+ "board_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "note_board_member_user_id_user_id_fk": {+ "name": "note_board_member_user_id_user_id_fk",+ "tableFrom": "note_board_member",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "note_board_member_board_id_user_id_pk": {+ "name": "note_board_member_board_id_user_id_pk",+ "columns": [+ "board_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.notification": {+ "name": "notification",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "source_activity_id": {+ "name": "source_activity_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "document_comment_id": {+ "name": "document_comment_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_user_id": {+ "name": "actor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "actor_name": {+ "name": "actor_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "read_at": {+ "name": "read_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "snoozed_until": {+ "name": "snoozed_until",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "notification_user_idx": {+ "name": "notification_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "notification_user_unread_idx": {+ "name": "notification_user_unread_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notification\".\"read_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "notification_issue_idx": {+ "name": "notification_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notification\".\"issue_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "notification_source_activity_idx": {+ "name": "notification_source_activity_idx",+ "columns": [+ {+ "expression": "source_activity_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notification\".\"source_activity_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "notification_user_id_user_id_fk": {+ "name": "notification_user_id_user_id_fk",+ "tableFrom": "notification",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notification_project_id_project_id_fk": {+ "name": "notification_project_id_project_id_fk",+ "tableFrom": "notification",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notification_issue_id_issue_id_fk": {+ "name": "notification_issue_id_issue_id_fk",+ "tableFrom": "notification",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notification_source_activity_id_issue_activity_id_fk": {+ "name": "notification_source_activity_id_issue_activity_id_fk",+ "tableFrom": "notification",+ "tableTo": "issue_activity",+ "columnsFrom": [+ "source_activity_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "notification_document_id_project_document_id_fk": {+ "name": "notification_document_id_project_document_id_fk",+ "tableFrom": "notification",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notification_document_comment_id_document_comment_id_fk": {+ "name": "notification_document_comment_id_document_comment_id_fk",+ "tableFrom": "notification",+ "tableTo": "document_comment",+ "columnsFrom": [+ "document_comment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "notification_actor_user_id_user_id_fk": {+ "name": "notification_actor_user_id_user_id_fk",+ "tableFrom": "notification",+ "tableTo": "user",+ "columnsFrom": [+ "actor_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "notification_type_check": {+ "name": "notification_type_check",+ "value": "\"notification\".\"type\" IN ('assigned', 'mentioned', 'commented', 'state_changed')"+ },+ "notification_target_check": {+ "name": "notification_target_check",+ "value": "(\"notification\".\"issue_id\" IS NULL) <> (\"notification\".\"document_id\" IS NULL)"+ }+ },+ "isRLSEnabled": false+ },+ "public.notification_delivery": {+ "name": "notification_delivery",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "channel": {+ "name": "channel",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "recipient": {+ "name": "recipient",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "notification_delivery_due_idx": {+ "name": "notification_delivery_due_idx",+ "columns": [+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notification_delivery\".\"status\" = 'pending'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "notification_delivery_project_id_project_id_fk": {+ "name": "notification_delivery_project_id_project_id_fk",+ "tableFrom": "notification_delivery",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "notification_delivery_channel_check": {+ "name": "notification_delivery_channel_check",+ "value": "\"notification_delivery\".\"channel\" IN ('email', 'telegram')"+ }+ },+ "isRLSEnabled": false+ },+ "public.project": {+ "name": "project",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "next_sequence": {+ "name": "next_sequence",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "mcp_enabled": {+ "name": "mcp_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "initiatives_enabled": {+ "name": "initiatives_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "dashboards_enabled": {+ "name": "dashboards_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "documents_enabled": {+ "name": "documents_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "notes_enabled": {+ "name": "notes_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "cycles_enabled": {+ "name": "cycles_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "subtasks_enabled": {+ "name": "subtasks_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "checklists_enabled": {+ "name": "checklists_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "issue_stats_enabled": {+ "name": "issue_stats_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "points_estimate_enabled": {+ "name": "points_estimate_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "time_estimate_enabled": {+ "name": "time_estimate_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "time_logging_enabled": {+ "name": "time_logging_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_team_id_team_id_fk": {+ "name": "project_team_id_team_id_fk",+ "tableFrom": "project",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "project_team_key_uq": {+ "name": "project_team_key_uq",+ "nullsNotDistinct": false,+ "columns": [+ "team_id",+ "key"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_action": {+ "name": "project_action",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "condition": {+ "name": "condition",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "effect": {+ "name": "effect",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_action_project_idx": {+ "name": "project_action_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_action_project_id_project_id_fk": {+ "name": "project_action_project_id_project_id_fk",+ "tableFrom": "project_action",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_column": {+ "name": "project_column",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "state_type": {+ "name": "state_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'unstarted'"+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "wip_limit": {+ "name": "wip_limit",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "wip_mode": {+ "name": "wip_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'soft'"+ },+ "auto_assign_user_id": {+ "name": "auto_assign_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_column_project_id_project_id_fk": {+ "name": "project_column_project_id_project_id_fk",+ "tableFrom": "project_column",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_column_auto_assign_user_id_user_id_fk": {+ "name": "project_column_auto_assign_user_id_user_id_fk",+ "tableFrom": "project_column",+ "tableTo": "user",+ "columnsFrom": [+ "auto_assign_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "project_column_project_id_position_unique": {+ "name": "project_column_project_id_position_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "position"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "project_column_state_type_check": {+ "name": "project_column_state_type_check",+ "value": "\"project_column\".\"state_type\" IN ('backlog', 'unstarted', 'started', 'completed', 'canceled')"+ },+ "project_column_wip_mode_check": {+ "name": "project_column_wip_mode_check",+ "value": "\"project_column\".\"wip_mode\" IN ('soft', 'hard')"+ },+ "project_column_wip_limit_check": {+ "name": "project_column_wip_limit_check",+ "value": "\"project_column\".\"wip_limit\" IS NULL OR \"project_column\".\"wip_limit\" > 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.project_dashboard": {+ "name": "project_dashboard",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "layout": {+ "name": "layout",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_dashboard_project_idx": {+ "name": "project_dashboard_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_dashboard_project_id_project_id_fk": {+ "name": "project_dashboard_project_id_project_id_fk",+ "tableFrom": "project_dashboard",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_document": {+ "name": "project_document",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "parent_id": {+ "name": "parent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "content_json": {+ "name": "content_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "full_width": {+ "name": "full_width",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_private": {+ "name": "is_private",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_locked": {+ "name": "is_locked",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "archived_by_ancestor_id": {+ "name": "archived_by_ancestor_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by_user_id": {+ "name": "updated_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_document_project_tree_idx": {+ "name": "project_document_project_tree_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_document_owner_idx": {+ "name": "project_document_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_document_project_archive_idx": {+ "name": "project_document_project_archive_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "archived_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_document_project_id_project_id_fk": {+ "name": "project_document_project_id_project_id_fk",+ "tableFrom": "project_document",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_parent_id_project_document_id_fk": {+ "name": "project_document_parent_id_project_document_id_fk",+ "tableFrom": "project_document",+ "tableTo": "project_document",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_document_archived_by_ancestor_id_project_document_id_fk": {+ "name": "project_document_archived_by_ancestor_id_project_document_id_fk",+ "tableFrom": "project_document",+ "tableTo": "project_document",+ "columnsFrom": [+ "archived_by_ancestor_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_document_owner_user_id_user_id_fk": {+ "name": "project_document_owner_user_id_user_id_fk",+ "tableFrom": "project_document",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_document_created_by_user_id_user_id_fk": {+ "name": "project_document_created_by_user_id_user_id_fk",+ "tableFrom": "project_document",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_document_updated_by_user_id_user_id_fk": {+ "name": "project_document_updated_by_user_id_user_id_fk",+ "tableFrom": "project_document",+ "tableTo": "user",+ "columnsFrom": [+ "updated_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "project_document_version_check": {+ "name": "project_document_version_check",+ "value": "\"project_document\".\"version\" > 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.project_document_initiative": {+ "name": "project_document_initiative",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_document_initiative_initiative_idx": {+ "name": "project_document_initiative_initiative_idx",+ "columns": [+ {+ "expression": "initiative_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_document_initiative_document_id_project_document_id_fk": {+ "name": "project_document_initiative_document_id_project_document_id_fk",+ "tableFrom": "project_document_initiative",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_initiative_initiative_id_initiative_id_fk": {+ "name": "project_document_initiative_initiative_id_initiative_id_fk",+ "tableFrom": "project_document_initiative",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_initiative_created_by_user_id_user_id_fk": {+ "name": "project_document_initiative_created_by_user_id_user_id_fk",+ "tableFrom": "project_document_initiative",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_document_initiative_document_id_initiative_id_pk": {+ "name": "project_document_initiative_document_id_initiative_id_pk",+ "columns": [+ "document_id",+ "initiative_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_document_issue": {+ "name": "project_document_issue",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_document_issue_issue_idx": {+ "name": "project_document_issue_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_document_issue_document_id_project_document_id_fk": {+ "name": "project_document_issue_document_id_project_document_id_fk",+ "tableFrom": "project_document_issue",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_issue_issue_id_issue_id_fk": {+ "name": "project_document_issue_issue_id_issue_id_fk",+ "tableFrom": "project_document_issue",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_issue_created_by_user_id_user_id_fk": {+ "name": "project_document_issue_created_by_user_id_user_id_fk",+ "tableFrom": "project_document_issue",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_document_issue_document_id_issue_id_pk": {+ "name": "project_document_issue_document_id_issue_id_pk",+ "columns": [+ "document_id",+ "issue_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_document_preference": {+ "name": "project_document_preference",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "is_favorite": {+ "name": "is_favorite",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_document_preference_user_idx": {+ "name": "project_document_preference_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_document_preference_document_id_project_document_id_fk": {+ "name": "project_document_preference_document_id_project_document_id_fk",+ "tableFrom": "project_document_preference",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_preference_user_id_user_id_fk": {+ "name": "project_document_preference_user_id_user_id_fk",+ "tableFrom": "project_document_preference",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_document_preference_document_id_user_id_pk": {+ "name": "project_document_preference_document_id_user_id_pk",+ "columns": [+ "document_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_document_revision": {+ "name": "project_document_revision",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "parent_id": {+ "name": "parent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_json": {+ "name": "content_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "full_width": {+ "name": "full_width",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_private": {+ "name": "is_private",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_locked": {+ "name": "is_locked",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_document_revision_document_idx": {+ "name": "project_document_revision_document_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "version",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_document_revision_document_id_project_document_id_fk": {+ "name": "project_document_revision_document_id_project_document_id_fk",+ "tableFrom": "project_document_revision",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_revision_owner_user_id_user_id_fk": {+ "name": "project_document_revision_owner_user_id_user_id_fk",+ "tableFrom": "project_document_revision",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_document_revision_created_by_user_id_user_id_fk": {+ "name": "project_document_revision_created_by_user_id_user_id_fk",+ "tableFrom": "project_document_revision",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "project_document_revision_document_version_unique": {+ "name": "project_document_revision_document_version_unique",+ "nullsNotDistinct": false,+ "columns": [+ "document_id",+ "version"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_member": {+ "name": "project_member",+ "schema": "",+ "columns": {+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "role_id": {+ "name": "role_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'invite'"+ },+ "is_favorite": {+ "name": "is_favorite",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_hidden": {+ "name": "is_hidden",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_member_user_idx": {+ "name": "project_member_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_member_project_id_project_id_fk": {+ "name": "project_member_project_id_project_id_fk",+ "tableFrom": "project_member",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_member_user_id_user_id_fk": {+ "name": "project_member_user_id_user_id_fk",+ "tableFrom": "project_member",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_member_role_id_team_role_id_fk": {+ "name": "project_member_role_id_team_role_id_fk",+ "tableFrom": "project_member",+ "tableTo": "team_role",+ "columnsFrom": [+ "role_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_member_project_id_user_id_pk": {+ "name": "project_member_project_id_user_id_pk",+ "columns": [+ "project_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "project_member_role_check": {+ "name": "project_member_role_check",+ "value": "\"project_member\".\"role\" IN ('owner', 'member')"+ },+ "project_member_source_check": {+ "name": "project_member_source_check",+ "value": "\"project_member\".\"source\" IN ('invite', 'scim')"+ }+ },+ "isRLSEnabled": false+ },+ "public.project_setting": {+ "name": "project_setting",+ "schema": "",+ "columns": {+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_setting_project_id_project_id_fk": {+ "name": "project_setting_project_id_project_id_fk",+ "tableFrom": "project_setting",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_setting_project_id_key_pk": {+ "name": "project_setting_project_id_key_pk",+ "columns": [+ "project_id",+ "key"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_template": {+ "name": "project_template",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "snapshot": {+ "name": "snapshot",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "all_teams": {+ "name": "all_teams",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "publication_id": {+ "name": "publication_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "publication_url": {+ "name": "publication_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "published_at": {+ "name": "published_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_template_workspace_idx": {+ "name": "project_template_workspace_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_template_workspace_id_workspace_id_fk": {+ "name": "project_template_workspace_id_workspace_id_fk",+ "tableFrom": "project_template",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_template_team": {+ "name": "project_template_team",+ "schema": "",+ "columns": {+ "template_id": {+ "name": "template_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "project_template_team_team_idx": {+ "name": "project_template_team_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_template_team_template_id_project_template_id_fk": {+ "name": "project_template_team_template_id_project_template_id_fk",+ "tableFrom": "project_template_team",+ "tableTo": "project_template",+ "columnsFrom": [+ "template_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_template_team_team_id_team_id_fk": {+ "name": "project_template_team_team_id_team_id_fk",+ "tableFrom": "project_template_team",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_template_team_template_id_team_id_pk": {+ "name": "project_template_team_template_id_team_id_pk",+ "columns": [+ "template_id",+ "team_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_view": {+ "name": "project_view",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "filters": {+ "name": "filters",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "display": {+ "name": "display",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "share_token": {+ "name": "share_token",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "share_extended": {+ "name": "share_extended",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "share_expires_at": {+ "name": "share_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "is_private": {+ "name": "is_private",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_view_project_idx": {+ "name": "project_view_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_view_owner_idx": {+ "name": "project_view_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_view_project_id_project_id_fk": {+ "name": "project_view_project_id_project_id_fk",+ "tableFrom": "project_view",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_view_owner_user_id_user_id_fk": {+ "name": "project_view_owner_user_id_user_id_fk",+ "tableFrom": "project_view",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "project_view_share_token_unique": {+ "name": "project_view_share_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "share_token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "project_view_private_owner_check": {+ "name": "project_view_private_owner_check",+ "value": "\"project_view\".\"is_private\" = (\"project_view\".\"owner_user_id\" is not null)"+ }+ },+ "isRLSEnabled": false+ },+ "public.project_view_favorite": {+ "name": "project_view_favorite",+ "schema": "",+ "columns": {+ "view_id": {+ "name": "view_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_view_favorite_view_id_project_view_id_fk": {+ "name": "project_view_favorite_view_id_project_view_id_fk",+ "tableFrom": "project_view_favorite",+ "tableTo": "project_view",+ "columnsFrom": [+ "view_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_view_favorite_user_id_user_id_fk": {+ "name": "project_view_favorite_user_id_user_id_fk",+ "tableFrom": "project_view_favorite",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_view_favorite_view_id_user_id_pk": {+ "name": "project_view_favorite_view_id_user_id_pk",+ "columns": [+ "view_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_view_preference": {+ "name": "project_view_preference",+ "schema": "",+ "columns": {+ "view_id": {+ "name": "view_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "is_hidden": {+ "name": "is_hidden",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_view_preference_view_id_project_view_id_fk": {+ "name": "project_view_preference_view_id_project_view_id_fk",+ "tableFrom": "project_view_preference",+ "tableTo": "project_view",+ "columnsFrom": [+ "view_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_view_preference_user_id_user_id_fk": {+ "name": "project_view_preference_user_id_user_id_fk",+ "tableFrom": "project_view_preference",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_view_preference_view_id_user_id_pk": {+ "name": "project_view_preference_view_id_user_id_pk",+ "columns": [+ "view_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.revision": {+ "name": "revision",+ "schema": "",+ "columns": {+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "rev": {+ "name": "rev",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ }+ },+ "indexes": {+ "revision_project_idx": {+ "name": "revision_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.team": {+ "name": "team",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "slug": {+ "name": "slug",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "mcp_enabled": {+ "name": "mcp_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "default_agent_ids": {+ "name": "default_agent_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "team_workspace_idx": {+ "name": "team_workspace_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "team_workspace_id_workspace_id_fk": {+ "name": "team_workspace_id_workspace_id_fk",+ "tableFrom": "team",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "team_slug_unique": {+ "name": "team_slug_unique",+ "nullsNotDistinct": false,+ "columns": [+ "slug"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.team_invite": {+ "name": "team_invite",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "team_role": {+ "name": "team_role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "project_role": {+ "name": "project_role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "role_id": {+ "name": "role_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "invited_by_user_id": {+ "name": "invited_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accepted_by_user_id": {+ "name": "accepted_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "responded_at": {+ "name": "responded_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "team_invite_team_pending_uq": {+ "name": "team_invite_team_pending_uq",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "email",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"team_invite\".\"status\" = 'pending' AND \"team_invite\".\"project_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "team_invite_project_pending_uq": {+ "name": "team_invite_project_pending_uq",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "email",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"team_invite\".\"status\" = 'pending' AND \"team_invite\".\"project_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "team_invite_team_idx": {+ "name": "team_invite_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "team_invite_project_idx": {+ "name": "team_invite_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "team_invite_team_id_team_id_fk": {+ "name": "team_invite_team_id_team_id_fk",+ "tableFrom": "team_invite",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "team_invite_project_id_project_id_fk": {+ "name": "team_invite_project_id_project_id_fk",+ "tableFrom": "team_invite",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "team_invite_role_id_team_role_id_fk": {+ "name": "team_invite_role_id_team_role_id_fk",+ "tableFrom": "team_invite",+ "tableTo": "team_role",+ "columnsFrom": [+ "role_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "team_invite_invited_by_user_id_user_id_fk": {+ "name": "team_invite_invited_by_user_id_user_id_fk",+ "tableFrom": "team_invite",+ "tableTo": "user",+ "columnsFrom": [+ "invited_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "team_invite_accepted_by_user_id_user_id_fk": {+ "name": "team_invite_accepted_by_user_id_user_id_fk",+ "tableFrom": "team_invite",+ "tableTo": "user",+ "columnsFrom": [+ "accepted_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "team_invite_token_unique": {+ "name": "team_invite_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "team_invite_team_role_check": {+ "name": "team_invite_team_role_check",+ "value": "\"team_invite\".\"team_role\" IN ('owner', 'manager', 'member')"+ },+ "team_invite_project_role_check": {+ "name": "team_invite_project_role_check",+ "value": "(\"team_invite\".\"project_id\" IS NULL AND \"team_invite\".\"project_role\" IS NULL)\n OR (\"team_invite\".\"project_id\" IS NOT NULL AND \"team_invite\".\"project_role\" IN ('owner', 'member'))"+ },+ "team_invite_status_check": {+ "name": "team_invite_status_check",+ "value": "\"team_invite\".\"status\" IN ('pending', 'accepted', 'rejected')"+ }+ },+ "isRLSEnabled": false+ },+ "public.team_member": {+ "name": "team_member",+ "schema": "",+ "columns": {+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'invite'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "team_member_user_idx": {+ "name": "team_member_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "team_member_team_id_team_id_fk": {+ "name": "team_member_team_id_team_id_fk",+ "tableFrom": "team_member",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "team_member_user_id_user_id_fk": {+ "name": "team_member_user_id_user_id_fk",+ "tableFrom": "team_member",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "team_member_team_id_user_id_pk": {+ "name": "team_member_team_id_user_id_pk",+ "columns": [+ "team_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "team_member_role_check": {+ "name": "team_member_role_check",+ "value": "\"team_member\".\"role\" IN ('owner', 'manager', 'member', 'agent')"+ },+ "team_member_source_check": {+ "name": "team_member_source_check",+ "value": "\"team_member\".\"source\" IN ('invite', 'scim')"+ }+ },+ "isRLSEnabled": false+ },+ "public.team_notification_setting": {+ "name": "team_notification_setting",+ "schema": "",+ "columns": {+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true+ },+ "ciphertext": {+ "name": "ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "iv": {+ "name": "iv",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "auth_tag": {+ "name": "auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "redacted": {+ "name": "redacted",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "team_notification_setting_team_id_team_id_fk": {+ "name": "team_notification_setting_team_id_team_id_fk",+ "tableFrom": "team_notification_setting",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.team_role": {+ "name": "team_role",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "is_default": {+ "name": "is_default",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "permissions": {+ "name": "permissions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "team_role_system_name_uq": {+ "name": "team_role_system_name_uq",+ "columns": [+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"team_role\".\"team_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "team_role_system_default_uq": {+ "name": "team_role_system_default_uq",+ "columns": [+ {+ "expression": "is_default",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"team_role\".\"team_id\" IS NULL AND \"team_role\".\"is_default\"",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "team_role_team_idx": {+ "name": "team_role_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "team_role_team_id_team_id_fk": {+ "name": "team_role_team_id_team_id_fk",+ "tableFrom": "team_role",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "team_role_team_id_name_unique": {+ "name": "team_role_team_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "team_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "team_role_default_system_check": {+ "name": "team_role_default_system_check",+ "value": "\"team_role\".\"team_id\" IS NULL OR NOT \"team_role\".\"is_default\""+ }+ },+ "isRLSEnabled": false+ },+ "public.template_publisher": {+ "name": "template_publisher",+ "schema": "",+ "columns": {+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "key_ciphertext": {+ "name": "key_ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "key_iv": {+ "name": "key_iv",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "key_auth_tag": {+ "name": "key_auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "author_name": {+ "name": "author_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "author_url": {+ "name": "author_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "template_publisher_workspace_id_workspace_id_fk": {+ "name": "template_publisher_workspace_id_workspace_id_fk",+ "tableFrom": "template_publisher",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_notification_preference": {+ "name": "user_notification_preference",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "email_events": {+ "name": "email_events",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "telegram_events": {+ "name": "telegram_events",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "user_notification_preference_user_id_user_id_fk": {+ "name": "user_notification_preference_user_id_user_id_fk",+ "tableFrom": "user_notification_preference",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_notification_preference_project_id_project_id_fk": {+ "name": "user_notification_preference_project_id_project_id_fk",+ "tableFrom": "user_notification_preference",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "user_notification_pref_user_project_unique": {+ "name": "user_notification_pref_user_project_unique",+ "nullsNotDistinct": false,+ "columns": [+ "user_id",+ "project_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_preference": {+ "name": "user_preference",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "timezone": {+ "name": "timezone",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'UTC'"+ },+ "locale": {+ "name": "locale",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'en'"+ },+ "theme": {+ "name": "theme",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'system'"+ },+ "issue_open_mode": {+ "name": "issue_open_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'panel'"+ },+ "start_page": {+ "name": "start_page",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'work-items'"+ },+ "show_chat_by_default": {+ "name": "show_chat_by_default",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "issue_stats_open": {+ "name": "issue_stats_open",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "issue_stats_view": {+ "name": "issue_stats_view",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'compact'"+ },+ "issue_activity_view": {+ "name": "issue_activity_view",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'flat'"+ },+ "auto_watch": {+ "name": "auto_watch",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "hotkeys": {+ "name": "hotkeys",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "last_project_id": {+ "name": "last_project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "seen_version": {+ "name": "seen_version",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "user_preference_user_id_user_id_fk": {+ "name": "user_preference_user_id_user_id_fk",+ "tableFrom": "user_preference",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_preference_last_project_id_project_id_fk": {+ "name": "user_preference_last_project_id_project_id_fk",+ "tableFrom": "user_preference",+ "tableTo": "project",+ "columnsFrom": [+ "last_project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "user_preference_theme_check": {+ "name": "user_preference_theme_check",+ "value": "\"user_preference\".\"theme\" IN ('light', 'dark', 'system')"+ },+ "user_preference_issue_open_mode_check": {+ "name": "user_preference_issue_open_mode_check",+ "value": "\"user_preference\".\"issue_open_mode\" IN ('panel', 'page')"+ },+ "user_preference_start_page_check": {+ "name": "user_preference_start_page_check",+ "value": "\"user_preference\".\"start_page\" IN ('inbox', 'dashboard', 'work-items', 'initiatives')"+ },+ "user_preference_issue_stats_view_check": {+ "name": "user_preference_issue_stats_view_check",+ "value": "\"user_preference\".\"issue_stats_view\" IN ('compact', 'timeline')"+ },+ "user_preference_issue_activity_view_check": {+ "name": "user_preference_issue_activity_view_check",+ "value": "\"user_preference\".\"issue_activity_view\" IN ('flat', 'grouped')"+ }+ },+ "isRLSEnabled": false+ },+ "public.user_telegram_account": {+ "name": "user_telegram_account",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "chat_id": {+ "name": "chat_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "username": {+ "name": "username",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "first_name": {+ "name": "first_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "link_code": {+ "name": "link_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "link_code_expires_at": {+ "name": "link_code_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "linked_at": {+ "name": "linked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_telegram_account_chat_id_unique": {+ "name": "user_telegram_account_chat_id_unique",+ "columns": [+ {+ "expression": "chat_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"user_telegram_account\".\"chat_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_telegram_account_link_code_unique": {+ "name": "user_telegram_account_link_code_unique",+ "columns": [+ {+ "expression": "link_code",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"user_telegram_account\".\"link_code\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_telegram_account_user_id_user_id_fk": {+ "name": "user_telegram_account_user_id_user_id_fk",+ "tableFrom": "user_telegram_account",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.webhook": {+ "name": "webhook",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "secret": {+ "name": "secret",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "events": {+ "name": "events",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "is_active": {+ "name": "is_active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "consecutive_failures": {+ "name": "consecutive_failures",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "webhook_project_idx": {+ "name": "webhook_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "webhook_project_id_project_id_fk": {+ "name": "webhook_project_id_project_id_fk",+ "tableFrom": "webhook",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.webhook_delivery": {+ "name": "webhook_delivery",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "webhook_id": {+ "name": "webhook_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "event_id": {+ "name": "event_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "event_type": {+ "name": "event_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "response_status": {+ "name": "response_status",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "response_body": {+ "name": "response_body",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "webhook_delivery_due_idx": {+ "name": "webhook_delivery_due_idx",+ "columns": [+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"webhook_delivery\".\"status\" = 'pending'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "webhook_delivery_webhook_idx": {+ "name": "webhook_delivery_webhook_idx",+ "columns": [+ {+ "expression": "webhook_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "webhook_delivery_webhook_id_webhook_id_fk": {+ "name": "webhook_delivery_webhook_id_webhook_id_fk",+ "tableFrom": "webhook_delivery",+ "tableTo": "webhook",+ "columnsFrom": [+ "webhook_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.workspace": {+ "name": "workspace",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "team_creation": {+ "name": "team_creation",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'owner'"+ },+ "max_concurrent_runs": {+ "name": "max_concurrent_runs",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "workspace_team_creation_check": {+ "name": "workspace_team_creation_check",+ "value": "\"workspace\".\"team_creation\" IN ('owner', 'managers', 'members')"+ },+ "workspace_max_concurrent_runs_check": {+ "name": "workspace_max_concurrent_runs_check",+ "value": "\"workspace\".\"max_concurrent_runs\" >= 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.workspace_manager": {+ "name": "workspace_manager",+ "schema": "",+ "columns": {+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'admin'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "workspace_manager_owner_uq": {+ "name": "workspace_manager_owner_uq",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"workspace_manager\".\"role\" = 'owner'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_manager_user_idx": {+ "name": "workspace_manager_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "workspace_manager_workspace_id_workspace_id_fk": {+ "name": "workspace_manager_workspace_id_workspace_id_fk",+ "tableFrom": "workspace_manager",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "workspace_manager_user_id_user_id_fk": {+ "name": "workspace_manager_user_id_user_id_fk",+ "tableFrom": "workspace_manager",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "workspace_manager_workspace_id_user_id_pk": {+ "name": "workspace_manager_workspace_id_user_id_pk",+ "columns": [+ "workspace_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "workspace_manager_role_check": {+ "name": "workspace_manager_role_check",+ "value": "\"workspace_manager\".\"role\" IN ('owner', 'admin')"+ }+ },+ "isRLSEnabled": false+ },+ "public.scim_group": {+ "name": "scim_group",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "display_name": {+ "name": "display_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "scim_group_instance_display_name_uq": {+ "name": "scim_group_instance_display_name_uq",+ "columns": [+ {+ "expression": "display_name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"scim_group\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "scim_group_workspace_id_workspace_id_fk": {+ "name": "scim_group_workspace_id_workspace_id_fk",+ "tableFrom": "scim_group",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "scim_group_workspace_id_display_name_unique": {+ "name": "scim_group_workspace_id_display_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "workspace_id",+ "display_name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.scim_group_mapping": {+ "name": "scim_group_mapping",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "group_id": {+ "name": "group_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "role_id": {+ "name": "role_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "scim_group_mapping_project_idx": {+ "name": "scim_group_mapping_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "scim_group_mapping_group_id_scim_group_id_fk": {+ "name": "scim_group_mapping_group_id_scim_group_id_fk",+ "tableFrom": "scim_group_mapping",+ "tableTo": "scim_group",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "scim_group_mapping_project_id_project_id_fk": {+ "name": "scim_group_mapping_project_id_project_id_fk",+ "tableFrom": "scim_group_mapping",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "scim_group_mapping_role_id_team_role_id_fk": {+ "name": "scim_group_mapping_role_id_team_role_id_fk",+ "tableFrom": "scim_group_mapping",+ "tableTo": "team_role",+ "columnsFrom": [+ "role_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "scim_group_mapping_group_id_project_id_unique": {+ "name": "scim_group_mapping_group_id_project_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "group_id",+ "project_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "scim_group_mapping_role_check": {+ "name": "scim_group_mapping_role_check",+ "value": "\"scim_group_mapping\".\"role\" IN ('owner', 'member')"+ }+ },+ "isRLSEnabled": false+ },+ "public.scim_group_member": {+ "name": "scim_group_member",+ "schema": "",+ "columns": {+ "group_id": {+ "name": "group_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "scim_group_member_user_idx": {+ "name": "scim_group_member_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "scim_group_member_group_id_scim_group_id_fk": {+ "name": "scim_group_member_group_id_scim_group_id_fk",+ "tableFrom": "scim_group_member",+ "tableTo": "scim_group",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "scim_group_member_user_id_user_id_fk": {+ "name": "scim_group_member_user_id_user_id_fk",+ "tableFrom": "scim_group_member",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "scim_group_member_group_id_user_id_pk": {+ "name": "scim_group_member_group_id_user_id_pk",+ "columns": [+ "group_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.scim_user": {+ "name": "scim_user",+ "schema": "",+ "columns": {+ "workspace_id": {+ "name": "workspace_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "active": {+ "name": "active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "scim_user_instance_user_uq": {+ "name": "scim_user_instance_user_uq",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"scim_user\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "scim_user_user_idx": {+ "name": "scim_user_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "scim_user_workspace_id_workspace_id_fk": {+ "name": "scim_user_workspace_id_workspace_id_fk",+ "tableFrom": "scim_user",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "scim_user_user_id_user_id_fk": {+ "name": "scim_user_user_id_user_id_fk",+ "tableFrom": "scim_user",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "scim_user_workspace_id_user_id_unique": {+ "name": "scim_user_workspace_id_user_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "workspace_id",+ "user_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ }+ },+ "enums": {},+ "schemas": {},+ "sequences": {},+ "roles": {},+ "policies": {},+ "views": {},+ "_meta": {+ "columns": {},+ "schemas": {},+ "tables": {}+ }+}\ No newline at end of filediff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.jsonindex 3778816e..a53ee204 100644--- a/packages/db/drizzle/meta/_journal.json+++ b/packages/db/drizzle/meta/_journal.json@@ -1205,6 +1205,20 @@"when": 1793626954039,"tag": "0171_share_expiry","breakpoints": true+ },+ {+ "idx": 172,+ "version": "7",+ "when": 1793703498898,+ "tag": "0172_workspace_project_templates",+ "breakpoints": true+ },+ {+ "idx": 173,+ "version": "7",+ "when": 1793713887371,+ "tag": "0173_template_gallery",+ "breakpoints": true}]}\ No newline at end of filediff --git a/packages/db/src/schema/app.ts b/packages/db/src/schema/app.tsindex ac677852..a0cefbee 100644--- a/packages/db/src/schema/app.ts+++ b/packages/db/src/schema/app.ts@@ -194,15 +194,71 @@ export const project = pgTable(// When set, the project is archived: read-only, left out of the members' project// lists, and its agent schedules do not run. Its rows are kept and it can be restored.archivedAt: timestamp('archived_at', { withTimezone: true }),- // A project template of the team: a saved copy of a project's configuration that new- // projects are created from. It has no members and is left out of every project list,- // so nobody works in it.- isTemplate: boolean('is_template').notNull().default(false),createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),},(t) => [unique('project_team_key_uq').on(t.teamId, t.key)],);+// A project template of a workspace: a snapshot of a project's configuration, without+// its issues, that new projects of its teams are created from. The snapshot's shape is+// ProjectSnapshot in the api (modules/projects/copy.ts). With all_teams off, only the+// teams in project_template_team see it. The flag is explicit so that a deleted team+// does not open a limited template to the whole workspace.+export const projectTemplate = pgTable(+ 'project_template',+ {+ id: serial('id').primaryKey(),+ workspaceId: integer('workspace_id')+ .notNull()+ .references(() => workspace.id, { onDelete: 'cascade' }),+ name: text('name').notNull(),+ description: text('description').notNull().default(''),+ snapshot: jsonb('snapshot').notNull(),+ allTeams: boolean('all_teams').notNull().default(true),+ // The template's page in the gallery at itsaplan.dev, NULL while it is not published.+ publicationId: text('publication_id'),+ publicationUrl: text('publication_url'),+ publishedAt: timestamp('published_at', { withTimezone: true }),+ createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),+ },+ (t) => [index('project_template_workspace_idx').on(t.workspaceId)],+);++// The teams a project template is limited to when its all_teams is off.+export const projectTemplateTeam = pgTable(+ 'project_template_team',+ {+ templateId: integer('template_id')+ .notNull()+ .references(() => projectTemplate.id, { onDelete: 'cascade' }),+ teamId: integer('team_id')+ .notNull()+ .references(() => team.id, { onDelete: 'cascade' }),+ },+ (t) => [+ primaryKey({ columns: [t.templateId, t.teamId] }),+ index('project_template_team_team_idx').on(t.teamId),+ ],+);++// The gallery publisher a workspace publishes its project templates under: the email it+// confirmed with a code, and the key the gallery issued for it. The key is read back for+// every publish, so it is kept encrypted rather than hashed. The author is the name the+// gallery shows on every template of the address; the workspace keeps a copy to show in+// its dialogs and refuses a publish until it is set.+export const templatePublisher = pgTable('template_publisher', {+ workspaceId: integer('workspace_id')+ .primaryKey()+ .references(() => workspace.id, { onDelete: 'cascade' }),+ email: text('email').notNull(),+ keyCiphertext: text('key_ciphertext').notNull(),+ keyIv: text('key_iv').notNull(),+ keyAuthTag: text('key_auth_tag').notNull(),+ authorName: text('author_name').notNull().default(''),+ authorUrl: text('author_url'),+ createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),+});+// Per-project key-value settings, mirroring app_setting but scoped to a project.// The value is a jsonb blob owned by whatever feature reads the key, so one table// backs many project settings (e.g. auto-archive thresholds under key