Skip to content

⭐️⭐️⭐️ 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.

feat: add cycles (sprints) (#98)

Croff82d2b7847b40
diff --git a/apps/api/src/ai-agents/issue-query.ts b/apps/api/src/ai-agents/issue-query.ts
index 7c2cbf66..57f187b7 100644
--- a/apps/api/src/ai-agents/issue-query.ts
+++ b/apps/api/src/ai-agents/issue-query.ts
@@ -22,6 +22,11 @@ export const issueQuerySchema = z.object({
.describe(
'Exact initiative id from list_initiatives, or null for issues without an initiative.',
),
+ cycleId: z
+ .number()
+ .nullable()
+ .optional()
+ .describe('Exact cycle id from list_cycles, or null for issues outside any cycle.'),
parentId: z
.number()
.nullable()
diff --git a/apps/api/src/ai-agents/runtime/tools/catalog.ts b/apps/api/src/ai-agents/runtime/tools/catalog.ts
index c01ba184..7246e4d5 100644
--- a/apps/api/src/ai-agents/runtime/tools/catalog.ts
+++ b/apps/api/src/ai-agents/runtime/tools/catalog.ts
@@ -46,7 +46,7 @@ export const AGENT_ACTIONS: ToolMeta[] = [
key: 'update_issue',
label: 'Update issues',
description:
- "Change an issue's state, type, initiative, assignee, delegate, details, priority, dates, or labels.",
+ "Change an issue's state, type, initiative, cycle, assignee, delegate, details, priority, dates, or labels.",
always: false,
},
{
@@ -109,6 +109,30 @@ export const AGENT_ACTIONS: ToolMeta[] = [
description: 'Permanently delete initiatives.',
always: false,
},
+ {
+ key: 'create_cycle',
+ label: 'Create cycles',
+ description: 'Create cycles in the project.',
+ always: false,
+ },
+ {
+ key: 'update_cycle',
+ label: 'Update cycles',
+ description: 'Change a cycle’s name, description, and dates.',
+ always: false,
+ },
+ {
+ key: 'delete_cycle',
+ label: 'Delete cycles',
+ description: 'Permanently delete cycles. Their issues stay, without a cycle.',
+ always: false,
+ },
+ {
+ key: 'transfer_cycle_issues',
+ label: 'Transfer cycle issues',
+ description: "Move a cycle's unfinished issues to another cycle, or off any cycle.",
+ always: false,
+ },
{
key: 'list_note_boards',
label: 'List note boards',
@@ -213,6 +237,18 @@ export const ALWAYS_ON_ACTIONS: ToolMeta[] = [
description: 'View one initiative with its progress and health.',
always: true,
},
+ {
+ key: 'list_cycles',
+ label: 'List cycles',
+ description: 'View the cycles of the project with their progress.',
+ always: true,
+ },
+ {
+ key: 'get_cycle',
+ label: 'Read a cycle',
+ description: 'View one cycle with its dates and progress.',
+ always: true,
+ },
];
const ACTION_KEYS = new Set(AGENT_ACTIONS.map((t) => t.key));
diff --git a/apps/api/src/app.ts b/apps/api/src/app.ts
index f828c9ec..91db4004 100644
--- a/apps/api/src/app.ts
+++ b/apps/api/src/app.ts
@@ -72,6 +72,7 @@ export const app = new Elysia()
name: 'Initiatives',
description: 'Initiatives (issue groupings) and their activity feed',
},
+ { name: 'Cycles', description: 'Cycles (time-boxed periods of work) and their issues' },
{ name: 'Attachments', description: 'Issue attachments and raw bytes' },
{ name: 'Avatars', description: "Current user's avatar image (upload and raw bytes)" },
{ name: 'Views', description: 'Saved work items views' },
diff --git a/apps/api/src/cycles/__tests__/integration/cycles.test.ts b/apps/api/src/cycles/__tests__/integration/cycles.test.ts
new file mode 100644
index 00000000..2cf1dc1c
--- /dev/null
+++ b/apps/api/src/cycles/__tests__/integration/cycles.test.ts
@@ -0,0 +1,475 @@
+import { describe, it, expect, beforeEach } from 'bun:test';
+import { authedApi, type Api } from '../../../__tests__/helpers/app';
+import { signUpTestUser } from '../../../__tests__/helpers/auth';
+import { resetDb } from '../../../__tests__/helpers/db';
+
+// Cycles are time-boxed periods of work inside a project (sprints). Issues link to
+// one through issue.cycleId. The status (upcoming/active/completed) follows from the
+// dates against today and progress from the linked issues' states — neither is
+// stored. Cycles of one project may not overlap, so at most one is ever active.
+
+// Dates relative to today, so a cycle's derived status does not depend on when the
+// suite runs.
+function day(offset: number): string {
+ const d = new Date();
+ d.setUTCDate(d.getUTCDate() + offset);
+ return d.toISOString().slice(0, 10);
+}
+
+async function setup() {
+ const owner = await signUpTestUser({ name: 'Owner' });
+ const asOwner = authedApi(owner.cookie);
+ await asOwner.projects.post({ key: 'MKT', name: 'Marketing' });
+ const view = await asOwner.projects({ projectKey: 'MKT' }).get();
+ const columns = view.data!.columns;
+ return {
+ owner,
+ asOwner,
+ columnId: columns[0].id,
+ startedColumnId: columns.find((c) => c.stateType === 'started')!.id,
+ doneColumnId: columns.find((c) => c.stateType === 'completed')!.id,
+ };
+}
+
+const cycles = (api: Api) => api.projects({ projectKey: 'MKT' }).cycles;
+
+function createCycle(api: Api, body: Record<string, unknown>) {
+ return cycles(api).post({ name: 'Sprint 1', startDate: day(0), endDate: day(6), ...body });
+}
+
+function createIssue(api: Api, columnId: number, body: Record<string, unknown> = {}) {
+ return api.projects({ projectKey: 'MKT' }).issues.post({ title: 'Task', columnId, ...body });
+}
+
+describe('cycles', () => {
+ beforeEach(async () => {
+ await resetDb();
+ });
+
+ describe('create', () => {
+ it('creates a cycle and lists it', async () => {
+ const { asOwner } = await setup();
+ const created = await createCycle(asOwner, { name: 'Sprint 1', goal: 'Ship the beta' });
+ expect(created.status).toBe(201);
+ expect(created.data).toMatchObject({
+ name: 'Sprint 1',
+ goal: 'Ship the beta',
+ status: 'active',
+ progress: { completed: 0, canceled: 0, total: 0 },
+ });
+
+ const list = await cycles(asOwner).get();
+ expect(list.data!.map((c) => c.name)).toEqual(['Sprint 1']);
+ });
+
+ it('derives the status from the dates', async () => {
+ const { asOwner } = await setup();
+ const past = await createCycle(asOwner, { startDate: day(-14), endDate: day(-8) });
+ const current = await createCycle(asOwner, { startDate: day(-1), endDate: day(5) });
+ const future = await createCycle(asOwner, { startDate: day(10), endDate: day(16) });
+
+ expect(past.data!.status).toBe('completed');
+ expect(current.data!.status).toBe('active');
+ expect(future.data!.status).toBe('upcoming');
+ });
+
+ it('lists cycles oldest first', async () => {
+ const { asOwner } = await setup();
+ await createCycle(asOwner, { name: 'Later', startDate: day(10), endDate: day(16) });
+ await createCycle(asOwner, { name: 'Earlier', startDate: day(0), endDate: day(6) });
+
+ const list = await cycles(asOwner).get();
+ expect(list.data!.map((c) => c.name)).toEqual(['Earlier', 'Later']);
+ });
+
+ it('rejects an empty name', async () => {
+ const { asOwner } = await setup();
+ expect((await createCycle(asOwner, { name: '' })).status).toBe(400);
+ });
+
+ it('rejects a date that is not YYYY-MM-DD', async () => {
+ const { asOwner } = await setup();
+ expect((await createCycle(asOwner, { startDate: '01.02.2026' })).status).toBe(400);
+ });
+
+ it('rejects an end date before the start date', async () => {
+ const { asOwner } = await setup();
+ const res = await createCycle(asOwner, { startDate: day(6), endDate: day(0) });
+ expect(res.status).toBe(400);
+ });
+
+ it('accepts a cycle that starts and ends on the same day', async () => {
+ const { asOwner } = await setup();
+ expect((await createCycle(asOwner, { startDate: day(3), endDate: day(3) })).status).toBe(201);
+ });
+
+ it('rejects dates that overlap another cycle', async () => {
+ const { asOwner } = await setup();
+ await createCycle(asOwner, { startDate: day(0), endDate: day(6) });
+
+ const overlapping = await createCycle(asOwner, { startDate: day(6), endDate: day(12) });
+ expect(overlapping.status).toBe(400);
+
+ const adjacent = await createCycle(asOwner, { startDate: day(7), endDate: day(13) });
+ expect(adjacent.status).toBe(201);
+ });
+
+ it('allows the same dates in another project', async () => {
+ const { asOwner } = await setup();
+ await createCycle(asOwner, { startDate: day(0), endDate: day(6) });
+ await asOwner.projects.post({ key: 'OPS', name: 'Operations' });
+
+ const other = await asOwner
+ .projects({ projectKey: 'OPS' })
+ .cycles.post({ name: 'Sprint 1', startDate: day(0), endDate: day(6) });
+ expect(other.status).toBe(201);
+ });
+ });
+
+ describe('list', () => {
+ // Two finished cycles, one running, one ahead — enough to tell the planned list
+ // and the archive apart, and to page the archive.
+ async function fourCycles(api: Api) {
+ await createCycle(api, { name: 'Old', startDate: day(-21), endDate: day(-15) });
+ await createCycle(api, { name: 'Last', startDate: day(-14), endDate: day(-8) });
+ await createCycle(api, { name: 'Current', startDate: day(-1), endDate: day(5) });
+ await createCycle(api, { name: 'Next', startDate: day(10), endDate: day(16) });
+ }
+
+ it('leaves the finished cycles out of the planned list', async () => {
+ const { asOwner } = await setup();
+ await fourCycles(asOwner);
+
+ const planned = await cycles(asOwner).get({ query: { status: 'planned' } });
+ expect(planned.data!.map((c) => c.name)).toEqual(['Current', 'Next']);
+ });
+
+ it('lists the finished cycles newest first, with how many there are', async () => {
+ const { asOwner } = await setup();
+ await fourCycles(asOwner);
+
+ const archive = await cycles(asOwner).completed.get({ query: {} });
+ expect(archive.data!.total).toBe(2);
+ expect(archive.data!.items.map((c) => c.name)).toEqual(['Last', 'Old']);
+ });
+
+ it('pages the finished cycles', async () => {
+ const { asOwner } = await setup();
+ await fourCycles(asOwner);
+
+ const first = await cycles(asOwner).completed.get({ query: { pageSize: 1 } });
+ expect(first.data).toMatchObject({ total: 2, page: 1, pageSize: 1 });
+ expect(first.data!.items.map((c) => c.name)).toEqual(['Last']);
+
+ const second = await cycles(asOwner).completed.get({ query: { page: 2, pageSize: 1 } });
+ expect(second.data!.items.map((c) => c.name)).toEqual(['Old']);
+
+ const past = await cycles(asOwner).completed.get({ query: { page: 3, pageSize: 1 } });
+ expect(past.data!.items).toEqual([]);
+ expect(past.data!.total).toBe(2);
+ });
+
+ it('reports an empty archive when nothing has finished', async () => {
+ const { asOwner } = await setup();
+ await createCycle(asOwner, { startDate: day(0), endDate: day(6) });
+
+ const archive = await cycles(asOwner).completed.get({ query: {} });
+ expect(archive.data).toMatchObject({ total: 0, items: [] });
+ });
+
+ it('rejects a page or page size outside its bounds', async () => {
+ const { asOwner } = await setup();
+ expect((await cycles(asOwner).completed.get({ query: { pageSize: 0 } })).status).toBe(400);
+ expect((await cycles(asOwner).completed.get({ query: { pageSize: 101 } })).status).toBe(400);
+ expect((await cycles(asOwner).completed.get({ query: { page: 0 } })).status).toBe(400);
+ });
+
+ it('denies a non-member the archive', async () => {
+ await setup();
+ const outsider = authedApi((await signUpTestUser()).cookie);
+ const res = await outsider
+ .projects({ projectKey: 'MKT' })
+ .cycles.completed.get({ query: {} });
+ expect(res.status).toBe(403);
+ });
+ });
+
+ describe('progress', () => {
+ it('counts the linked issues by their state type', async () => {
+ const { asOwner, columnId, startedColumnId, doneColumnId } = await setup();
+ const cycle = (await createCycle(asOwner, {})).data!;
+ await createIssue(asOwner, columnId, { cycleId: cycle.id });
+ await createIssue(asOwner, startedColumnId, { cycleId: cycle.id });
+ await createIssue(asOwner, doneColumnId, { cycleId: cycle.id });
+ await createIssue(asOwner, columnId);
+
+ const read = await asOwner.cycles({ cycleId: cycle.id }).get();
+ expect(read.data!.progress).toMatchObject({ total: 3, completed: 1, canceled: 0 });
+ });
+ });
+
+ describe('update', () => {
+ it('moves both dates of an upcoming cycle', async () => {
+ const { asOwner } = await setup();
+ const cycle = (await createCycle(asOwner, { startDate: day(10), endDate: day(16) })).data!;
+
+ const res = await asOwner
+ .cycles({ cycleId: cycle.id })
+ .patch({ name: 'Sprint 2', startDate: day(20), endDate: day(26) });
+ expect(res.status).toBe(200);
+ expect(res.data).toMatchObject({ name: 'Sprint 2', status: 'upcoming' });
+ });
+
+ // What a cycle is called and what it is for describe the work, so they stay
+ // editable whatever state its dates put it in; the dates themselves do not.
+ it('keeps the start date of a running cycle and lets its end move', async () => {
+ const { asOwner } = await setup();
+ const running = (await createCycle(asOwner, { startDate: day(-1), endDate: day(5) })).data!;
+
+ const moved = await asOwner.cycles({ cycleId: running.id }).patch({ startDate: day(0) });
+ expect(moved.status).toBe(400);
+
+ const extended = await asOwner.cycles({ cycleId: running.id }).patch({ endDate: day(9) });
+ expect(extended.status).toBe(200);
+ expect(extended.data).toMatchObject({ status: 'active' });
+
+ const renamed = await asOwner
+ .cycles({ cycleId: running.id })
+ .patch({ name: 'Renamed', goal: 'Ship it' });
+ expect(renamed.status).toBe(200);
+ });
+
+ it('keeps both dates of a completed cycle', async () => {
+ const { asOwner } = await setup();
+ const past = (await createCycle(asOwner, { startDate: day(-14), endDate: day(-8) })).data!;
+
+ expect((await asOwner.cycles({ cycleId: past.id }).patch({ endDate: day(-7) })).status).toBe(
+ 400,
+ );
+ expect(
+ (await asOwner.cycles({ cycleId: past.id }).patch({ startDate: day(-13) })).status,
+ ).toBe(400);
+ expect(
+ (await asOwner.cycles({ cycleId: past.id }).patch({ name: 'Q2 wrap-up' })).status,
+ ).toBe(200);
+ });
+
+ // The form sends every field on save, so re-sending the dates a cycle already has
+ // is not an attempt to move them.
+ it('accepts a save that resends the unchanged dates of a completed cycle', async () => {
+ const { asOwner } = await setup();
+ const past = (await createCycle(asOwner, { startDate: day(-14), endDate: day(-8) })).data!;
+
+ const res = await asOwner
+ .cycles({ cycleId: past.id })
+ .patch({ name: 'Sprint 0', goal: 'Set up', startDate: day(-14), endDate: day(-8) });
+ expect(res.status).toBe(200);
+ expect(res.data).toMatchObject({ name: 'Sprint 0', goal: 'Set up' });
+ });
+
+ it('rejects new dates that overlap another cycle', async () => {
+ const { asOwner } = await setup();
+ await createCycle(asOwner, { startDate: day(0), endDate: day(6) });
+ const second = (await createCycle(asOwner, { startDate: day(7), endDate: day(13) })).data!;
+
+ const res = await asOwner.cycles({ cycleId: second.id }).patch({ startDate: day(6) });
+ expect(res.status).toBe(400);
+ });
+
+ it('keeps its own dates out of the overlap check', async () => {
+ const { asOwner } = await setup();
+ const cycle = (await createCycle(asOwner, {})).data!;
+ const res = await asOwner.cycles({ cycleId: cycle.id }).patch({ name: 'Renamed' });
+ expect(res.status).toBe(200);
+ });
+
+ it('404s on an unknown cycle', async () => {
+ const { asOwner } = await setup();
+ expect((await asOwner.cycles({ cycleId: 999999 }).patch({ name: 'x' })).status).toBe(404);
+ });
+ });
+
+ describe('delete', () => {
+ it('deletes the cycle and leaves its issues without one', async () => {
+ const { asOwner, columnId } = await setup();
+ const cycle = (await createCycle(asOwner, {})).data!;
+ const issue = (await createIssue(asOwner, columnId, { cycleId: cycle.id })).data!;
+
+ expect((await asOwner.cycles({ cycleId: cycle.id }).delete()).status).toBe(204);
+ expect((await cycles(asOwner).get()).data).toHaveLength(0);
+ expect((await asOwner.issues({ issueId: issue.id }).get()).data!.cycle).toBeNull();
+ });
+ });
+
+ describe('issue link', () => {
+ it('plans an issue into a cycle and unplans it', async () => {
+ const { asOwner, columnId } = await setup();
+ const cycle = (await createCycle(asOwner, {})).data!;
+ const issue = (await createIssue(asOwner, columnId, { cycleId: cycle.id })).data!;
+ expect(issue.cycle).toMatchObject({ id: cycle.id, name: 'Sprint 1' });
+
+ const cleared = await asOwner.issues({ issueId: issue.id }).patch({ cycleId: null });
+ expect(cleared.data!.cycle).toBeNull();
+ });
+
+ it('rejects a cycle from another project', async () => {
+ const { asOwner, columnId } = await setup();
+ await asOwner.projects.post({ key: 'OPS', name: 'Operations' });
+ const foreign = (
+ await asOwner
+ .projects({ projectKey: 'OPS' })
+ .cycles.post({ name: 'Other', startDate: day(0), endDate: day(6) })
+ ).data!;
+
+ const res = await createIssue(asOwner, columnId, { cycleId: foreign.id });
+ expect(res.status).toBe(400);
+ });
+
+ it('rejects a completed cycle', async () => {
+ const { asOwner, columnId } = await setup();
+ const past = (await createCycle(asOwner, { startDate: day(-14), endDate: day(-8) })).data!;
+
+ expect((await createIssue(asOwner, columnId, { cycleId: past.id })).status).toBe(400);
+
+ const issue = (await createIssue(asOwner, columnId)).data!;
+ const res = await asOwner.issues({ issueId: issue.id }).patch({ cycleId: past.id });
+ expect(res.status).toBe(400);
+ expect((await asOwner.issues({ issueId: issue.id }).get()).data!.cycle).toBeNull();
+ });
+
+ it('keeps an issue on the cycle it was planned into once that cycle ends', async () => {
+ const { asOwner, columnId } = await setup();
+ const cycle = (await createCycle(asOwner, { startDate: day(-5), endDate: day(6) })).data!;
+ const issue = (await createIssue(asOwner, columnId, { cycleId: cycle.id })).data!;
+ await asOwner.cycles({ cycleId: cycle.id }).patch({ endDate: day(-1) });
+
+ const renamed = await asOwner.issues({ issueId: issue.id }).patch({ title: 'Still planned' });
+ expect(renamed.status).toBe(200);
+ expect(renamed.data!.cycle).toMatchObject({ id: cycle.id });
+
+ const resent = await asOwner.issues({ issueId: issue.id }).patch({ cycleId: cycle.id });
+ expect(resent.status).toBe(200);
+
+ const cleared = await asOwner.issues({ issueId: issue.id }).patch({ cycleId: null });
+ expect(cleared.data!.cycle).toBeNull();
+ });
+
+ it('filters the issue list by cycle', async () => {
+ const { asOwner, columnId } = await setup();
+ const cycle = (await createCycle(asOwner, {})).data!;
+ await createIssue(asOwner, columnId, { title: 'Planned', cycleId: cycle.id });
+ await createIssue(asOwner, columnId, { title: 'Unplanned' });
+
+ const res = await asOwner
+ .projects({ projectKey: 'MKT' })
+ .issues.get({ query: { cycleId: cycle.id } });
+ expect(res.data!.map((i) => i.title)).toEqual(['Planned']);
+ });
+ });
+
+ describe('transfer', () => {
+ it('moves the unfinished issues and leaves the finished ones', async () => {
+ const { asOwner, columnId, doneColumnId } = await setup();
+ const from = (await createCycle(asOwner, {})).data!;
+ const to = (await createCycle(asOwner, { startDate: day(10), endDate: day(16) })).data!;
+ const open = (await createIssue(asOwner, columnId, { cycleId: from.id })).data!;
+ const done = (await createIssue(asOwner, doneColumnId, { cycleId: from.id })).data!;
+
+ const res = await asOwner
+ .cycles({ cycleId: from.id })
+ .transfer.post({ targetCycleId: to.id });
+ expect(res.status).toBe(200);
+ expect(res.data).toMatchObject({ moved: 1 });
+ expect((await asOwner.issues({ issueId: open.id }).get()).data!.cycle).toMatchObject({
+ id: to.id,
+ });
+ expect((await asOwner.issues({ issueId: done.id }).get()).data!.cycle).toMatchObject({
+ id: from.id,
+ });
+ });
+
+ it('unplans the unfinished issues when the target is null', async () => {
+ const { asOwner, columnId } = await setup();
+ const cycle = (await createCycle(asOwner, {})).data!;
+ const issue = (await createIssue(asOwner, columnId, { cycleId: cycle.id })).data!;
+
+ const res = await asOwner
+ .cycles({ cycleId: cycle.id })
+ .transfer.post({ targetCycleId: null });
+ expect(res.data).toMatchObject({ moved: 1 });
+ expect((await asOwner.issues({ issueId: issue.id }).get()).data!.cycle).toBeNull();
+ });
+
+ it('rejects the cycle itself as the target', async () => {
+ const { asOwner } = await setup();
+ const cycle = (await createCycle(asOwner, {})).data!;
+ const res = await asOwner
+ .cycles({ cycleId: cycle.id })
+ .transfer.post({ targetCycleId: cycle.id });
+ expect(res.status).toBe(400);
+ });
+
+ it('rejects a completed target cycle', async () => {
+ const { asOwner, columnId } = await setup();
+ const cycle = (await createCycle(asOwner, {})).data!;
+ const past = (await createCycle(asOwner, { startDate: day(-14), endDate: day(-8) })).data!;
+ const issue = (await createIssue(asOwner, columnId, { cycleId: cycle.id })).data!;
+
+ const res = await asOwner
+ .cycles({ cycleId: cycle.id })
+ .transfer.post({ targetCycleId: past.id });
+ expect(res.status).toBe(400);
+ expect((await asOwner.issues({ issueId: issue.id }).get()).data!.cycle).toMatchObject({
+ id: cycle.id,
+ });
+ });
+
+ it('rejects a target cycle from another project', async () => {
+ const { asOwner } = await setup();
+ const cycle = (await createCycle(asOwner, {})).data!;
+ await asOwner.projects.post({ key: 'OPS', name: 'Operations' });
+ const foreign = (
+ await asOwner
+ .projects({ projectKey: 'OPS' })
+ .cycles.post({ name: 'Other', startDate: day(0), endDate: day(6) })
+ ).data!;
+
+ const res = await asOwner
+ .cycles({ cycleId: cycle.id })
+ .transfer.post({ targetCycleId: foreign.id });
+ expect(res.status).toBe(400);
+ });
+ });
+
+ describe('access', () => {
+ it('returns 404 for an unknown project', async () => {
+ const { asOwner } = await setup();
+ const res = await asOwner
+ .projects({ projectKey: 'NOPE' })
+ .cycles.post({ name: 'x', startDate: day(0), endDate: day(6) });
+ expect(res.status).toBe(404);
+ });
+
+ it('denies a non-member on the cycle routes', async () => {
+ const { asOwner } = await setup();
+ const cycle = (await createCycle(asOwner, {})).data!;
+ const outsider = authedApi((await signUpTestUser()).cookie);
+
+ expect(
+ (
+ await outsider
+ .projects({ projectKey: 'MKT' })
+ .cycles.post({ name: 'x', startDate: day(0), endDate: day(6) })
+ ).status,
+ ).toBe(403);
+ expect((await outsider.projects({ projectKey: 'MKT' }).cycles.get()).status).toBe(403);
+ expect((await outsider.cycles({ cycleId: cycle.id }).get()).status).toBe(403);
+ expect((await outsider.cycles({ cycleId: cycle.id }).patch({ name: 'x' })).status).toBe(403);
+ expect(
+ (await outsider.cycles({ cycleId: cycle.id }).transfer.post({ targetCycleId: null }))
+ .status,
+ ).toBe(403);
+ expect((await outsider.cycles({ cycleId: cycle.id }).delete()).status).toBe(403);
+ });
+ });
+});
diff --git a/apps/api/src/cycles/routes.ts b/apps/api/src/cycles/routes.ts
new file mode 100644
index 00000000..1f251bf9
--- /dev/null
+++ b/apps/api/src/cycles/routes.ts
@@ -0,0 +1,276 @@
+import { Elysia, t } from 'elysia';
+import { mcpTool } from '../mcp/generate';
+import { noContent } from '../shared/http';
+import { guards, entityGuard } from '../shared/guards';
+import { authContext } from '../shared/auth-context';
+import { requireUser } from '../shared/access';
+import { HttpError } from '../shared/lib';
+import { ErrorResponse } from '../shared/responses';
+import { transferCycleIssues } from '../issues/store';
+import {
+ listCycles,
+ listPlannedCycles,
+ listCompletedCycles,
+ getCycle,
+ getCycleProjectId,
+ createCycle,
+ updateCycle,
+ deleteCycle,
+} from './store';
+
+const cycleParams = t.Object({ cycleId: t.Numeric() });
+
+const IsoDate = t.String({
+ pattern: '^\\d{4}-\\d{2}-\\d{2}$',
+ description: "Date 'YYYY-MM-DD'.",
+});
+
+// CycleRow from the store. status follows from the dates against today (upcoming /
+// active / completed) and progress is derived issue counts; neither is stored.
+const CycleResponse = t.Object({
+ id: t.Number(),
+ projectId: t.Number(),
+ name: t.String(),
+ goal: t.String(),
+ startDate: t.String(),
+ endDate: t.String(),
+ status: t.String(),
+ createdAt: t.String(),
+ updatedAt: t.String(),
+ progress: t.Object({ completed: t.Number(), canceled: t.Number(), total: t.Number() }),
+});
+
+export const cycleRoutes = new Elysia({
+ name: 'cycles',
+ detail: { tags: ['Cycles'] },
+})
+ .use(authContext)
+ .use(guards)
+ // Guard for routes that address a cycle by its own id (no :projectKey in the
+ // path). Set `cycle: "<action>"` in the route options.
+ .macro({
+ cycle: entityGuard('cycles', 'Cycle not found', (p) => getCycleProjectId(Number(p.cycleId))),
+ })
+
+ .get(
+ '/projects/:projectKey/cycles',
+ async ({ project, query }) =>
+ query.status === 'planned' ? listPlannedCycles(project.id) : listCycles(project.id),
+ {
+ params: t.Object({ projectKey: t.String() }),
+ query: t.Object({
+ status: t.Optional(
+ t.Literal('planned', {
+ description: 'Only the cycles that have not finished: active and upcoming.',
+ }),
+ ),
+ }),
+ permission: ['cycles', 'read'],
+ response: {
+ 200: t.Array(CycleResponse),
+ 400: ErrorResponse,
+ 401: ErrorResponse,
+ 403: ErrorResponse,
+ 404: ErrorResponse,
+ },
+ detail: {
+ summary: 'List cycles',
+ description: "A project's cycles, oldest first.",
+ ...mcpTool('list_cycles'),
+ },
+ },
+ )
+
+ .get(
+ '/projects/:projectKey/cycles/completed',
+ async ({ project, query }) => {
+ const page = query.page ?? 1;
+ const pageSize = query.pageSize ?? 25;
+ const { items, total } = await listCompletedCycles(project.id, {
+ limit: pageSize,
+ offset: (page - 1) * pageSize,
+ });
+ return { items, total, page, pageSize };
+ },
+ {
+ params: t.Object({ projectKey: t.String() }),
+ query: t.Object({
+ page: t.Optional(t.Numeric({ minimum: 1, description: '1-based page. Default 1.' })),
+ pageSize: t.Optional(
+ t.Numeric({
+ minimum: 1,
+ maximum: 100,
+ description: 'Items per page (1-100). Default 25.',
+ }),
+ ),
+ }),
+ permission: ['cycles', 'read'],
+ response: {
+ 200: t.Object({
+ items: t.Array(CycleResponse),
+ total: t.Number(),
+ page: t.Number(),
+ pageSize: t.Number(),
+ }),
+ 400: ErrorResponse,
+ 401: ErrorResponse,
+ 403: ErrorResponse,
+ 404: ErrorResponse,
+ },
+ detail: {
+ summary: 'List completed cycles',
+ description: "A page of a project's finished cycles, newest first.",
+ },
+ },
+ )
+
+ .post(
+ '/projects/:projectKey/cycles',
+ async ({ project, body, set }) => {
+ set.status = 201;
+ return createCycle(project.id, body);
+ },
+ {
+ params: t.Object({ projectKey: t.String() }),
+ body: t.Object({
+ name: t.String({ minLength: 1, description: 'Cycle name.' }),
+ goal: t.Optional(t.String({ description: 'What the team commits to in this cycle.' })),
+ startDate: IsoDate,
+ endDate: IsoDate,
+ }),
+ permission: ['cycles', 'create'],
+ response: {
+ 201: CycleResponse,
+ 400: ErrorResponse,
+ 401: ErrorResponse,
+ 403: ErrorResponse,
+ 404: ErrorResponse,
+ },
+ detail: {
+ summary: 'Create a cycle',
+ description:
+ 'Create a cycle in a project. Its dates must not overlap another cycle of the same project.',
+ ...mcpTool('create_cycle'),
+ },
+ },
+ )
+
+ .get(
+ '/cycles/:cycleId',
+ async ({ params }) => {
+ const found = await getCycle(params.cycleId);
+ if (!found) throw new HttpError(404, 'Cycle not found');
+ return found;
+ },
+ {
+ params: cycleParams,
+ cycle: 'read',
+ response: {
+ 200: CycleResponse,
+ 400: ErrorResponse,
+ 401: ErrorResponse,
+ 403: ErrorResponse,
+ 404: ErrorResponse,
+ },
+ detail: {
+ summary: 'Get a cycle',
+ description: 'Get a cycle by its numeric id.',
+ ...mcpTool('get_cycle'),
+ },
+ },
+ )
+
+ .patch(
+ '/cycles/:cycleId',
+ async ({ params, body }) => {
+ const updated = await updateCycle(params.cycleId, body);
+ if (!updated) throw new HttpError(404, 'Cycle not found');
+ return updated;
+ },
+ {
+ params: cycleParams,
+ body: t.Object({
+ name: t.Optional(t.String({ minLength: 1, description: 'New name.' })),
+ goal: t.Optional(t.String({ description: 'New goal.' })),
+ startDate: t.Optional(IsoDate),
+ endDate: t.Optional(IsoDate),
+ }),
+ cycle: 'edit',
+ response: {
+ 200: CycleResponse,
+ 400: ErrorResponse,
+ 401: ErrorResponse,
+ 403: ErrorResponse,
+ 404: ErrorResponse,
+ },
+ detail: {
+ summary: 'Update a cycle',
+ description:
+ 'Update a cycle by its numeric id. New dates must not overlap another cycle of the same project.',
+ ...mcpTool('update_cycle'),
+ },
+ },
+ )
+
+ .delete(
+ '/cycles/:cycleId',
+ async ({ params }) => {
+ await deleteCycle(params.cycleId);
+ return noContent();
+ },
+ {
+ params: cycleParams,
+ cycle: 'delete',
+ response: {
+ 204: t.Void(),
+ 400: ErrorResponse,
+ 401: ErrorResponse,
+ 403: ErrorResponse,
+ 404: ErrorResponse,
+ },
+ detail: {
+ summary: 'Delete a cycle',
+ description: 'Delete a cycle by its numeric id. Its issues stay, without a cycle.',
+ ...mcpTool('delete_cycle'),
+ },
+ },
+ )
+
+ .post(
+ '/cycles/:cycleId/transfer',
+ // projectId comes from the cycle guard, which resolved it to check access.
+ async ({ params, body, user, projectId }) => {
+ const moved = await transferCycleIssues(
+ projectId,
+ params.cycleId,
+ body.targetCycleId ?? null,
+ requireUser(user).id,
+ );
+ return { moved };
+ },
+ {
+ params: cycleParams,
+ body: t.Object({
+ targetCycleId: t.Nullable(
+ t.Integer({
+ description:
+ 'Cycle to move the unfinished issues to, or null to leave them without a cycle.',
+ }),
+ ),
+ }),
+ cycle: 'edit',
+ response: {
+ 200: t.Object({ moved: t.Number() }),
+ 400: ErrorResponse,
+ 401: ErrorResponse,
+ 403: ErrorResponse,
+ 404: ErrorResponse,
+ },
+ detail: {
+ summary: 'Transfer unfinished issues',
+ description:
+ "Move the cycle's issues that are not in a completed or canceled state to another cycle, or off any cycle. Finished issues stay on this cycle.",
+ ...mcpTool('transfer_cycle_issues'),
+ },
+ },
+ );
diff --git a/apps/api/src/cycles/store.ts b/apps/api/src/cycles/store.ts
new file mode 100644
index 00000000..aee0b4d8
--- /dev/null
+++ b/apps/api/src/cycles/store.ts
@@ -0,0 +1,251 @@
+import { db, cycle, issue, projectColumn } from '@repo/db';
+import { and, asc, desc, eq, ne, sql, type SQL } from 'drizzle-orm';
+import { HttpError, iso } from '../shared/lib';
+
+// Data access for cycles: a time-boxed period of work inside a project (a sprint).
+// Issues link to a cycle through issue.cycle_id. The status is derived from the
+// dates, not stored, and progress is derived from the linked issues' state types.
+
+export type CycleStatus = 'upcoming' | 'active' | 'completed';
+
+export interface CycleProgress {
+ completed: number;
+ canceled: number;
+ total: number;
+}
+
+export interface CycleRow {
+ id: number;
+ projectId: number;
+ name: string;
+ goal: string;
+ startDate: string;
+ endDate: string;
+ status: CycleStatus;
+ createdAt: string;
+ updatedAt: string;
+ progress: CycleProgress;
+}
+
+// Compared in UTC against the date columns, so a cycle turns active and completed on
+// its own boundary days regardless of the reader's zone.
+function cycleStatus(startDate: string, endDate: string): CycleStatus {
+ const today = new Date().toISOString().slice(0, 10);
+ if (today < startDate) return 'upcoming';
+ if (today > endDate) return 'completed';
+ return 'active';
+}
+
+function toCycle(row: typeof cycle.$inferSelect, progress: CycleProgress): CycleRow {
+ return {
+ id: row.id,
+ projectId: row.projectId,
+ name: row.name,
+ goal: row.goal,
+ startDate: row.startDate,
+ endDate: row.endDate,
+ status: cycleStatus(row.startDate, row.endDate),
+ createdAt: iso(row.createdAt),
+ updatedAt: iso(row.updatedAt),
+ progress,
+ };
+}
+
+// Cycles with their issue counts in one query: the issues hang off each cycle
+// through left joins, so a cycle with none stays in the result with zero counts.
+// total counts the joined issues, not the rows — `count(*)` would read that empty
+// join row as one issue.
+function selectCycles(where: SQL | undefined) {
+ return db
+ .select({
+ row: cycle,
+ total: sql<number>`count(${issue.id})`,
+ completed: sql<number>`count(*) filter (where ${projectColumn.stateType} = 'completed')`,
+ canceled: sql<number>`count(*) filter (where ${projectColumn.stateType} = 'canceled')`,
+ })
+ .from(cycle)
+ .leftJoin(issue, eq(issue.cycleId, cycle.id))
+ .leftJoin(projectColumn, eq(projectColumn.id, issue.columnId))
+ .where(where)
+ .groupBy(cycle.id);
+}
+
+type CycleAggregate = Awaited<ReturnType<typeof selectCycles>>[number];
+
+function mapCycle(r: CycleAggregate): CycleRow {
+ return toCycle(r.row, {
+ total: Number(r.total),
+ completed: Number(r.completed),
+ canceled: Number(r.canceled),
+ });
+}
+
+// Today in UTC, the same boundary cycleStatus compares against.
+const TODAY = sql`(now() at time zone 'utc')::date`;
+
+// Every cycle of a project, oldest first, so the list reads as a timeline.
+export async function listCycles(projectId: number): Promise<CycleRow[]> {
+ const rows = await selectCycles(eq(cycle.projectId, projectId)).orderBy(
+ asc(cycle.startDate),
+ asc(cycle.id),
+ );
+ return rows.map(mapCycle);
+}
+
+// The cycles that have not finished yet — active and upcoming — oldest first. This
+// is what the cycles page opens with: it stays the same size as a project ages,
+// while the finished ones only accumulate and are paged separately.
+export async function listPlannedCycles(projectId: number): Promise<CycleRow[]> {
+ const rows = await selectCycles(
+ and(eq(cycle.projectId, projectId), sql`${cycle.endDate} >= ${TODAY}`),
+ ).orderBy(asc(cycle.startDate), asc(cycle.id));
+ return rows.map(mapCycle);
+}
+
+export interface CyclePage {
+ items: CycleRow[];
+ total: number;
+}
+
+// One page of the finished cycles, newest first — the archive, read back from the
+// most recent. `total` counts all of them, not just the page.
+export async function listCompletedCycles(
+ projectId: number,
+ { limit, offset }: { limit: number; offset: number },
+): Promise<CyclePage> {
+ const where = and(eq(cycle.projectId, projectId), sql`${cycle.endDate} < ${TODAY}`);
+ const rows = await selectCycles(where)
+ .orderBy(desc(cycle.startDate), desc(cycle.id))
+ .limit(limit)
+ .offset(offset);
+ // Counted separately, not as a window over the page: a page past the end holds no
+ // row to carry the count, and the archive still has to say how many there are.
+ const [counted] = await db
+ .select({ total: sql<number>`count(*)` })
+ .from(cycle)
+ .where(where);
+ return { items: rows.map(mapCycle), total: Number(counted?.total ?? 0) };
+}
+
+export async function getCycle(id: number): Promise<CycleRow | null> {
+ const [row] = await selectCycles(eq(cycle.id, id));
+ return row ? mapCycle(row) : null;
+}
+
+// The project a cycle belongs to and the state its dates put it in, or null if it
+// does not exist. What the checks on a cycle referenced by its own id read.
+export async function getCycleRef(
+ id: number,
+): Promise<{ projectId: number; status: CycleStatus } | null> {
+ const rows = await db
+ .select({ projectId: cycle.projectId, startDate: cycle.startDate, endDate: cycle.endDate })
+ .from(cycle)
+ .where(eq(cycle.id, id));
+ const row = rows[0];
+ return row ? { projectId: row.projectId, status: cycleStatus(row.startDate, row.endDate) } : null;
+}
+
+// Used by the access check on routes that address a cycle by its own id.
+export async function getCycleProjectId(id: number): Promise<number | null> {
+ return (await getCycleRef(id))?.projectId ?? null;
+}
+
+// Cycles of one project may not overlap: that is what keeps at most one of them
+// active, so "the current cycle" is never ambiguous. excludeId skips the cycle being
+// updated. Throws 400 on an overlap, and on a range that ends before it starts (the
+// DB check would otherwise surface as a 500).
+async function assertRange(
+ projectId: number,
+ startDate: string,
+ endDate: string,
+ excludeId?: number,
+): Promise<void> {
+ if (endDate < startDate) throw new HttpError(400, 'Cycle end date must not precede its start');
+ const conds = [
+ eq(cycle.projectId, projectId),
+ sql`${cycle.startDate} <= ${endDate} and ${cycle.endDate} >= ${startDate}`,
+ ];
+ if (excludeId !== undefined) conds.push(ne(cycle.id, excludeId));
+ const rows = await db
+ .select({ id: cycle.id })
+ .from(cycle)
+ .where(and(...conds))
+ .limit(1);
+ if (rows.length > 0) throw new HttpError(400, 'Cycle dates overlap another cycle');
+}
+
+export interface NewCycleInput {
+ name: string;
+ goal?: string;
+ startDate: string;
+ endDate: string;
+}
+
+export async function createCycle(projectId: number, input: NewCycleInput): Promise<CycleRow> {
+ await assertRange(projectId, input.startDate, input.endDate);
+ const [row] = await db
+ .insert(cycle)
+ .values({
+ projectId,
+ name: input.name,
+ goal: input.goal ?? '',
+ startDate: input.startDate,
+ endDate: input.endDate,
+ })
+ .returning();
+ // A cycle nothing can point at yet, so its progress needs no reading back.
+ return toCycle(row, { completed: 0, canceled: 0, total: 0 });
+}
+
+export interface CyclePatch {
+ name?: string;
+ goal?: string;
+ startDate?: string;
+ endDate?: string;
+}
+
+// How far a cycle's dates may still move, by the state its dates put it in: an
+// upcoming one is planning material and moves freely, a running one may only be cut
+// short or extended, and a finished one is a record of what happened. The name and
+// the goal stay editable throughout — they describe the work, not when it ran.
+function assertDatesMovable(status: CycleStatus, movesStart: boolean, movesEnd: boolean): void {
+ if (status === 'completed' && (movesStart || movesEnd))
+ throw new HttpError(400, 'A completed cycle keeps its dates');
+ if (status === 'active' && movesStart)
+ throw new HttpError(400, 'A running cycle keeps its start date');
+}
+
+// Addressed by its own id (the route's entity guard already resolved the owning
+// project and asserted permission). Returns null if the cycle does not exist, which
+// the route maps to a 404.
+export async function updateCycle(id: number, patch: CyclePatch): Promise<CycleRow | null> {
+ const [before] = await db.select().from(cycle).where(eq(cycle.id, id));
+ if (!before) return null;
+ const movesStart = patch.startDate !== undefined && patch.startDate !== before.startDate;
+ const movesEnd = patch.endDate !== undefined && patch.endDate !== before.endDate;
+ assertDatesMovable(cycleStatus(before.startDate, before.endDate), movesStart, movesEnd);
+ if (movesStart || movesEnd) {
+ await assertRange(
+ before.projectId,
+ patch.startDate ?? before.startDate,
+ patch.endDate ?? before.endDate,
+ id,
+ );
+ }
+
+ const set: Partial<typeof cycle.$inferInsert> = {};
+ if (patch.name !== undefined) set.name = patch.name;
+ if (patch.goal !== undefined) set.goal = patch.goal;
+ if (patch.startDate !== undefined) set.startDate = patch.startDate;
+ if (patch.endDate !== undefined) set.endDate = patch.endDate;
+ if (Object.keys(set).length > 0) {
+ set.updatedAt = sql`now()` as unknown as Date;
+ await db.update(cycle).set(set).where(eq(cycle.id, id));
+ }
+ return getCycle(id);
+}
+
+// Linked issues keep existing (issue.cycle_id is set null by the FK).
+export async function deleteCycle(id: number): Promise<void> {
+ await db.delete(cycle).where(eq(cycle.id, id));
+}
diff --git a/apps/api/src/issues/activity.ts b/apps/api/src/issues/activity.ts
index 2876d087..f3de283b 100644
--- a/apps/api/src/issues/activity.ts
+++ b/apps/api/src/issues/activity.ts
@@ -7,6 +7,7 @@ import {
issueType,
label,
initiative,
+ cycle,
} from '@repo/db';
import { and, desc, eq, gte, inArray, lt, sql } from 'drizzle-orm';
import { HttpError, iso } from '../shared/lib';
@@ -418,6 +419,11 @@ async function initiativeName(id: number | null): Promise<string | null> {
.where(eq(initiative.id, id));
return rows[0]?.title ?? null;
}
+async function cycleName(id: number | null): Promise<string | null> {
+ if (id == null) return null;
+ const rows = await db.select({ name: cycle.name }).from(cycle).where(eq(cycle.id, id));
+ return rows[0]?.name ?? null;
+}
async function userName(id: string | null): Promise<string | null> {
if (id == null) return null;
const rows = await db.select({ name: user.name }).from(user).where(eq(user.id, id));
@@ -445,6 +451,7 @@ export interface IssueSnapshot {
columnId: number;
typeId: number | null;
initiativeId: number | null;
+ cycleId: number | null;
assigneeUserId: string | null;
delegateUserId: string | null;
priority: string | null;
@@ -485,6 +492,12 @@ export async function logIssueUpdate(
fromText: await initiativeName(before.initiativeId),
toText: await initiativeName(after.initiativeId),
});
+ if (before.cycleId !== after.cycleId)
+ events.push({
+ action: 'cycle',
+ fromText: await cycleName(before.cycleId),
+ toText: await cycleName(after.cycleId),
+ });
if (before.assigneeUserId !== after.assigneeUserId)
events.push({
action: 'assignee',
diff --git a/apps/api/src/issues/routes.ts b/apps/api/src/issues/routes.ts
index a6b61e40..a53403ca 100644
--- a/apps/api/src/issues/routes.ts
+++ b/apps/api/src/issues/routes.ts
@@ -112,6 +112,9 @@ const IssueResponse = t.Object({
// The linked initiative expanded to id + title (for rendering), or null. Set
// through create/update by initiativeId.
initiative: t.Nullable(t.Object({ id: t.Number(), title: t.String() })),
+ // The cycle this issue is planned into, expanded to id + name, or null. Set
+ // through create/update by cycleId.
+ cycle: t.Nullable(t.Object({ id: t.Number(), name: t.String() })),
assigneeUserId: t.Nullable(t.String()),
delegateUserId: t.Nullable(t.String()),
columnId: t.Number(),
@@ -286,6 +289,7 @@ const IssueSearchHitResponse = t.Object({
columnId: t.Number(),
typeId: t.Nullable(t.Number()),
initiativeId: t.Nullable(t.Number()),
+ cycleId: t.Nullable(t.Number()),
parentId: t.Nullable(t.Number()),
assigneeUserId: t.Nullable(t.String()),
delegateUserId: t.Nullable(t.String()),
@@ -398,6 +402,14 @@ export const issueRoutes = new Elysia({ name: 'issues', detail: { tags: ['Issues
}),
),
),
+ cycleId: t.Optional(
+ t.Nullable(
+ t.Integer({
+ description:
+ 'Cycle id to plan this issue into, or null. From list_cycles; a completed cycle is rejected.',
+ }),
+ ),
+ ),
assigneeUserId: t.Optional(
t.Nullable(
t.String({
@@ -481,6 +493,7 @@ export const issueRoutes = new Elysia({ name: 'issues', detail: { tags: ['Issues
columnId: t.Optional(t.Integer()),
typeId: t.Optional(t.Nullable(t.Integer())),
initiativeId: t.Optional(t.Nullable(t.Integer())),
+ cycleId: t.Optional(t.Nullable(t.Integer())),
assigneeUserId: t.Optional(t.Nullable(t.String())),
delegateUserId: t.Optional(t.Nullable(t.String())),
priority: t.Optional(t.Nullable(t.String())),
@@ -650,6 +663,7 @@ export const issueRoutes = new Elysia({ name: 'issues', detail: { tags: ['Issues
columnId: posId(query.columnId),
typeId: posId(query.typeId),
initiativeId: posId(query.initiativeId),
+ cycleId: posId(query.cycleId),
parentId: posId(query.parentId),
assigneeUserId: str(query.assigneeUserId),
delegateUserId: str(query.delegateUserId),
@@ -668,6 +682,7 @@ export const issueRoutes = new Elysia({ name: 'issues', detail: { tags: ['Issues
columnId: t.Optional(t.Numeric({ description: 'Exact column (state) id.' })),
typeId: t.Optional(t.Numeric({ description: 'Exact issue type id.' })),
initiativeId: t.Optional(t.Numeric({ description: 'Exact initiative id.' })),
+ cycleId: t.Optional(t.Numeric({ description: 'Exact cycle id.' })),
parentId: t.Optional(
t.Numeric({ description: 'Parent issue id, to list that issue’s subtasks.' }),
),
@@ -879,6 +894,14 @@ export const issueRoutes = new Elysia({ name: 'issues', detail: { tags: ['Issues
}),
),
),
+ cycleId: t.Optional(
+ t.Nullable(
+ t.Integer({
+ description:
+ 'Plan this issue into a cycle id, or null to unplan it. From list_cycles; a completed cycle is rejected.',
+ }),
+ ),
+ ),
assigneeUserId: t.Optional(
t.Nullable(
t.String({ description: 'New assignee user id (a project member), or null.' }),
diff --git a/apps/api/src/issues/store.ts b/apps/api/src/issues/store.ts
index dc91f716..f80ceb6b 100644
--- a/apps/api/src/issues/store.ts
+++ b/apps/api/src/issues/store.ts
@@ -14,6 +14,7 @@ import {
customField,
customFieldOption,
initiative,
+ cycle,
} from '@repo/db';
import {
and,
@@ -25,6 +26,7 @@ import {
isNotNull,
isNull,
lte,
+ notInArray,
or,
sql,
type SQL,
@@ -48,6 +50,7 @@ import { emitWebhookEvent } from '../webhooks/emit';
import { getAssignTriggerAgent, isProjectAgent } from '../ai-agents/store';
import { deleteThreadsWhere } from '../ai-agents/runtime/memory';
import { getInitiativeProjectId } from '../initiatives/store';
+import { getCycleRef } from '../cycles/store';
import { getMembership } from '../members/store';
import { enqueueAgentRun } from '../ai-agents/run-queue';
@@ -72,8 +75,11 @@ export interface IssueRow {
identifier: string;
typeId: number | null;
// The initiative this issue is linked to, expanded to id + title for rendering,
- // or null. Filled by attachInitiatives; mapIssue alone leaves it null.
+ // or null. Filled by attachGroupings; mapIssue alone leaves it null.
initiative: { id: number; title: string } | null;
+ // The cycle this issue is planned into, expanded to id + name for rendering, or
+ // null. Filled by attachGroupings; mapIssue alone leaves it null.
+ cycle: { id: number; name: string } | null;
assigneeUserId: string | null;
delegateUserId: string | null;
columnId: number;
@@ -119,6 +125,7 @@ function mapIssue(row: typeof issue.$inferSelect, projectKey: string): IssueRow
identifier: `${projectKey}-${row.sequenceNumber}`,
typeId: row.typeId,
initiative: null,
+ cycle: null,
assigneeUserId: row.assigneeUserId,
delegateUserId: row.delegateUserId,
columnId: row.columnId,
@@ -180,6 +187,7 @@ function snapshot(row: IssueRow): IssueSnapshot {
columnId: row.columnId,
typeId: row.typeId,
initiativeId: row.initiative?.id ?? null,
+ cycleId: row.cycle?.id ?? null,
assigneeUserId: row.assigneeUserId,
delegateUserId: row.delegateUserId,
priority: row.priority,
@@ -198,7 +206,7 @@ export async function listIssues(project: ProjectRow): Promise<IssueRow[]> {
await attachLabels(issues);
await attachFieldValues(issues);
await attachStatusSince(issues);
- await attachInitiatives(issues);
+ await attachGroupings(issues);
return issues;
}
@@ -214,7 +222,7 @@ export async function listArchivedIssues(project: ProjectRow): Promise<IssueRow[
await attachLabels(issues);
await attachFieldValues(issues);
await attachStatusSince(issues);
- await attachInitiatives(issues);
+ await attachGroupings(issues);
return issues;
}
@@ -230,6 +238,7 @@ export interface IssueSearchHit {
columnId: number;
typeId: number | null;
initiativeId: number | null;
+ cycleId: number | null;
parentId: number | null;
assigneeUserId: string | null;
delegateUserId: string | null;
@@ -308,6 +317,10 @@ export async function searchIssues(
? isNull(issue.initiativeId)
: eq(issue.initiativeId, filters.initiativeId),
);
+ if (filters.cycleId !== undefined)
+ conds.push(
+ filters.cycleId === null ? isNull(issue.cycleId) : eq(issue.cycleId, filters.cycleId),
+ );
if (filters.parentId !== undefined)
conds.push(
filters.parentId === null ? isNull(issue.parentId) : eq(issue.parentId, filters.parentId),
@@ -358,6 +371,7 @@ export async function searchIssues(
sequenceNumber: issue.sequenceNumber,
typeId: issue.typeId,
initiativeId: issue.initiativeId,
+ cycleId: issue.cycleId,
parentId: issue.parentId,
assigneeUserId: issue.assigneeUserId,
delegateUserId: issue.delegateUserId,
@@ -380,6 +394,7 @@ export async function searchIssues(
columnId: r.columnId,
typeId: r.typeId,
initiativeId: r.initiativeId,
+ cycleId: r.cycleId,
parentId: r.parentId,
assigneeUserId: r.assigneeUserId,
delegateUserId: r.delegateUserId,
@@ -433,25 +448,39 @@ export async function restoreIssue(
return getIssue(id);
}
-// Expands each issue's linked initiative to { id, title } in place, in one query
-// joining the issue to its initiative. Issues with no initiative keep the null
-// mapIssue set. Rendering the initiative name on a board card needs no separate
-// scaffold lookup this way.
-async function attachInitiatives(issues: IssueRow[]): Promise<void> {
+// Expands what an issue is planned under — its initiative and its cycle — to
+// { id, title } / { id, name } in place. Both hang off the same issue rows, so one
+// query carries them; an issue linked to neither keeps the nulls mapIssue set.
+// Rendering those names on a board card needs no separate scaffold lookup this way.
+async function attachGroupings(issues: IssueRow[]): Promise<void> {
if (issues.length === 0) return;
const rows = await db
- .select({ issueId: issue.id, id: initiative.id, title: initiative.title })
+ .select({
+ issueId: issue.id,
+ initiativeId: initiative.id,
+ initiativeTitle: initiative.title,
+ cycleId: cycle.id,
+ cycleName: cycle.name,
+ })
.from(issue)
- .innerJoin(initiative, eq(initiative.id, issue.initiativeId))
+ .leftJoin(initiative, eq(initiative.id, issue.initiativeId))
+ .leftJoin(cycle, eq(cycle.id, issue.cycleId))
.where(
- inArray(
- issue.id,
- issues.map((i) => i.id),
+ and(
+ inArray(
+ issue.id,
+ issues.map((i) => i.id),
+ ),
+ or(isNotNull(issue.initiativeId), isNotNull(issue.cycleId)),
),
);
- const byIssue = new Map<number, { id: number; title: string }>();
- for (const r of rows) byIssue.set(r.issueId, { id: r.id, title: r.title });
- for (const i of issues) i.initiative = byIssue.get(i.id) ?? null;
+ const byIssue = new Map(rows.map((r) => [r.issueId, r]));
+ for (const i of issues) {
+ const r = byIssue.get(i.id);
+ i.initiative =
+ r && r.initiativeId != null ? { id: r.initiativeId, title: r.initiativeTitle! } : null;
+ i.cycle = r && r.cycleId != null ? { id: r.cycleId, name: r.cycleName! } : null;
+ }
}
// Loads every issue's label ids and merges them onto the issues in place. Generic
@@ -544,6 +573,7 @@ async function loadSnapshot(
columnId: issue.columnId,
typeId: issue.typeId,
initiativeId: issue.initiativeId,
+ cycleId: issue.cycleId,
assigneeUserId: issue.assigneeUserId,
delegateUserId: issue.delegateUserId,
priority: issue.priority,
@@ -572,7 +602,7 @@ export async function getIssues(ids: number[]): Promise<IssueRow[]> {
const issues = rows.map((row) => mapIssue(row.issue, row.projectKey));
await attachLabels(issues);
await attachStatusSince(issues);
- await attachInitiatives(issues);
+ await attachGroupings(issues);
return issues;
}
@@ -592,7 +622,7 @@ export async function getIssueBySequence(
const mapped = mapIssue(rows[0].issue, rows[0].projectKey);
await attachLabels([mapped]);
await attachStatusSince([mapped]);
- await attachInitiatives([mapped]);
+ await attachGroupings([mapped]);
return mapped;
}
@@ -606,6 +636,7 @@ export async function getIssueProjectId(id: number): Promise<number | null> {
export interface NewIssueInput {
typeId?: number | null;
initiativeId?: number | null;
+ cycleId?: number | null;
assigneeUserId?: string | null;
delegateUserId?: string | null;
columnId: number;
@@ -647,6 +678,23 @@ async function assertInitiative(
throw new HttpError(400, 'Initiative must belong to this project');
}
+// Enforces that a linked cycle belongs to the same project and has not finished: a
+// completed cycle is the record of what it delivered, so no issue is planned into it
+// after the fact. Only checks when the link changes to a non-null value — clearing
+// it, and keeping the cycle an issue is already on, stay allowed. Throws 400
+// otherwise.
+async function assertCycle(
+ projectId: number,
+ cycleId: number | null | undefined,
+ currentCycleId: number | null = null,
+): Promise<void> {
+ if (cycleId == null || cycleId === currentCycleId) return;
+ const ref = await getCycleRef(cycleId);
+ if (!ref || ref.projectId !== projectId)
+ throw new HttpError(400, 'Cycle must belong to this project');
+ if (ref.status === 'completed') throw new HttpError(400, 'A completed cycle takes no new issues');
+}
+
// Enforces that a column belongs to the issue's project — issue.column_id only
// requires the column to exist somewhere, so an issue could otherwise sit on
// another project's board. Throws 400 otherwise.
@@ -730,6 +778,7 @@ export async function createIssue(
): Promise<IssueRow> {
await assertAssignments(project.id, input);
await assertInitiative(project.id, input.initiativeId);
+ await assertCycle(project.id, input.cycleId);
await assertColumn(project.id, input.columnId);
await assertIssueType(project.id, input.typeId);
await assertParent(project.id, null, input.parentId);
@@ -753,6 +802,7 @@ export async function createIssue(
sequenceNumber,
typeId: input.typeId ?? null,
initiativeId: input.initiativeId ?? null,
+ cycleId: input.cycleId ?? null,
assigneeUserId: input.assigneeUserId ?? null,
delegateUserId: input.delegateUserId ?? null,
columnId: input.columnId,
@@ -844,6 +894,7 @@ export interface IssuePatch {
typeId?: number | null;
parentId?: number | null;
initiativeId?: number | null;
+ cycleId?: number | null;
assigneeUserId?: string | null;
delegateUserId?: string | null;
title?: string;
@@ -863,6 +914,7 @@ export async function updateIssue(
await assertAssignments(before.projectId, patch);
await assertInitiative(before.projectId, patch.initiativeId);
+ await assertCycle(before.projectId, patch.cycleId, before.cycleId);
await assertColumn(before.projectId, patch.columnId);
await assertIssueType(before.projectId, patch.typeId);
await assertParent(before.projectId, id, patch.parentId);
@@ -873,6 +925,7 @@ export async function updateIssue(
if (patch.typeId !== undefined) set.typeId = patch.typeId;
if (patch.parentId !== undefined) set.parentId = patch.parentId;
if (patch.initiativeId !== undefined) set.initiativeId = patch.initiativeId;
+ if (patch.cycleId !== undefined) set.cycleId = patch.cycleId;
if (patch.assigneeUserId !== undefined) set.assigneeUserId = patch.assigneeUserId;
if (patch.delegateUserId !== undefined) set.delegateUserId = patch.delegateUserId;
if (patch.title !== undefined) set.title = patch.title;
@@ -1023,6 +1076,35 @@ async function issuesInProject(projectId: number, ids: number[]): Promise<number
return rows.map((r) => r.id);
}
+// Moves a cycle's unfinished issues — the ones outside a completed or canceled
+// column — to another cycle, or off any cycle when targetCycleId is null. What the
+// cycle finished stays on it, so it keeps recording what it delivered. Runs the
+// single-issue update per issue, so each move lands in the feed like a hand-made
+// one. Returns how many issues moved.
+export async function transferCycleIssues(
+ projectId: number,
+ cycleId: number,
+ targetCycleId: number | null,
+ actorUserId?: string | null,
+): Promise<number> {
+ if (targetCycleId === cycleId) throw new HttpError(400, 'Target cycle must be a different cycle');
+ await assertCycle(projectId, targetCycleId);
+
+ const rows = await db
+ .select({ id: issue.id })
+ .from(issue)
+ .innerJoin(projectColumn, eq(projectColumn.id, issue.columnId))
+ .where(
+ and(
+ eq(issue.cycleId, cycleId),
+ isNull(issue.archivedAt),
+ notInArray(projectColumn.stateType, ['completed', 'canceled']),
+ ),
+ );
+ for (const row of rows) await updateIssue(row.id, { cycleId: targetCycleId }, actorUserId);
+ return rows.length;
+}
+
// Applies the same patch to every listed issue. Returns how many were updated.
export async function bulkUpdateIssues(
projectId: number,
@@ -1103,12 +1185,13 @@ export async function bulkDeleteIssues(
// Clients poll these cheaply and refetch the heavy payload only when the marker
// moved, so a live board / open issue stays current without constant full reads.
-// The board's marker: changes when any issue or initiative in the project is
-// created, updated, or deleted. Issue label changes bump updated_at too (see
-// setIssueLabels). Initiative metadata is part of the work-items board payload.
-// Links are part of it as well and change no issue's updated_at, so they carry
-// their own count and highest id: adding one raises the id, removing one lowers
-// the count.
+// The board's marker: changes when any issue, initiative or cycle in the project
+// is created, updated, or deleted. Issue label changes bump updated_at too (see
+// setIssueLabels). Initiative and cycle metadata is part of the work-items board
+// payload — each issue carries the name of the one it belongs to, so a rename has
+// to move the marker. Links are part of it as well and change no issue's
+// updated_at, so they carry their own count and highest id: adding one raises the
+// id, removing one lowers the count.
export async function projectBoardRev(projectId: number): Promise<string> {
const [row] = await db
.select({
@@ -1118,6 +1201,10 @@ export async function projectBoardRev(projectId: number): Promise<string> {
initiativeMax: sql<
string | null
>`(select max(${initiative.updatedAt})::text from ${initiative} where ${initiative.projectId} = ${projectId})`,
+ cycleCount: sql<number>`(select count(*) from ${cycle} where ${cycle.projectId} = ${projectId})`,
+ cycleMax: sql<
+ string | null
+ >`(select max(${cycle.updatedAt})::text from ${cycle} where ${cycle.projectId} = ${projectId})`,
})
// Only active issues count: archiving one (manual or the worker's sweep) drops
// the count, which moves the marker and makes the board refetch it away.
@@ -1142,6 +1229,8 @@ export async function projectBoardRev(projectId: number): Promise<string> {
row?.m ?? '',
row?.initiativeCount ?? 0,
row?.initiativeMax ?? '',
+ row?.cycleCount ?? 0,
+ row?.cycleMax ?? '',
links?.count ?? 0,
links?.max ?? '',
].join(':');
diff --git a/apps/api/src/planner.ts b/apps/api/src/planner.ts
index 36e0be4c..3995ae2a 100644
--- a/apps/api/src/planner.ts
+++ b/apps/api/src/planner.ts
@@ -15,6 +15,7 @@ import { agentToolRoutes } from './agent-tools/routes';
import { customFieldRoutes } from './custom-fields/routes';
import { issueRoutes } from './issues/routes';
import { initiativeRoutes } from './initiatives/routes';
+import { cycleRoutes } from './cycles/routes';
import { attachmentRoutes } from './attachments/routes';
import { avatarRoutes } from './avatars/routes';
import { viewRoutes } from './views/routes';
@@ -84,6 +85,7 @@ export const planner = new Elysia({ name: 'planner' })
.use(customFieldRoutes)
.use(issueRoutes)
.use(initiativeRoutes)
+ .use(cycleRoutes)
.use(attachmentRoutes)
.use(avatarRoutes)
.use(viewRoutes)
diff --git a/apps/api/src/projects/__tests__/integration/projects.test.ts b/apps/api/src/projects/__tests__/integration/projects.test.ts
index c94f9484..08dff549 100644
--- a/apps/api/src/projects/__tests__/integration/projects.test.ts
+++ b/apps/api/src/projects/__tests__/integration/projects.test.ts
@@ -305,6 +305,7 @@ describe('projects', () => {
const settings = await api.projects({ projectKey: 'DST' }).settings.get();
expect(settings.data?.features).toEqual({
initiatives: true,
+ cycles: true,
dashboards: false,
notes: false,
});
diff --git a/apps/api/src/projects/copy.ts b/apps/api/src/projects/copy.ts
index d894c68a..85a03217 100644
--- a/apps/api/src/projects/copy.ts
+++ b/apps/api/src/projects/copy.ts
@@ -226,6 +226,7 @@ function mapProjectRow(row: typeof project.$inferSelect): ProjectRow {
initiativesEnabled: row.initiativesEnabled,
dashboardsEnabled: row.dashboardsEnabled,
notesEnabled: row.notesEnabled,
+ cyclesEnabled: row.cyclesEnabled,
createdAt: iso(row.createdAt),
};
}
@@ -279,6 +280,7 @@ export async function copyProject(
initiativesEnabled: project.initiativesEnabled,
dashboardsEnabled: project.dashboardsEnabled,
notesEnabled: project.notesEnabled,
+ cyclesEnabled: project.cyclesEnabled,
})
.from(project)
.where(eq(project.id, sourceProjectId));
diff --git a/apps/api/src/projects/routes.ts b/apps/api/src/projects/routes.ts
index 64e6b959..48848e48 100644
--- a/apps/api/src/projects/routes.ts
+++ b/apps/api/src/projects/routes.ts
@@ -72,6 +72,7 @@ const ProjectResponse = t.Object({
initiativesEnabled: t.Boolean(),
dashboardsEnabled: t.Boolean(),
notesEnabled: t.Boolean(),
+ cyclesEnabled: t.Boolean(),
createdAt: t.String(),
});
@@ -171,6 +172,7 @@ const FeaturesResponse = t.Object({
initiatives: t.Boolean(),
dashboards: t.Boolean(),
notes: t.Boolean(),
+ cycles: t.Boolean(),
});
// The project's settings: MCP reachability and the enabled sections.
@@ -429,6 +431,7 @@ export const projectRoutes = new Elysia({ name: 'projects', detail: { tags: ['Pr
initiatives: t.Optional(t.Boolean()),
dashboards: t.Optional(t.Boolean()),
notes: t.Optional(t.Boolean()),
+ cycles: t.Optional(t.Boolean()),
}),
),
}),
diff --git a/apps/api/src/projects/store.ts b/apps/api/src/projects/store.ts
index b7b00f5f..0dc3184a 100644
--- a/apps/api/src/projects/store.ts
+++ b/apps/api/src/projects/store.ts
@@ -32,6 +32,7 @@ export interface ProjectRow {
initiativesEnabled: boolean;
dashboardsEnabled: boolean;
notesEnabled: boolean;
+ cyclesEnabled: boolean;
createdAt: string;
}
@@ -41,6 +42,7 @@ export interface ProjectFeatures {
initiatives: boolean;
dashboards: boolean;
notes: boolean;
+ cycles: boolean;
}
// A project in the caller's list, carrying the caller's own role in it. The list
@@ -63,6 +65,7 @@ function mapProject(row: typeof project.$inferSelect): ProjectRow {
initiativesEnabled: row.initiativesEnabled,
dashboardsEnabled: row.dashboardsEnabled,
notesEnabled: row.notesEnabled,
+ cyclesEnabled: row.cyclesEnabled,
createdAt: iso(row.createdAt),
};
}
@@ -88,6 +91,7 @@ export async function listProjects(
initiativesEnabled: project.initiativesEnabled,
dashboardsEnabled: project.dashboardsEnabled,
notesEnabled: project.notesEnabled,
+ cyclesEnabled: project.cyclesEnabled,
createdAt: project.createdAt,
role: projectMember.role,
rolePermissions: projectRole.permissions,
@@ -285,6 +289,7 @@ export function projectFeatures(row: ProjectRow): ProjectFeatures {
initiatives: row.initiativesEnabled,
dashboards: row.dashboardsEnabled,
notes: row.notesEnabled,
+ cycles: row.cyclesEnabled,
};
}
@@ -298,6 +303,7 @@ export async function setProjectFeatures(
if (patch.initiatives !== undefined) values.initiativesEnabled = patch.initiatives;
if (patch.dashboards !== undefined) values.dashboardsEnabled = patch.dashboards;
if (patch.notes !== undefined) values.notesEnabled = patch.notes;
+ if (patch.cycles !== undefined) values.cyclesEnabled = patch.cycles;
if (Object.keys(values).length === 0) return getProjectById(projectId);
const [row] = await db.update(project).set(values).where(eq(project.id, projectId)).returning();
return row ? mapProject(row) : null;
diff --git a/apps/api/src/share/__tests__/integration/share.test.ts b/apps/api/src/share/__tests__/integration/share.test.ts
index 0bb4268e..69c6cfb9 100644
--- a/apps/api/src/share/__tests__/integration/share.test.ts
+++ b/apps/api/src/share/__tests__/integration/share.test.ts
@@ -74,12 +74,23 @@ describe('share', () => {
.issues({ issueId })
.patch({ assigneeUserId: ownerId, labelIds: [label.data!.id] });
+ // A cycle that starts today, since a completed one takes no new issues.
+ const start = new Date();
+ const end = new Date(start.getTime() + 13 * 24 * 60 * 60 * 1000);
+ const cycle = await asOwner.projects({ projectKey: 'MKT' }).cycles.post({
+ name: 'Sprint 1',
+ startDate: start.toISOString().slice(0, 10),
+ endDate: end.toISOString().slice(0, 10),
+ });
+ await asOwner.issues({ issueId }).patch({ cycleId: cycle.data!.id });
+
const token = (await asOwner.issues({ issueId }).share.post()).data!.token;
const plain = await api.share.issue({ token }).get();
expect(plain.data.issue).toMatchObject({
title: 'Shared thing',
assigneeUserId: null,
labelIds: [],
+ cycle: null,
});
expect(plain.data.feed).toEqual([]);
expect(plain.data.project.labels).toEqual([]);
@@ -89,6 +100,7 @@ describe('share', () => {
const full = await api.share.issue({ token }).get();
expect(full.data.issue.assigneeUserId).not.toBeNull();
expect(full.data.issue.labelIds).toHaveLength(1);
+ expect(full.data.issue.cycle).toMatchObject({ name: 'Sprint 1' });
expect(full.data.feed.length).toBeGreaterThan(0);
});
diff --git a/apps/api/src/share/store.ts b/apps/api/src/share/store.ts
index 7db4e6f3..c5ee28d0 100644
--- a/apps/api/src/share/store.ts
+++ b/apps/api/src/share/store.ts
@@ -99,11 +99,13 @@ async function buildScaffold(project: ProjectRow, extended: boolean): Promise<Sh
// Cuts an issue down to what a non-extended share exposes: its title, description,
// state, type, priority, dates, and its place among the other issues. The people on
-// it, its labels and its custom field values stay private.
+// it, its planning (initiative, cycle), its labels and its custom field values stay
+// private.
function redactIssue<T extends IssueRow>(row: T): T {
return {
...row,
initiative: null,
+ cycle: null,
assigneeUserId: null,
delegateUserId: null,
labelIds: [],
diff --git a/apps/api/src/shared/permissions.ts b/apps/api/src/shared/permissions.ts
index 7f84b582..b2f5e25f 100644
--- a/apps/api/src/shared/permissions.ts
+++ b/apps/api/src/shared/permissions.ts
@@ -6,6 +6,7 @@
export const PERMISSION_RESOURCES = [
'work_items',
'initiatives',
+ 'cycles',
'dashboards',
'views',
'members_invite',
@@ -53,6 +54,7 @@ export function defaultMemberPermissions(): Permissions {
const p = emptyPermissions();
p.work_items = fill(true);
p.initiatives = fill(true);
+ p.cycles = fill(true);
p.note_boards = fill(true);
p.dashboards.read = true;
p.views.read = true;
diff --git a/apps/web/src/app/project/[projectKey]/cycles/[view]/page.tsx b/apps/web/src/app/project/[projectKey]/cycles/[view]/page.tsx
new file mode 100644
index 00000000..d72692ea
--- /dev/null
+++ b/apps/web/src/app/project/[projectKey]/cycles/[view]/page.tsx
@@ -0,0 +1,20 @@
+import { redirect } from 'next/navigation';
+import RequireFeature from '@/components/common/permissions/RequireFeature';
+import CyclesPage from '@/features/cycles/CyclesPage';
+import { cyclesPath, isCyclesView } from '@/utils/paths';
+
+// One layout of the cycles list: the grouped table or the day track.
+export default async function Page({
+ params,
+}: {
+ params: Promise<{ projectKey: string; view: string }>;
+}) {
+ const { projectKey, view } = await params;
+ if (!isCyclesView(view)) redirect(cyclesPath(projectKey));
+
+ return (
+ <RequireFeature feature="cycles">
+ <CyclesPage view={view} />
+ </RequireFeature>
+ );
+}
diff --git a/apps/web/src/app/project/[projectKey]/cycles/details/[cycleId]/page.tsx b/apps/web/src/app/project/[projectKey]/cycles/details/[cycleId]/page.tsx
new file mode 100644
index 00000000..edcbdf1e
--- /dev/null
+++ b/apps/web/src/app/project/[projectKey]/cycles/details/[cycleId]/page.tsx
@@ -0,0 +1,15 @@
+import { notFound } from 'next/navigation';
+import RequireFeature from '@/components/common/permissions/RequireFeature';
+import CycleDetailPage from '@/features/cycles/CycleDetailPage';
+
+export default async function Page({ params }: { params: Promise<{ cycleId: string }> }) {
+ const { cycleId } = await params;
+ const id = Number(cycleId);
+ if (!Number.isInteger(id)) notFound();
+
+ return (
+ <RequireFeature feature="cycles">
+ <CycleDetailPage cycleId={id} />
+ </RequireFeature>
+ );
+}
diff --git a/apps/web/src/app/project/[projectKey]/cycles/page.tsx b/apps/web/src/app/project/[projectKey]/cycles/page.tsx
new file mode 100644
index 00000000..cd6fca38
--- /dev/null
+++ b/apps/web/src/app/project/[projectKey]/cycles/page.tsx
@@ -0,0 +1,11 @@
+import RequireFeature from '@/components/common/permissions/RequireFeature';
+import CyclesRedirect from '@/features/cycles/CyclesRedirect';
+
+// The list path carries no layout of its own; it redirects to one.
+export default function Page() {
+ return (
+ <RequireFeature feature="cycles">
+ <CyclesRedirect />
+ </RequireFeature>
+ );
+}
diff --git a/apps/web/src/components/common/ProgressBar.tsx b/apps/web/src/components/common/ProgressBar.tsx
new file mode 100644
index 00000000..ca8a32fa
--- /dev/null
+++ b/apps/web/src/components/common/ProgressBar.tsx
@@ -0,0 +1,28 @@
+import { progressPercent } from '@/utils/progress';
+import { cn } from '@/lib/utils';
+
+// Issue progress as a thin bar plus a "completed/total" count. Canceled issues are
+// excluded from the denominator so the bar reflects deliverable work. Shared by the
+// groupings that track it: initiatives and cycles. The bar is a fixed width so it
+// lines up down a list column; `wide` spreads it over whatever room it is given.
+export default function ProgressBar({
+ progress,
+ wide,
+}: {
+ progress: { completed: number; canceled: number; total: number };
+ wide?: boolean;
+}) {
+ return (
+ <div className={cn('flex items-center gap-2', wide && 'w-full')}>
+ <div className={cn('h-1.5 overflow-hidden rounded-full bg-muted', wide ? 'flex-1' : 'w-16')}>
+ <div
+ className="h-full rounded-full bg-foreground/70"
+ style={{ width: `${progressPercent(progress)}%` }}
+ />
+ </div>
+ <span className="text-xs text-muted-foreground tabular-nums">
+ {progress.completed}/{progress.total - progress.canceled}
+ </span>
+ </div>
+ );
+}
diff --git a/apps/web/src/components/common/fields/DatePill.tsx b/apps/web/src/components/common/fields/DatePill.tsx
index 101b5e3b..e39ed080 100644
--- a/apps/web/src/components/common/fields/DatePill.tsx
+++ b/apps/web/src/components/common/fields/DatePill.tsx
@@ -1,4 +1,4 @@
-import { useState, type ReactNode } from 'react';
+import { useState, type ComponentProps, type ReactNode } from 'react';
import { Calendar as CalendarIcon } from 'lucide-react';
import { formatDate, parseDate, toDateStr } from '@/utils/dates';
import { Button } from '@/components/ui/button';
@@ -16,12 +16,20 @@ export default function DatePill({
onChange,
readOnly,
trigger,
+ clearable = true,
+ disabled,
}: {
value: string | null;
placeholder?: string;
onChange: (v: string | null) => void;
readOnly?: boolean;
trigger?: ReactNode;
+ // False on a date the form requires, where offering to clear it would be an
+ // action the caller has to ignore.
+ clearable?: boolean;
+ // Days the caller cannot accept, as react-day-picker matchers ({ before }, { after },
+ // { from, to }, …). They render greyed out and cannot be selected.
+ disabled?: ComponentProps<typeof Calendar>['disabled'];
}) {
const [open, setOpen] = useState(false);
const pill = trigger ?? (
@@ -38,13 +46,14 @@ export default function DatePill({
<Calendar
mode="single"
selected={parseDate(value) ?? undefined}
+ disabled={disabled}
onSelect={(d) => {
onChange(d ? toDateStr(d) : null);
setOpen(false);
}}
autoFocus
/>
- {value && (
+ {value && clearable && (
<div className="border-t p-2">
<Button variant="ghost" size="sm" className="w-full" onClick={() => onChange(null)}>
Clear
diff --git a/apps/web/src/features/work-items/components/timeline/TimelineHeader.tsx b/apps/web/src/components/common/timeline/TimelineHeader.tsx
similarity index 97%
rename from apps/web/src/features/work-items/components/timeline/TimelineHeader.tsx
rename to apps/web/src/components/common/timeline/TimelineHeader.tsx
index 097507b3..c8834496 100644
--- a/apps/web/src/features/work-items/components/timeline/TimelineHeader.tsx
+++ b/apps/web/src/components/common/timeline/TimelineHeader.tsx
@@ -1,7 +1,7 @@
import { startOfDay } from 'date-fns';
import { daysBetween } from '@/utils/dates';
+import { type MonthLabel } from '@/utils/timelineTrack';
import { cn } from '@/lib/utils';
-import { type MonthLabel } from '../../utils/timeline';
// The sticky timeline header: the label column's corner, month labels, and the
// day-number row. Day numbers thin out as the day width shrinks.
diff --git a/apps/web/src/features/work-items/components/timeline/TimelineLabelResizer.tsx b/apps/web/src/components/common/timeline/TimelineLabelResizer.tsx
similarity index 84%
rename from apps/web/src/features/work-items/components/timeline/TimelineLabelResizer.tsx
rename to apps/web/src/components/common/timeline/TimelineLabelResizer.tsx
index 964d83f3..2a53d0e0 100644
--- a/apps/web/src/features/work-items/components/timeline/TimelineLabelResizer.tsx
+++ b/apps/web/src/components/common/timeline/TimelineLabelResizer.tsx
@@ -1,9 +1,9 @@
import { useEffect, useRef } from 'react';
-// The grip on the right edge of the Timeline's label column: dragging it sets
-// how much room the issue titles get. It spans the whole column, header to last
-// row, and sticks to the left edge so it stays reachable however far the timeline
-// is scrolled.
+// The grip on the right edge of a timeline's label column: dragging it sets how
+// much room the labels get. It spans the whole column, header to last row, and
+// sticks to the left edge so it stays reachable however far the timeline is
+// scrolled.
export function TimelineLabelResizer({
labelW,
onResize,
diff --git a/apps/web/src/components/layout/CycleBreadcrumb.tsx b/apps/web/src/components/layout/CycleBreadcrumb.tsx
new file mode 100644
index 00000000..1f37e60e
--- /dev/null
+++ b/apps/web/src/components/layout/CycleBreadcrumb.tsx
@@ -0,0 +1,31 @@
+'use client';
+
+import Link from 'next/link';
+import { ChevronRight } from 'lucide-react';
+import { cyclesPath } from '@/utils/paths';
+import { useCycleQuery } from '@/services/cycles.service';
+
+// The header title on a cycle page: Cycles › cycle name. Renaming a cycle happens
+// in its edit dialog, so the name here is plain text.
+export default function CycleBreadcrumb({
+ projectKey,
+ cycleId,
+}: {
+ projectKey: string | null;
+ cycleId: number;
+}) {
+ const name = useCycleQuery(cycleId).data?.name;
+
+ return (
+ <span className="flex min-w-0 items-center gap-1.5">
+ <Link
+ href={projectKey ? cyclesPath(projectKey) : '/'}
+ className="truncate text-muted-foreground hover:text-foreground"
+ >
+ Cycles
+ </Link>
+ <ChevronRight className="size-3.5 shrink-0 text-muted-foreground" />
+ <span className="truncate font-medium">{name ?? '…'}</span>
+ </span>
+ );
+}
diff --git a/apps/web/src/components/layout/DisplayGroupingRows.tsx b/apps/web/src/components/layout/DisplayGroupingRows.tsx
index ec4d823b..c82ccb40 100644
--- a/apps/web/src/components/layout/DisplayGroupingRows.tsx
+++ b/apps/web/src/components/layout/DisplayGroupingRows.tsx
@@ -1,6 +1,6 @@
import { ArrowDownNarrowWide, ArrowUpNarrowWide } from 'lucide-react';
import { SORT_FIELDS, type SortField, type WorkItemsView } from '@/utils/viewTypes';
-import type { GroupField, ViewSettings } from '@/utils/viewSettings';
+import { isFieldEnabled, type GroupField, type ViewSettings } from '@/utils/viewSettings';
import { useProjectFeatures } from '@/hooks/useProjectFeatures';
import { Button } from '@/components/ui/button';
import { Checkbox } from '@/components/ui/checkbox';
@@ -20,6 +20,7 @@ const GROUP_OPTIONS: { value: GroupField; label: string }[] = [
{ value: 'priority', label: 'Priority' },
{ value: 'type', label: 'Type' },
{ value: 'initiative', label: 'Initiative' },
+ { value: 'cycle', label: 'Cycle' },
];
// The grouping, sub-grouping, ordering, empty-group, links and subtasks rows.
@@ -38,11 +39,9 @@ export default function DisplayGroupingRows({
const setGroup = (group: GroupField) =>
onChange(group === settings.subgroup ? { group, subgroup: 'none' } : { group });
- // Initiative is only offered while the project shows the Initiatives section.
+ // Initiative and Cycle are only offered while the project shows their section.
const features = useProjectFeatures();
- const options = features.initiatives
- ? GROUP_OPTIONS
- : GROUP_OPTIONS.filter((o) => o.value !== 'initiative');
+ const options = GROUP_OPTIONS.filter((o) => isFieldEnabled(o.value, features));
const groupOptions =
view === 'kanban' || view === 'timeline' ? options.filter((o) => o.value !== 'none') : options;
diff --git a/apps/web/src/components/layout/DisplayPropertiesSection.tsx b/apps/web/src/components/layout/DisplayPropertiesSection.tsx
index 037acdcb..a3d3fd99 100644
--- a/apps/web/src/components/layout/DisplayPropertiesSection.tsx
+++ b/apps/web/src/components/layout/DisplayPropertiesSection.tsx
@@ -26,7 +26,7 @@ export default function DisplayPropertiesSection({
issueTypes: IssueType[];
}) {
const features = useProjectFeatures();
- const properties = offeredDisplayProperties(features.initiatives);
+ const properties = offeredDisplayProperties(features);
// Enabling appends to the end (a new column shows on the right); disabling
// removes. Order is otherwise preserved.
diff --git a/apps/web/src/components/layout/ShellHeaderTitle.tsx b/apps/web/src/components/layout/ShellHeaderTitle.tsx
index 7e68b89e..c1a9441a 100644
--- a/apps/web/src/components/layout/ShellHeaderTitle.tsx
+++ b/apps/web/src/components/layout/ShellHeaderTitle.tsx
@@ -1,23 +1,25 @@
import { SETTINGS_SECTIONS } from '@/utils/settingsSections';
import type { ShellRoute } from '@/hooks/useShellRoute';
+import CycleBreadcrumb from '@/components/layout/CycleBreadcrumb';
import InitiativeBreadcrumb from '@/components/layout/InitiativeBreadcrumb';
import IssueBreadcrumb from '@/components/layout/IssueBreadcrumb';
-// The label on the pages that are not an issue or initiative detail.
+// The label on the pages that are not an issue, initiative or cycle detail.
function pageLabel(route: ShellRoute, projectName: string): string {
const { sub, section, aiTeamCrumb } = route;
if (section) return SETTINGS_SECTIONS.find((s) => s.slug === section)?.label ?? 'Settings';
if (sub === 'members') return 'Members';
if (sub === 'dashboard') return 'Dashboards';
if (sub === 'initiatives') return 'Initiatives';
+ if (sub === 'cycles') return 'Cycles';
if (aiTeamCrumb) return aiTeamCrumb;
if (sub === 'ai-agents') return 'AI agents';
if (sub === 'api') return 'API';
return projectName;
}
-// The header title: a breadcrumb on an issue or initiative page, otherwise the
-// page's own label.
+// The header title: a breadcrumb on an issue, initiative or cycle page, otherwise
+// the page's own label.
export default function ShellHeaderTitle({
route,
projectName,
@@ -41,5 +43,8 @@ export default function ShellHeaderTitle({
<InitiativeBreadcrumb projectKey={route.projectKey} initiativeId={route.routeInitiativeId} />
);
}
+ if (route.routeCycleId != null) {
+ return <CycleBreadcrumb projectKey={route.projectKey} cycleId={route.routeCycleId} />;
+ }
return <>{pageLabel(route, projectName)}</>;
}
diff --git a/apps/web/src/components/layout/SidebarWorkNav.tsx b/apps/web/src/components/layout/SidebarWorkNav.tsx
index 95002e7f..42819c87 100644
--- a/apps/web/src/components/layout/SidebarWorkNav.tsx
+++ b/apps/web/src/components/layout/SidebarWorkNav.tsx
@@ -1,6 +1,13 @@
import { usePathname } from 'next/navigation';
-import { Inbox, LayoutDashboard, SquareKanban, StickyNote, Target } from 'lucide-react';
-import { dashboardsPath, inboxPath, initiativesPath, notesPath, projectPath } from '@/utils/paths';
+import { Inbox, LayoutDashboard, RefreshCw, SquareKanban, StickyNote, Target } from 'lucide-react';
+import {
+ cyclesPath,
+ dashboardsPath,
+ inboxPath,
+ initiativesPath,
+ notesPath,
+ projectPath,
+} from '@/utils/paths';
import { usePermissions } from '@/hooks/usePermissions';
import { useProjectFeatures } from '@/hooks/useProjectFeatures';
import { useInboxUnread } from '@/hooks/useInboxUnread';
@@ -67,6 +74,15 @@ export default function SidebarWorkNav({
disabled={disabled}
/>
)}
+ {features.cycles && can('cycles', 'read') && (
+ <SidebarNavItem
+ href={projectKey ? cyclesPath(projectKey) : '#'}
+ icon={RefreshCw}
+ label="Cycles"
+ active={pathname.includes('/cycles')}
+ disabled={disabled}
+ />
+ )}
{features.notes && can('note_boards', 'read') && (
<SidebarNavItem
href={projectKey ? notesPath(projectKey) : '#'}
diff --git a/apps/web/src/components/layout/TableProperties.tsx b/apps/web/src/components/layout/TableProperties.tsx
index 82a88c19..645f565f 100644
--- a/apps/web/src/components/layout/TableProperties.tsx
+++ b/apps/web/src/components/layout/TableProperties.tsx
@@ -42,7 +42,7 @@ export default function TableProperties({
const enabled = properties.filter((k) => labelFor(k) != null);
const enabledSet = new Set(properties);
const features = useProjectFeatures();
- const disabledBuiltins = offeredDisplayProperties(features.initiatives).filter(
+ const disabledBuiltins = offeredDisplayProperties(features).filter(
(p) => !enabledSet.has(p.value),
);
diff --git a/apps/web/src/features/cycles/CycleDetailPage.tsx b/apps/web/src/features/cycles/CycleDetailPage.tsx
new file mode 100644
index 00000000..42a023db
--- /dev/null
+++ b/apps/web/src/features/cycles/CycleDetailPage.tsx
@@ -0,0 +1,30 @@
+'use client';
+
+import { useShell } from '@/context/shellContext';
+import { Skeleton } from '@/components/ui/skeleton';
+import { useCycleQuery } from '@/services/cycles.service';
+import CycleHeader from './components/detail/CycleHeader';
+import CycleIssuesBoard from './components/detail/CycleIssuesBoard';
+
+// One cycle: its header over the board of the issues planned into it.
+export default function CycleDetailPage({ cycleId }: { cycleId: number }) {
+ const { project } = useShell();
+ const projectKey = project?.project.key ?? null;
+ const query = useCycleQuery(cycleId);
+ const cycle = query.data;
+
+ if (!project || !projectKey) return null;
+ if (!cycle)
+ return query.isLoading ? (
+ <Skeleton className="m-6 h-8 w-64" />
+ ) : (
+ <p className="px-6 py-8 text-sm text-muted-foreground">Cycle not found.</p>
+ );
+
+ return (
+ <div className="flex min-h-0 flex-1 flex-col">
+ <CycleHeader cycle={cycle} projectKey={projectKey} />
+ <CycleIssuesBoard cycle={cycle} />
+ </div>
+ );
+}
diff --git a/apps/web/src/features/cycles/CyclesPage.tsx b/apps/web/src/features/cycles/CyclesPage.tsx
new file mode 100644
index 00000000..593cbe91
--- /dev/null
+++ b/apps/web/src/features/cycles/CyclesPage.tsx
@@ -0,0 +1,70 @@
+'use client';
+
+import { useState } from 'react';
+import { useRouter } from 'next/navigation';
+import { Plus } from 'lucide-react';
+import { useShell } from '@/context/shellContext';
+import { usePermissions } from '@/hooks/usePermissions';
+import { Button } from '@/components/ui/button';
+import { usePlannedCyclesQuery } from '@/services/cycles.service';
+import { cyclesViewPath, type CyclesView } from '@/utils/paths';
+import { rememberCyclesView } from './utils/cyclesView';
+import { useCompletedCycles } from './hooks/useCompletedCycles';
+import CyclesList from './components/list/CyclesList';
+import CyclesViewTabs from './components/list/CyclesViewTabs';
+import CycleFormDialog from './components/CycleFormDialog';
+
+// A project's cycles, grouped by the status their dates put them in, as a table or
+// on a timeline. Each layout is a route of its own, and the one picked becomes the
+// project's remembered layout. What is still planned loads whole — it stays a
+// handful of cycles however old the project is; the finished ones only accumulate,
+// so they are a paged archive of their own.
+export default function CyclesPage({ view }: { view: CyclesView }) {
+ const { project } = useShell();
+ const { can } = usePermissions();
+ const router = useRouter();
+ const [creating, setCreating] = useState(false);
+
+ const projectKey = project?.project.key ?? null;
+ const query = usePlannedCyclesQuery(projectKey);
+ const completed = useCompletedCycles(projectKey);
+
+ if (!project || !projectKey) return null;
+
+ const cycles = query.data ?? [];
+
+ const changeView = (next: CyclesView) => {
+ rememberCyclesView(projectKey, next);
+ router.push(cyclesViewPath(projectKey, next));
+ };
+
+ return (
+ <div className="flex flex-1 flex-col overflow-hidden">
+ <div className="flex items-center justify-between gap-2 px-4 py-3">
+ <h1 className="text-lg font-semibold">Cycles</h1>
+ {can('cycles', 'create') && (
+ <Button size="sm" className="h-8 gap-1.5" onClick={() => setCreating(true)}>
+ <Plus className="size-3.5" />
+ New cycle
+ </Button>
+ )}
+ </div>
+
+ <div className="min-w-0 px-4 pb-2">
+ <CyclesViewTabs view={view} onSelect={changeView} />
+ </div>
+
+ <CyclesList
+ cycles={cycles}
+ completed={completed}
+ projectKey={projectKey}
+ view={view}
+ isLoading={query.isLoading || completed.isLoading}
+ canCreate={can('cycles', 'create')}
+ onCreate={() => setCreating(true)}
+ />
+
+ {creating && <CycleFormDialog projectKey={projectKey} onClose={() => setCreating(false)} />}
+ </div>
+ );
+}
diff --git a/apps/web/src/features/cycles/CyclesRedirect.tsx b/apps/web/src/features/cycles/CyclesRedirect.tsx
new file mode 100644
index 00000000..051625a5
--- /dev/null
+++ b/apps/web/src/features/cycles/CyclesRedirect.tsx
@@ -0,0 +1,26 @@
+'use client';
+
+import { useEffect } from 'react';
+import { useRouter } from 'next/navigation';
+import { useShell } from '@/context/shellContext';
+import { cyclesViewPath } from '@/utils/paths';
+import { readCyclesView } from './utils/cyclesView';
+
+// What the cycles list path opens: the layout last used in this project. The
+// replace keeps the path out of the history, so Back leaves the section instead of
+// redirecting again.
+//
+// This has to run on the client: the remembered layout is in localStorage, which
+// the server render cannot read.
+export default function CyclesRedirect() {
+ const { project } = useShell();
+ const router = useRouter();
+ const projectKey = project?.project.key ?? null;
+
+ useEffect(() => {
+ if (!projectKey) return;
+ router.replace(cyclesViewPath(projectKey, readCyclesView(projectKey)));
+ }, [projectKey, router]);
+
+ return null;
+}
diff --git a/apps/web/src/features/cycles/components/CycleActions.tsx b/apps/web/src/features/cycles/components/CycleActions.tsx
new file mode 100644
index 00000000..849e4660
--- /dev/null
+++ b/apps/web/src/features/cycles/components/CycleActions.tsx
@@ -0,0 +1,85 @@
+'use client';
+
+import { useState } from 'react';
+import { useRouter } from 'next/navigation';
+import { ArrowRightLeft, MoreHorizontal, Pencil, Trash2 } from 'lucide-react';
+import type { Cycle } from '@/lib/api';
+import { cyclesPath } from '@/utils/paths';
+import { usePermissions } from '@/hooks/usePermissions';
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu';
+import { useDeleteCycle } from '@/services/cycles.service';
+import CycleFormDialog from './CycleFormDialog';
+import TransferIssuesDialog from './TransferIssuesDialog';
+
+// The cycle's overflow menu. Deleting returns to the cycles list; the issues of a
+// deleted cycle stay, without one.
+export default function CycleActions({ cycle, projectKey }: { cycle: Cycle; projectKey: string }) {
+ const { can } = usePermissions();
+ const del = useDeleteCycle(projectKey);
+ const router = useRouter();
+ const [editing, setEditing] = useState(false);
+ const [transferring, setTransferring] = useState(false);
+
+ const canEdit = can('cycles', 'edit');
+ const canDelete = can('cycles', 'delete');
+ if (!canEdit && !canDelete) return null;
+
+ const remove = async () => {
+ await del.mutateAsync(cycle.id);
+ router.push(cyclesPath(projectKey));
+ };
+
+ return (
+ <>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <button
+ type="button"
+ aria-label="Cycle options"
+ className="rounded p-0.5 text-muted-foreground/60 hover:text-foreground"
+ >
+ <MoreHorizontal className="size-4" />
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ {canEdit && (
+ <DropdownMenuItem onClick={() => setEditing(true)}>
+ <Pencil className="size-4" />
+ Edit
+ </DropdownMenuItem>
+ )}
+ {canEdit && (
+ <DropdownMenuItem onClick={() => setTransferring(true)}>
+ <ArrowRightLeft className="size-4" />
+ Transfer unfinished issues
+ </DropdownMenuItem>
+ )}
+ {canEdit && canDelete && <DropdownMenuSeparator />}
+ {canDelete && (
+ <DropdownMenuItem variant="destructive" onClick={() => void remove()}>
+ <Trash2 className="size-4" />
+ Delete
+ </DropdownMenuItem>
+ )}
+ </DropdownMenuContent>
+ </DropdownMenu>
+
+ {editing && (
+ <CycleFormDialog cycle={cycle} projectKey={projectKey} onClose={() => setEditing(false)} />
+ )}
+ {transferring && (
+ <TransferIssuesDialog
+ cycle={cycle}
+ projectKey={projectKey}
+ onClose={() => setTransferring(false)}
+ />
+ )}
+ </>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/CycleForm.tsx b/apps/web/src/features/cycles/components/CycleForm.tsx
new file mode 100644
index 00000000..2b5cba54
--- /dev/null
+++ b/apps/web/src/features/cycles/components/CycleForm.tsx
@@ -0,0 +1,157 @@
+import { useState } from 'react';
+import { toast } from 'sonner';
+import { ApiError, type Cycle } from '@/lib/api';
+import { addDays, daysBetween, parseDate, toDateStr } from '@/utils/dates';
+import Modal from '@/components/common/overlay/Modal';
+import DatePill from '@/components/common/fields/DatePill';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { Label } from '@/components/ui/label';
+import { Textarea } from '@/components/ui/textarea';
+import { useCreateCycle, useUpdateCycle } from '@/services/cycles.service';
+import type { CycleDefaults } from '../utils/cycleDefaults';
+import { busyRanges, endLimit } from '../utils/cycleRanges';
+import CycleLengthPicker from './CycleLengthPicker';
+import FixedDate from './FixedDate';
+
+// The fields of a cycle: name, goal, and the range. A new cycle opens already filled
+// in from `defaults`, so creating one takes a single click. The API rejects dates
+// that overlap another cycle; that message is shown as it comes back.
+export default function CycleForm({
+ projectKey,
+ cycle,
+ cycles,
+ defaults,
+ onClose,
+}: {
+ projectKey: string;
+ cycle?: Cycle;
+ // The project's cycles, which the new range has to fit around.
+ cycles: Cycle[];
+ defaults: CycleDefaults;
+ onClose: () => void;
+}) {
+ const [name, setName] = useState(cycle?.name ?? defaults.name);
+ const [goal, setGoal] = useState(cycle?.goal ?? '');
+ const [startDate, setStartDate] = useState(cycle?.startDate ?? defaults.startDate);
+ const [endDate, setEndDate] = useState(cycle?.endDate ?? defaults.endDate);
+ const create = useCreateCycle(projectKey);
+ const update = useUpdateCycle(projectKey);
+ const saving = create.isPending || update.isPending;
+
+ const start = parseDate(startDate);
+ const end = parseDate(endDate);
+ const length = start && end ? daysBetween(start, end) + 1 : 0;
+
+ const busy = busyRanges(cycles, cycle?.id);
+ const lastDay = endLimit(cycles, startDate, cycle?.id);
+
+ // How far the dates may still move, matching what the API accepts: a running cycle
+ // can only be cut short or extended, a finished one is a record and keeps both
+ // dates. The name and the goal stay editable either way.
+ const startLocked = cycle !== undefined && cycle.status !== 'upcoming';
+ const endLocked = cycle?.status === 'completed';
+
+ // A range may not run into the cycle that follows it, so an end computed from a
+ // length stops at the day before that one starts.
+ const endFrom = (from: Date, days: number): string => {
+ const limit = endLimit(cycles, toDateStr(from), cycle?.id);
+ const candidate = addDays(from, days - 1);
+ return toDateStr(limit && candidate > limit ? limit : candidate);
+ };
+
+ // Both dates move together: changing the length or the start keeps the span, so
+ // only the end date is ever picked by hand.
+ const changeLength = (days: number) => {
+ if (start) setEndDate(endFrom(start, days));
+ };
+ const changeStart = (next: string) => {
+ setStartDate(next);
+ const from = parseDate(next);
+ if (from && length > 0) setEndDate(endFrom(from, length));
+ };
+
+ const submit = async () => {
+ const trimmed = name.trim();
+ if (!trimmed) return;
+ const input = { name: trimmed, goal: goal.trim(), startDate, endDate };
+ try {
+ if (cycle) await update.mutateAsync({ id: cycle.id, patch: input });
+ else await create.mutateAsync(input);
+ onClose();
+ } catch (err) {
+ toast.error(err instanceof ApiError ? err.message : 'Could not save the cycle');
+ }
+ };
+
+ return (
+ <Modal title={cycle ? 'Edit cycle' : 'New cycle'} projectKey={projectKey} onClose={onClose}>
+ <div className="flex flex-col gap-4">
+ <div className="flex flex-col gap-1.5">
+ <Label htmlFor="cycle-name">Name</Label>
+ <Input
+ id="cycle-name"
+ value={name}
+ autoFocus
+ onChange={(e) => setName(e.target.value)}
+ onKeyDown={(e) => e.key === 'Enter' && name.trim() && void submit()}
+ />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <Label htmlFor="cycle-goal">Goal</Label>
+ <Textarea
+ id="cycle-goal"
+ value={goal}
+ placeholder="What should this cycle deliver?"
+ onChange={(e) => setGoal(e.target.value)}
+ />
+ </div>
+ {!endLocked && (
+ <div className="flex flex-col gap-1.5">
+ <Label>Length</Label>
+ <CycleLengthPicker days={length} onChange={changeLength} />
+ </div>
+ )}
+ <div className="flex items-center gap-3">
+ <div className="flex flex-col gap-1.5">
+ <Label>Starts</Label>
+ {startLocked ? (
+ <FixedDate value={startDate} />
+ ) : (
+ <DatePill
+ value={startDate}
+ clearable={false}
+ disabled={busy}
+ onChange={(v) => v && changeStart(v)}
+ />
+ )}
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <Label>Ends</Label>
+ {endLocked ? (
+ <FixedDate value={endDate} />
+ ) : (
+ <DatePill
+ value={endDate}
+ clearable={false}
+ disabled={[
+ ...(start ? [{ before: start }] : []),
+ ...(lastDay ? [{ after: lastDay }] : []),
+ ]}
+ onChange={(v) => v && setEndDate(v)}
+ />
+ )}
+ </div>
+ </div>
+ <div className="flex justify-end gap-2">
+ <Button variant="ghost" onClick={onClose}>
+ Cancel
+ </Button>
+ <Button disabled={!name.trim() || saving} onClick={() => void submit()}>
+ {saving ? 'Saving…' : cycle ? 'Save' : 'Create cycle'}
+ </Button>
+ </div>
+ </div>
+ </Modal>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/CycleFormDialog.tsx b/apps/web/src/features/cycles/components/CycleFormDialog.tsx
new file mode 100644
index 00000000..e800e384
--- /dev/null
+++ b/apps/web/src/features/cycles/components/CycleFormDialog.tsx
@@ -0,0 +1,39 @@
+import type { Cycle } from '@/lib/api';
+import Modal from '@/components/common/overlay/Modal';
+import { useCyclesQuery } from '@/services/cycles.service';
+import { cycleDefaults } from '../utils/cycleDefaults';
+import CycleForm from './CycleForm';
+
+// Creating a cycle or editing one. Both need every cycle of the project: a new one
+// is filled in from the last of them, and neither may take dates another one holds.
+// The list is its own request — the cycles page loads the planned ones and pages the
+// rest — so the dialog opens on a placeholder and mounts the form once it is in.
+export default function CycleFormDialog({
+ projectKey,
+ cycle,
+ onClose,
+}: {
+ projectKey: string;
+ cycle?: Cycle;
+ onClose: () => void;
+}) {
+ const { data: cycles } = useCyclesQuery(projectKey);
+
+ if (!cycles) {
+ return (
+ <Modal title={cycle ? 'Edit cycle' : 'New cycle'} projectKey={projectKey} onClose={onClose}>
+ <p className="text-sm text-muted-foreground">Loading…</p>
+ </Modal>
+ );
+ }
+
+ return (
+ <CycleForm
+ projectKey={projectKey}
+ cycle={cycle}
+ cycles={cycles}
+ defaults={cycleDefaults(cycles)}
+ onClose={onClose}
+ />
+ );
+}
diff --git a/apps/web/src/features/cycles/components/CycleLengthPicker.tsx b/apps/web/src/features/cycles/components/CycleLengthPicker.tsx
new file mode 100644
index 00000000..8d5e2d91
--- /dev/null
+++ b/apps/web/src/features/cycles/components/CycleLengthPicker.tsx
@@ -0,0 +1,30 @@
+import { Button } from '@/components/ui/button';
+import { CYCLE_LENGTHS } from '../utils/cycleDefaults';
+
+// The cycle length as one click per common option, so the end date rarely has to be
+// picked by hand. `days` is the length the two dates currently span, which
+// highlights the matching option and stays unhighlighted for a hand-picked range.
+export default function CycleLengthPicker({
+ days,
+ onChange,
+}: {
+ days: number;
+ onChange: (days: number) => void;
+}) {
+ return (
+ <div className="flex items-center gap-1.5">
+ {CYCLE_LENGTHS.map((length) => (
+ <Button
+ key={length}
+ type="button"
+ size="sm"
+ variant={days === length ? 'secondary' : 'outline'}
+ className="h-7 px-2.5 text-xs font-normal"
+ onClick={() => onChange(length)}
+ >
+ {length / 7} {length === 7 ? 'week' : 'weeks'}
+ </Button>
+ ))}
+ </div>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/FixedDate.tsx b/apps/web/src/features/cycles/components/FixedDate.tsx
new file mode 100644
index 00000000..c27a4a50
--- /dev/null
+++ b/apps/web/src/features/cycles/components/FixedDate.tsx
@@ -0,0 +1,8 @@
+import { formatDate } from '@/utils/dates';
+
+// A date the form cannot change, written out plainly. A control that opens nothing
+// would read as editable, so a running or finished cycle shows its fixed dates as
+// text instead.
+export default function FixedDate({ value }: { value: string }) {
+ return <span className="flex h-7 items-center px-1 text-sm">{formatDate(value)}</span>;
+}
diff --git a/apps/web/src/features/cycles/components/TransferIssuesDialog.tsx b/apps/web/src/features/cycles/components/TransferIssuesDialog.tsx
new file mode 100644
index 00000000..1286be59
--- /dev/null
+++ b/apps/web/src/features/cycles/components/TransferIssuesDialog.tsx
@@ -0,0 +1,84 @@
+import { useState } from 'react';
+import { toast } from 'sonner';
+import { ApiError, type Cycle } from '@/lib/api';
+import { formatShortDate } from '@/utils/dates';
+import Modal from '@/components/common/overlay/Modal';
+import { Button } from '@/components/ui/button';
+import { Label } from '@/components/ui/label';
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from '@/components/ui/select';
+import { usePlannedCyclesQuery, useTransferCycleIssues } from '@/services/cycles.service';
+
+// Moves the cycle's unfinished issues elsewhere. The target is another cycle the
+// project has not finished yet, or "No cycle", which leaves them unplanned. Finished
+// issues stay on this cycle, so it keeps recording what it delivered.
+const NO_CYCLE = 'none';
+
+export default function TransferIssuesDialog({
+ cycle,
+ projectKey,
+ onClose,
+}: {
+ cycle: Cycle;
+ projectKey: string;
+ onClose: () => void;
+}) {
+ const [target, setTarget] = useState<string>(NO_CYCLE);
+ const transfer = useTransferCycleIssues(projectKey);
+ const targets = (usePlannedCyclesQuery(projectKey).data ?? []).filter((c) => c.id !== cycle.id);
+
+ const submit = async () => {
+ try {
+ const { moved } = await transfer.mutateAsync({
+ id: cycle.id,
+ targetCycleId: target === NO_CYCLE ? null : Number(target),
+ });
+ toast.success(moved === 1 ? '1 issue moved' : `${moved} issues moved`);
+ onClose();
+ } catch (err) {
+ toast.error(err instanceof ApiError ? err.message : 'Could not move the issues');
+ }
+ };
+
+ return (
+ <Modal
+ title="Transfer unfinished issues"
+ crumb={cycle.name}
+ description="Issues that are not completed or canceled move to the cycle you pick. The rest stay here."
+ projectKey={projectKey}
+ onClose={onClose}
+ >
+ <div className="flex flex-col gap-4">
+ <div className="flex flex-col gap-1.5">
+ <Label htmlFor="transfer-target">Move to</Label>
+ <Select value={target} onValueChange={setTarget}>
+ <SelectTrigger id="transfer-target">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value={NO_CYCLE}>No cycle</SelectItem>
+ {targets.map((c) => (
+ <SelectItem key={c.id} value={String(c.id)}>
+ {c.name} ({formatShortDate(c.startDate)} – {formatShortDate(c.endDate)})
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </div>
+ <div className="flex justify-end gap-2">
+ <Button variant="ghost" onClick={onClose}>
+ Cancel
+ </Button>
+ <Button disabled={transfer.isPending} onClick={() => void submit()}>
+ {transfer.isPending ? 'Moving…' : 'Move issues'}
+ </Button>
+ </div>
+ </div>
+ </Modal>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/detail/CycleHeader.tsx b/apps/web/src/features/cycles/components/detail/CycleHeader.tsx
new file mode 100644
index 00000000..26b3465a
--- /dev/null
+++ b/apps/web/src/features/cycles/components/detail/CycleHeader.tsx
@@ -0,0 +1,36 @@
+'use client';
+
+import type { Cycle } from '@/lib/api';
+import { formatShortDate } from '@/utils/dates';
+import { CYCLE_STATUS_META } from '@/utils/cycleMeta';
+import { colorDot } from '@/components/common/fields/colorDot';
+import ProgressBar from '@/components/common/ProgressBar';
+import CycleActions from '../CycleActions';
+
+// The cycle detail header: name, the status its dates put it in, the range, and how
+// much of it is done. Editing happens in the overflow menu dialog.
+export default function CycleHeader({ cycle, projectKey }: { cycle: Cycle; projectKey: string }) {
+ const status = CYCLE_STATUS_META[cycle.status];
+
+ return (
+ <div className="flex flex-wrap items-center justify-between gap-x-2 gap-y-1.5 border-b px-6 py-2.5">
+ <div className="flex flex-wrap items-center gap-2">
+ <span className="text-sm font-semibold">{cycle.name}</span>
+ <span className="flex items-center gap-1.5 text-xs text-muted-foreground">
+ {colorDot(status.color)}
+ {status.label}
+ </span>
+ <span className="text-xs text-muted-foreground">
+ {formatShortDate(cycle.startDate)} – {formatShortDate(cycle.endDate)}
+ </span>
+ {cycle.goal && (
+ <span className="max-w-md truncate text-xs text-muted-foreground">{cycle.goal}</span>
+ )}
+ </div>
+ <div className="flex items-center gap-3">
+ <ProgressBar progress={cycle.progress} />
+ <CycleActions cycle={cycle} projectKey={projectKey} />
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/detail/CycleIssuesBoard.tsx b/apps/web/src/features/cycles/components/detail/CycleIssuesBoard.tsx
new file mode 100644
index 00000000..b14966b2
--- /dev/null
+++ b/apps/web/src/features/cycles/components/detail/CycleIssuesBoard.tsx
@@ -0,0 +1,82 @@
+'use client';
+
+import { useMemo } from 'react';
+import type { Cycle } from '@/lib/api';
+import { useShell } from '@/context/shellContext';
+import { applyFilters } from '@/utils/filters';
+import { useLocalBoardSettings } from '@/hooks/useLocalBoardSettings';
+import FilterBar from '@/components/layout/FilterBar';
+import DisplayPopover from '@/components/layout/DisplayPopover';
+import KanbanBoard from '@/features/work-items/components/kanban/KanbanBoard';
+import TableView from '@/features/work-items/components/table/TableView';
+import TimelineView from '@/features/work-items/components/timeline/TimelineView';
+import CalendarView from '@/features/work-items/components/calendar/CalendarView';
+
+// Where this board's layout and display settings are kept, per cycle.
+const CYCLE_BOARD_STORE_KEY = 'planner_cycle_board_settings';
+
+// The cycle's issues rendered as the work items board (kanban/table/timeline/
+// calendar) with filters and display settings, but no saved views. The board is fed
+// a project whose issues are just this cycle's, so drag/edit still hit the real
+// issues and the live board refresh keeps it current. On a finished cycle a new
+// issue is created without one: nothing is planned into a cycle that has ended.
+export default function CycleIssuesBoard({ cycle }: { cycle: Cycle }) {
+ const { project, customFields, onOpenIssue, onAddIssue } = useShell();
+ const cycleId = cycle.id;
+ const board = useLocalBoardSettings(CYCLE_BOARD_STORE_KEY, cycleId);
+
+ const viewProject = useMemo(() => {
+ if (!project) return null;
+ const issues = project.issues.filter((i) => i.cycle?.id === cycleId);
+ return { ...project, issues: applyFilters(issues, board.filters, project) };
+ }, [project, cycleId, board.filters]);
+
+ if (!project || !viewProject) return null;
+
+ const viewProps = {
+ project: viewProject,
+ customFields,
+ settings: board.settings,
+ onSettingsChange: board.changeSettings,
+ onOpenIssue,
+ onAddIssue: (defaults: Parameters<typeof onAddIssue>[0]) =>
+ onAddIssue(cycle.status === 'completed' ? defaults : { cycleId, ...defaults }),
+ };
+
+ let view;
+ switch (board.view) {
+ case 'table':
+ view = <TableView {...viewProps} />;
+ break;
+ case 'timeline':
+ view = <TimelineView {...viewProps} />;
+ break;
+ case 'calendar':
+ view = <CalendarView {...viewProps} />;
+ break;
+ default:
+ view = <KanbanBoard {...viewProps} />;
+ }
+
+ return (
+ <div className="flex min-h-0 flex-1 flex-col">
+ <div className="flex items-center justify-between gap-2 border-b px-3 py-2">
+ <FilterBar
+ filters={board.filters}
+ onChange={board.setFilters}
+ project={project}
+ customFields={customFields}
+ />
+ <DisplayPopover
+ view={board.view}
+ onViewChange={board.changeView}
+ settings={board.settings}
+ onSettingsChange={board.changeSettings}
+ customFields={customFields}
+ issueTypes={project.issueTypes}
+ />
+ </div>
+ <div className="relative flex-1 overflow-hidden">{view}</div>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/list/CycleInfoPopover.tsx b/apps/web/src/features/cycles/components/list/CycleInfoPopover.tsx
new file mode 100644
index 00000000..162eed3f
--- /dev/null
+++ b/apps/web/src/features/cycles/components/list/CycleInfoPopover.tsx
@@ -0,0 +1,77 @@
+import Link from 'next/link';
+import { ArrowRight, Info } from 'lucide-react';
+import type { Cycle } from '@/lib/api';
+import { formatShortDate } from '@/utils/dates';
+import { cyclePath } from '@/utils/paths';
+import { CYCLE_STATUS_META } from '@/utils/cycleMeta';
+import { colorDot } from '@/components/common/fields/colorDot';
+import ProgressBar from '@/components/common/ProgressBar';
+import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
+import { cycleLength } from '../../utils/cycleDates';
+
+// The cycle's name in the timeline's label column, opening what does not fit on the
+// track: the goal, the range, and how far the work is. The info icon marks the name
+// as something to click, since a bar next to it is dragged instead.
+export default function CycleInfoPopover({
+ cycle,
+ projectKey,
+}: {
+ cycle: Cycle;
+ projectKey: string;
+}) {
+ const status = CYCLE_STATUS_META[cycle.status];
+
+ return (
+ <Popover>
+ <PopoverTrigger asChild>
+ <button
+ type="button"
+ className="group/name flex w-full min-w-0 items-center gap-2 text-left"
+ title="Cycle details"
+ >
+ {colorDot(status.color)}
+ <span className="min-w-0 flex-1 truncate text-sm">{cycle.name}</span>
+ <Info className="size-3.5 shrink-0 text-muted-foreground/50 group-hover/name:text-foreground" />
+ </button>
+ </PopoverTrigger>
+
+ <PopoverContent align="start" side="right" className="w-72 p-0 text-sm">
+ <div className="flex flex-col gap-2 px-3.5 py-3">
+ <div className="flex items-center justify-between gap-2">
+ <span className="truncate font-medium">{cycle.name}</span>
+ <span className="flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground">
+ {colorDot(status.color)}
+ {status.label}
+ </span>
+ </div>
+ <p className="text-xs text-muted-foreground">
+ {formatShortDate(cycle.startDate)} – {formatShortDate(cycle.endDate)} ·{' '}
+ {cycleLength(cycle)}d
+ </p>
+ </div>
+
+ <div className="border-t border-border px-3.5 py-3">
+ <p className="text-xs font-medium text-muted-foreground">Goal</p>
+ <p className="mt-1 text-xs leading-snug whitespace-pre-wrap">
+ {cycle.goal || <span className="text-muted-foreground">No goal set.</span>}
+ </p>
+ </div>
+
+ <div className="border-t border-border px-3.5 py-3">
+ <p className="text-xs font-medium text-muted-foreground">Progress</p>
+ <div className="mt-2">
+ <ProgressBar progress={cycle.progress} wide />
+ </div>
+ </div>
+
+ <Link
+ href={cyclePath(projectKey, cycle.id)}
+ className="flex items-center justify-between border-t border-border px-3.5 py-2.5 text-xs font-medium text-muted-foreground hover:text-foreground"
+ >
+ Open cycle
+ <ArrowRight className="size-3.5" />
+ </Link>
+ </PopoverContent>
+ </Popover>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/list/CycleTableArchive.tsx b/apps/web/src/features/cycles/components/list/CycleTableArchive.tsx
new file mode 100644
index 00000000..d7093a07
--- /dev/null
+++ b/apps/web/src/features/cycles/components/list/CycleTableArchive.tsx
@@ -0,0 +1,53 @@
+import { useState } from 'react';
+import ShowMoreButton from '@/components/common/ShowMoreButton';
+import { CYCLE_STATUS_META } from '@/utils/cycleMeta';
+import type { CompletedCycles } from '../../hooks/useCompletedCycles';
+import CycleTableSection from './CycleTableSection';
+import CycleTableRow from './CycleTableRow';
+
+// The finished cycles at the bottom of the table, newest first. The header carries
+// how many there are in all, so the group says what it holds while folded; opening
+// it shows the pages loaded so far and asks for the next one on demand. Unlike the
+// planned groups, this one is not remembered: it starts folded every time, so what
+// is running and what is next are what the table opens on.
+export default function CycleTableArchive({
+ completed,
+ projectKey,
+ gridTemplate,
+}: {
+ completed: CompletedCycles;
+ projectKey: string;
+ gridTemplate: string;
+}) {
+ const [collapsed, setCollapsed] = useState(true);
+ const { label, color } = CYCLE_STATUS_META.completed;
+
+ return (
+ <>
+ <CycleTableSection
+ label={label}
+ color={color}
+ count={completed.total}
+ collapsed={collapsed}
+ onToggle={() => setCollapsed((folded) => !folded)}
+ />
+ {!collapsed && (
+ <>
+ {completed.items.map((cycle) => (
+ <CycleTableRow
+ key={cycle.id}
+ cycle={cycle}
+ projectKey={projectKey}
+ gridTemplate={gridTemplate}
+ />
+ ))}
+ {completed.hasMore && (
+ <div className="px-4">
+ <ShowMoreButton loading={completed.isLoadingMore} onClick={completed.loadMore} />
+ </div>
+ )}
+ </>
+ )}
+ </>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/list/CycleTableRow.tsx b/apps/web/src/features/cycles/components/list/CycleTableRow.tsx
new file mode 100644
index 00000000..dbe07a67
--- /dev/null
+++ b/apps/web/src/features/cycles/components/list/CycleTableRow.tsx
@@ -0,0 +1,57 @@
+import Link from 'next/link';
+import { useRouter } from 'next/navigation';
+import type { Cycle } from '@/lib/api';
+import { cyclePath } from '@/utils/paths';
+import { formatShortDate } from '@/utils/dates';
+import ProgressBar from '@/components/common/ProgressBar';
+import CycleActions from '../CycleActions';
+import { cycleLength, daysLeft } from '../../utils/cycleDates';
+
+// One cycle as a table row. The whole row navigates to the cycle; the name is also
+// a real anchor so middle/cmd-click opens it in a new tab.
+export default function CycleTableRow({
+ cycle,
+ projectKey,
+ gridTemplate,
+}: {
+ cycle: Cycle;
+ projectKey: string;
+ gridTemplate: string;
+}) {
+ const router = useRouter();
+ const href = cyclePath(projectKey, cycle.id);
+
+ return (
+ <div
+ onClick={() => router.push(href)}
+ className="grid cursor-pointer items-center gap-3 border-b px-4 py-2 text-sm hover:bg-accent/40"
+ style={{ gridTemplateColumns: gridTemplate }}
+ >
+ <div className="flex min-w-0 items-center gap-2">
+ <Link
+ href={href}
+ onClick={(e) => e.stopPropagation()}
+ className="truncate font-medium hover:underline"
+ >
+ {cycle.name}
+ </Link>
+ {cycle.goal && <span className="truncate text-xs text-muted-foreground">{cycle.goal}</span>}
+ </div>
+
+ <span className="text-xs text-muted-foreground">
+ {formatShortDate(cycle.startDate)} – {formatShortDate(cycle.endDate)}
+ {cycle.status === 'active' && ` · ${daysLeft(cycle)}d left`}
+ </span>
+
+ <span className="text-xs text-muted-foreground tabular-nums">{cycleLength(cycle)}d</span>
+
+ <span className="text-xs text-muted-foreground tabular-nums">{cycle.progress.total}</span>
+
+ <ProgressBar progress={cycle.progress} />
+
+ <div onClick={(e) => e.stopPropagation()} className="flex justify-end">
+ <CycleActions cycle={cycle} projectKey={projectKey} />
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/list/CycleTableSection.tsx b/apps/web/src/features/cycles/components/list/CycleTableSection.tsx
new file mode 100644
index 00000000..5f5ef0e2
--- /dev/null
+++ b/apps/web/src/features/cycles/components/list/CycleTableSection.tsx
@@ -0,0 +1,36 @@
+import { ChevronDown, ChevronRight } from 'lucide-react';
+import { colorDot } from '@/components/common/fields/colorDot';
+
+// A group header above the cycles of one status, collapsible like the work items
+// table sections. `count` is how many cycles the group holds in all, which for the
+// archive is more than the rows loaded under it.
+export default function CycleTableSection({
+ label,
+ color,
+ count,
+ collapsed,
+ onToggle,
+}: {
+ label: string;
+ color: string;
+ count: number;
+ collapsed: boolean;
+ onToggle: () => void;
+}) {
+ return (
+ <button
+ type="button"
+ onClick={onToggle}
+ className="flex w-full items-center gap-2 bg-muted/40 px-4 py-1.5 text-sm font-medium text-foreground"
+ >
+ {collapsed ? (
+ <ChevronRight className="size-3.5 text-muted-foreground" />
+ ) : (
+ <ChevronDown className="size-3.5 text-muted-foreground" />
+ )}
+ {colorDot(color)}
+ {label}
+ <span className="text-muted-foreground">{count}</span>
+ </button>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/list/CycleTimelineGroupRow.tsx b/apps/web/src/features/cycles/components/list/CycleTimelineGroupRow.tsx
new file mode 100644
index 00000000..cff494ee
--- /dev/null
+++ b/apps/web/src/features/cycles/components/list/CycleTimelineGroupRow.tsx
@@ -0,0 +1,29 @@
+import { colorDot } from '@/components/common/fields/colorDot';
+import type { CycleGroup } from '../../utils/cycleGroups';
+import { CYCLE_GROUP_H } from '../../utils/cycleTimeline';
+
+// A group header row on the timeline: the status and how many cycles it holds, with
+// an empty band across the day track.
+export default function CycleTimelineGroupRow({
+ group,
+ labelW,
+ trackWidth,
+}: {
+ group: CycleGroup;
+ labelW: number;
+ trackWidth: number;
+}) {
+ return (
+ <div className="flex border-b bg-muted/40" style={{ height: CYCLE_GROUP_H }}>
+ <div
+ className="sticky left-0 z-10 flex shrink-0 items-center gap-2 border-r bg-muted px-3 text-sm font-medium"
+ style={{ width: labelW }}
+ >
+ {colorDot(group.color)}
+ <span className="truncate">{group.label}</span>
+ <span className="text-muted-foreground">{group.cycles.length}</span>
+ </div>
+ <div style={{ width: trackWidth }} />
+ </div>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/list/CycleTimelineRow.tsx b/apps/web/src/features/cycles/components/list/CycleTimelineRow.tsx
new file mode 100644
index 00000000..ab08af31
--- /dev/null
+++ b/apps/web/src/features/cycles/components/list/CycleTimelineRow.tsx
@@ -0,0 +1,110 @@
+import { CalendarRange, CircleDashed } from 'lucide-react';
+import type { Cycle } from '@/lib/api';
+import { CYCLE_STATUS_META } from '@/utils/cycleMeta';
+import { formatShortDate } from '@/utils/dates';
+import { progressPercent } from '@/utils/progress';
+import { cn } from '@/lib/utils';
+import type { CycleDragMode } from '../../hooks/useCycleDrag';
+import { cycleLength, movableEnds } from '../../utils/cycleDates';
+import { CYCLE_ROW_H } from '../../utils/cycleTimeline';
+import CycleInfoPopover from './CycleInfoPopover';
+
+// One cycle row: the sticky label on the left and its bar on the day track. The bar
+// moves the cycle or resizes one end, within what the cycle's status still allows.
+// The length and issue counts read after the bar, so a short bar still has room for
+// them. With edit rights every gesture on the bar goes through the drag handler,
+// which opens the cycle when the pointer did not travel; without them the bar is a
+// plain click that opens it.
+export default function CycleTimelineRow({
+ cycle,
+ projectKey,
+ rect,
+ labelW,
+ trackWidth,
+ dayLines,
+ todayInRange,
+ todayLeft,
+ canEdit,
+ onBeginDrag,
+ onOpen,
+}: {
+ cycle: Cycle;
+ projectKey: string;
+ rect: { left: number; width: number };
+ labelW: number;
+ trackWidth: number;
+ dayLines: { backgroundImage: string };
+ todayInRange: boolean;
+ todayLeft: number;
+ canEdit: boolean;
+ onBeginDrag: (e: React.PointerEvent, cycle: Cycle, mode: CycleDragMode) => void;
+ onOpen: (id: number) => void;
+}) {
+ const color = CYCLE_STATUS_META[cycle.status].color;
+ const ends = movableEnds(cycle.status);
+ const canMove = canEdit && ends.move;
+
+ return (
+ <div className="flex border-b hover:bg-accent/20" style={{ height: CYCLE_ROW_H }}>
+ <div
+ className="sticky left-0 z-10 flex shrink-0 items-center overflow-hidden border-r bg-background px-3"
+ style={{ width: labelW }}
+ >
+ <CycleInfoPopover cycle={cycle} projectKey={projectKey} />
+ </div>
+
+ <div className="relative" style={{ width: trackWidth, ...dayLines }}>
+ {todayInRange && (
+ <div
+ className="absolute top-0 bottom-0 z-0 w-px bg-primary/40"
+ style={{ left: todayLeft }}
+ />
+ )}
+ <div
+ onPointerDown={canEdit ? (e) => onBeginDrag(e, cycle, 'move') : undefined}
+ onClick={canEdit ? undefined : () => onOpen(cycle.id)}
+ title={`${formatShortDate(cycle.startDate)} – ${formatShortDate(cycle.endDate)}`}
+ className={cn(
+ 'group absolute top-1/2 z-10 flex h-6 -translate-y-1/2 items-center overflow-hidden rounded px-1.5 text-white select-none',
+ canMove ? 'cursor-grab' : 'cursor-pointer',
+ )}
+ style={{ left: rect.left, width: rect.width, backgroundColor: color }}
+ >
+ <div
+ className="absolute inset-y-0 left-0 bg-white/30"
+ style={{ width: `${progressPercent(cycle.progress)}%` }}
+ />
+ {canEdit && ends.start && (
+ <span
+ onPointerDown={(e) => onBeginDrag(e, cycle, 'start')}
+ className="absolute top-0 left-0 h-full w-1.5 cursor-ew-resize bg-white/40 opacity-0 group-hover:opacity-100"
+ />
+ )}
+ <span className="relative truncate text-[11px] leading-none">{cycle.name}</span>
+ {canEdit && ends.end && (
+ <span
+ onPointerDown={(e) => onBeginDrag(e, cycle, 'end')}
+ className="absolute top-0 right-0 h-full w-1.5 cursor-ew-resize bg-white/40 opacity-0 group-hover:opacity-100"
+ />
+ )}
+ </div>
+
+ <div
+ className="pointer-events-none absolute top-1/2 flex -translate-y-1/2 items-center gap-2.5 text-[11px] whitespace-nowrap text-muted-foreground tabular-nums"
+ style={{ left: rect.left + rect.width + 8 }}
+ >
+ <span className="flex items-center gap-1" title="Length">
+ <CalendarRange className="size-3" />
+ {cycleLength(cycle)}d
+ </span>
+ {cycle.progress.total > 0 && (
+ <span className="flex items-center gap-1" title="Issues done">
+ <CircleDashed className="size-3" />
+ {cycle.progress.completed}/{cycle.progress.total - cycle.progress.canceled}
+ </span>
+ )}
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/list/CyclesList.tsx b/apps/web/src/features/cycles/components/list/CyclesList.tsx
new file mode 100644
index 00000000..eea3a753
--- /dev/null
+++ b/apps/web/src/features/cycles/components/list/CyclesList.tsx
@@ -0,0 +1,65 @@
+import type { Cycle } from '@/lib/api';
+import type { CyclesView } from '@/utils/paths';
+import { Button } from '@/components/ui/button';
+import { EmptyState } from '@/components/common/page/EmptyState';
+import type { CompletedCycles } from '../../hooks/useCompletedCycles';
+import CyclesTable from './CyclesTable';
+import CyclesTimeline from './CyclesTimeline';
+
+// The cycles of a project in the layout the user picked: a grouped table or a day
+// track. `cycles` is what is still planned — active and upcoming. The finished ones
+// are the table's archive; the timeline draws only what is ahead, but still takes
+// them, since a dragged cycle may not run into one either.
+export default function CyclesList({
+ cycles,
+ completed,
+ projectKey,
+ view,
+ isLoading,
+ canCreate,
+ onCreate,
+}: {
+ cycles: Cycle[];
+ completed: CompletedCycles;
+ projectKey: string;
+ view: CyclesView;
+ isLoading: boolean;
+ canCreate: boolean;
+ onCreate: () => void;
+}) {
+ if (isLoading) return <p className="px-4 py-6 text-sm text-muted-foreground">Loading…</p>;
+
+ const newCycleButton = canCreate && (
+ <Button size="sm" onClick={onCreate}>
+ New cycle
+ </Button>
+ );
+
+ if (cycles.length === 0 && completed.total === 0) {
+ return (
+ <EmptyState
+ title="No cycles yet"
+ description="A cycle is a time-boxed period the team plans its issues into."
+ >
+ {newCycleButton}
+ </EmptyState>
+ );
+ }
+
+ if (view === 'table') {
+ return <CyclesTable cycles={cycles} completed={completed} projectKey={projectKey} />;
+ }
+
+ if (cycles.length === 0) {
+ return (
+ <EmptyState
+ title="Nothing planned"
+ description="The timeline shows active and upcoming cycles. Finished ones are in the table."
+ >
+ {newCycleButton}
+ </EmptyState>
+ );
+ }
+
+ return <CyclesTimeline cycles={cycles} finished={completed.items} projectKey={projectKey} />;
+}
diff --git a/apps/web/src/features/cycles/components/list/CyclesTable.tsx b/apps/web/src/features/cycles/components/list/CyclesTable.tsx
new file mode 100644
index 00000000..cdfbc659
--- /dev/null
+++ b/apps/web/src/features/cycles/components/list/CyclesTable.tsx
@@ -0,0 +1,73 @@
+import { Fragment } from 'react';
+import type { Cycle } from '@/lib/api';
+import { usePersistedSet } from '@/hooks/usePersistedSet';
+import { groupCycles } from '../../utils/cycleGroups';
+import type { CompletedCycles } from '../../hooks/useCompletedCycles';
+import CycleTableSection from './CycleTableSection';
+import CycleTableRow from './CycleTableRow';
+import CycleTableArchive from './CycleTableArchive';
+
+// The header row and every cycle row share this template, so the labels line up
+// with the cells below them.
+const GRID = 'minmax(200px,1fr) 200px 60px 56px 132px 32px';
+
+// The project's cycles as one table: the planned ones grouped by the status their
+// dates put them in, then the archive of the finished ones. Each planned group folds
+// away, and which ones are folded is remembered per project.
+export default function CyclesTable({
+ cycles,
+ completed,
+ projectKey,
+}: {
+ cycles: Cycle[];
+ completed: CompletedCycles;
+ projectKey: string;
+}) {
+ const collapsed = usePersistedSet(`cycles-collapsed:${projectKey}`);
+
+ return (
+ <div className="flex-1 overflow-auto">
+ <div className="min-w-[760px]">
+ <div
+ className="sticky top-0 z-10 grid items-center gap-3 border-b bg-background px-4 py-2 text-xs font-medium text-muted-foreground"
+ style={{ gridTemplateColumns: GRID }}
+ >
+ <span>Name</span>
+ <span>Dates</span>
+ <span>Length</span>
+ <span>Issues</span>
+ <span>Progress</span>
+ <span />
+ </div>
+
+ {groupCycles(cycles).map((group) => {
+ const isCollapsed = collapsed.values.has(group.status);
+ return (
+ <Fragment key={group.status}>
+ <CycleTableSection
+ label={group.label}
+ color={group.color}
+ count={group.cycles.length}
+ collapsed={isCollapsed}
+ onToggle={() => collapsed.toggle(group.status)}
+ />
+ {!isCollapsed &&
+ group.cycles.map((cycle) => (
+ <CycleTableRow
+ key={cycle.id}
+ cycle={cycle}
+ projectKey={projectKey}
+ gridTemplate={GRID}
+ />
+ ))}
+ </Fragment>
+ );
+ })}
+
+ {completed.total > 0 && (
+ <CycleTableArchive completed={completed} projectKey={projectKey} gridTemplate={GRID} />
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/list/CyclesTimeline.tsx b/apps/web/src/features/cycles/components/list/CyclesTimeline.tsx
new file mode 100644
index 00000000..b7c6547b
--- /dev/null
+++ b/apps/web/src/features/cycles/components/list/CyclesTimeline.tsx
@@ -0,0 +1,105 @@
+import { useEffect, useRef } from 'react';
+import { useRouter } from 'next/navigation';
+import type { Cycle } from '@/lib/api';
+import { cyclePath } from '@/utils/paths';
+import { usePermissions } from '@/hooks/usePermissions';
+import { useElementWidth } from '@/hooks/useElementWidth';
+import { useTimelineLabelWidth } from '@/hooks/useTimelineLabelWidth';
+import { LABEL_NARROW_W } from '@/utils/timelineTrack';
+import { TimelineHeader } from '@/components/common/timeline/TimelineHeader';
+import { TimelineLabelResizer } from '@/components/common/timeline/TimelineLabelResizer';
+import { useCycleDrag } from '../../hooks/useCycleDrag';
+import { buildCycleTimeline, CYCLE_DAY_W, cycleLabelWidthKey } from '../../utils/cycleTimeline';
+import CycleTimelineGroupRow from './CycleTimelineGroupRow';
+import CycleTimelineRow from './CycleTimelineRow';
+
+// The project's cycles on a day track, in the same groups as the table. Dragging a
+// bar rewrites the cycle's dates; the track opens scrolled to today.
+export default function CyclesTimeline({
+ cycles,
+ finished,
+ projectKey,
+}: {
+ cycles: Cycle[];
+ // Not drawn, but a drag is clamped off them too.
+ finished: Cycle[];
+ projectKey: string;
+}) {
+ const router = useRouter();
+ const { can } = usePermissions();
+ const scrollRef = useRef<HTMLDivElement>(null);
+ const scrolledToToday = useRef(false);
+ // Width of the scroll area, so the track extends with trailing days until it
+ // fills the viewport instead of leaving empty space on the right.
+ const viewportW = useElementWidth(scrollRef);
+
+ const openCycle = (id: number) => router.push(cyclePath(projectKey, id));
+ const canEdit = can('cycles', 'edit');
+ const { width: labelWidth, setWidth: setLabelWidth } = useTimelineLabelWidth(
+ cycleLabelWidthKey(projectKey),
+ );
+ // Narrow the sticky label column on small screens so the day track is usable; on
+ // wider ones it is the width the grip was dragged to.
+ const narrow = viewportW < 640;
+ const labelW = narrow ? LABEL_NARROW_W : labelWidth;
+ const { rows, days, months, trackWidth, todayLeft, todayInRange, dayLines, spanToRect } =
+ buildCycleTimeline({ cycles, viewportW, labelW, dayW: CYCLE_DAY_W });
+ const { preview, beginDrag } = useCycleDrag({
+ projectKey,
+ cycles: [...cycles, ...finished],
+ dayW: CYCLE_DAY_W,
+ onOpen: openCycle,
+ });
+
+ useEffect(() => {
+ const el = scrollRef.current;
+ if (!el || scrolledToToday.current || rows.length === 0) return;
+ scrolledToToday.current = true;
+ el.scrollLeft = Math.max(0, todayLeft - labelW);
+ }, [rows.length, todayLeft, labelW]);
+
+ return (
+ <div ref={scrollRef} className="flex-1 overflow-auto">
+ <div className="relative" style={{ width: labelW + trackWidth }}>
+ <TimelineHeader
+ labelW={labelW}
+ trackWidth={trackWidth}
+ dayW={CYCLE_DAY_W}
+ months={months}
+ days={days}
+ />
+ {!narrow && <TimelineLabelResizer labelW={labelW} onResize={setLabelWidth} />}
+
+ {rows.map((row) =>
+ row.kind === 'group' ? (
+ <CycleTimelineGroupRow
+ key={`g-${row.group.status}`}
+ group={row.group}
+ labelW={labelW}
+ trackWidth={trackWidth}
+ />
+ ) : (
+ <CycleTimelineRow
+ key={row.cycle.id}
+ cycle={row.cycle}
+ projectKey={projectKey}
+ rect={
+ preview?.cycleId === row.cycle.id
+ ? spanToRect(preview.start, preview.end)
+ : spanToRect(row.span.start, row.span.end)
+ }
+ labelW={labelW}
+ trackWidth={trackWidth}
+ dayLines={dayLines}
+ todayInRange={todayInRange}
+ todayLeft={todayLeft}
+ canEdit={canEdit}
+ onBeginDrag={beginDrag}
+ onOpen={openCycle}
+ />
+ ),
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/list/CyclesViewTabs.tsx b/apps/web/src/features/cycles/components/list/CyclesViewTabs.tsx
new file mode 100644
index 00000000..f6b66cb8
--- /dev/null
+++ b/apps/web/src/features/cycles/components/list/CyclesViewTabs.tsx
@@ -0,0 +1,37 @@
+import { GanttChart, Table2, type LucideIcon } from 'lucide-react';
+import type { CyclesView } from '@/utils/paths';
+import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
+
+const TABS: { value: CyclesView; label: string; icon: LucideIcon }[] = [
+ { value: 'table', label: 'Table', icon: Table2 },
+ { value: 'timeline', label: 'Timeline', icon: GanttChart },
+];
+
+// The cycles list layout switcher: the grouped table or the day track. The open
+// layout comes from the route, so Radix drives no selection of its own and each
+// trigger navigates on click.
+export default function CyclesViewTabs({
+ view,
+ onSelect,
+}: {
+ view: CyclesView;
+ onSelect: (view: CyclesView) => void;
+}) {
+ return (
+ <Tabs value={view}>
+ <TabsList variant="line" className="overflow-x-auto">
+ {TABS.map(({ value, label, icon: Icon }) => (
+ <TabsTrigger
+ key={value}
+ value={value}
+ className="shrink-0 gap-1.5"
+ onClick={() => onSelect(value)}
+ >
+ <Icon className="size-3.5" />
+ {label}
+ </TabsTrigger>
+ ))}
+ </TabsList>
+ </Tabs>
+ );
+}
diff --git a/apps/web/src/features/cycles/hooks/useCompletedCycles.ts b/apps/web/src/features/cycles/hooks/useCompletedCycles.ts
new file mode 100644
index 00000000..2c095d98
--- /dev/null
+++ b/apps/web/src/features/cycles/hooks/useCompletedCycles.ts
@@ -0,0 +1,25 @@
+import type { Cycle } from '@/lib/api';
+import { useCompletedCyclesQuery } from '@/services/cycles.service';
+
+// The archive as the table reads it: the pages loaded so far as one list, how many
+// finished cycles there are in all, and whether another page is worth asking for.
+export interface CompletedCycles {
+ items: Cycle[];
+ total: number;
+ isLoading: boolean;
+ isLoadingMore: boolean;
+ hasMore: boolean;
+ loadMore: () => void;
+}
+
+export function useCompletedCycles(projectKey: string | null): CompletedCycles {
+ const query = useCompletedCyclesQuery(projectKey);
+ return {
+ items: query.data?.pages.flatMap((page) => page.items) ?? [],
+ total: query.data?.pages[0]?.total ?? 0,
+ isLoading: query.isLoading,
+ isLoadingMore: query.isFetchingNextPage,
+ hasMore: query.hasNextPage,
+ loadMore: () => void query.fetchNextPage(),
+ };
+}
diff --git a/apps/web/src/features/cycles/hooks/useCycleDrag.ts b/apps/web/src/features/cycles/hooks/useCycleDrag.ts
new file mode 100644
index 00000000..17eb41a5
--- /dev/null
+++ b/apps/web/src/features/cycles/hooks/useCycleDrag.ts
@@ -0,0 +1,110 @@
+import { useState } from 'react';
+import { toast } from 'sonner';
+import { ApiError, type Cycle, type CyclePatch } from '@/lib/api';
+import { addDays, daysBetween, toDateStr } from '@/utils/dates';
+import { useUpdateCycle } from '@/services/cycles.service';
+import { cycleSpan, dateWindow, movableEnds } from '../utils/cycleDates';
+
+// Whether a bar drag moves the whole cycle or resizes one end.
+export type CycleDragMode = 'move' | 'start' | 'end';
+
+// A gesture that stays within this many pixels is a click, not a drag.
+const CLICK_SLOP = 3;
+
+// Pointer-drag state and handler for the cycles timeline. A drag rewrites the
+// cycle's dates; a press that does not travel opens the cycle. Every pointer
+// gesture on a bar goes through here rather than through a click handler, so the
+// click the browser fires after a drag cannot also open the cycle. The dates are
+// held inside the gap the neighbouring cycles leave, so a drag never produces an
+// overlap the API would reject. `preview` is the in-progress range of the dragged
+// cycle.
+export function useCycleDrag({
+ projectKey,
+ cycles,
+ dayW,
+ onOpen,
+}: {
+ projectKey: string;
+ cycles: Cycle[];
+ dayW: number;
+ onOpen: (id: number) => void;
+}) {
+ const update = useUpdateCycle(projectKey);
+ const [preview, setPreview] = useState<{ cycleId: number; start: Date; end: Date } | null>(null);
+
+ function beginDrag(e: React.PointerEvent, cycle: Cycle, mode: CycleDragMode) {
+ e.preventDefault();
+ e.stopPropagation();
+ const span = cycleSpan(cycle);
+ if (!span) return;
+ const limits = dateWindow(cycles, cycle);
+ const ends = movableEnds(cycle.status);
+ const startX = e.clientX;
+ const current = { start: span.start, end: span.end };
+ let travelled = false;
+
+ const onMove = (ev: PointerEvent) => {
+ if (Math.abs(ev.clientX - startX) > CLICK_SLOP) travelled = true;
+ const delta = Math.round((ev.clientX - startX) / dayW);
+ if (!ends[mode]) return;
+ if (mode === 'move') {
+ const min = limits.from ? -daysBetween(limits.from, span.start) : -Infinity;
+ const max = limits.to ? daysBetween(span.end, limits.to) : Infinity;
+ const held = Math.min(Math.max(delta, min), max);
+ current.start = addDays(span.start, held);
+ current.end = addDays(span.end, held);
+ } else if (mode === 'start') {
+ let start = addDays(span.start, delta);
+ if (limits.from && start < limits.from) start = limits.from;
+ if (start > span.end) start = span.end;
+ current.start = start;
+ } else {
+ let end = addDays(span.end, delta);
+ if (limits.to && end > limits.to) end = limits.to;
+ if (end < span.start) end = span.start;
+ current.end = end;
+ }
+ setPreview({ cycleId: cycle.id, start: current.start, end: current.end });
+ };
+
+ // Also bound to pointercancel: a gesture the browser takes over (a touch
+ // scroll, a system gesture) never reaches pointerup, and would otherwise leave
+ // the listeners bound and the bar stuck at its preview position.
+ const endDrag = () => {
+ window.removeEventListener('pointermove', onMove);
+ window.removeEventListener('pointerup', onUp);
+ window.removeEventListener('pointercancel', endDrag);
+ setPreview(null);
+ };
+
+ const onUp = () => {
+ endDrag();
+
+ const patch: CyclePatch = {};
+ const startDate = toDateStr(current.start);
+ const endDate = toDateStr(current.end);
+ if (mode !== 'end' && startDate !== cycle.startDate) patch.startDate = startDate;
+ if (mode !== 'start' && endDate !== cycle.endDate) patch.endDate = endDate;
+
+ // A press that stayed put opens the cycle; a drag that changed no date (it
+ // ran into a neighbour, or the status locks that end) leaves it alone.
+ if (Object.keys(patch).length === 0) {
+ if (!travelled) onOpen(cycle.id);
+ return;
+ }
+ update.mutate(
+ { id: cycle.id, patch },
+ {
+ onError: (err) =>
+ toast.error(err instanceof ApiError ? err.message : 'Could not move the cycle'),
+ },
+ );
+ };
+
+ window.addEventListener('pointermove', onMove);
+ window.addEventListener('pointerup', onUp);
+ window.addEventListener('pointercancel', endDrag);
+ }
+
+ return { preview, beginDrag };
+}
diff --git a/apps/web/src/features/cycles/utils/cycleDates.ts b/apps/web/src/features/cycles/utils/cycleDates.ts
new file mode 100644
index 00000000..6f914687
--- /dev/null
+++ b/apps/web/src/features/cycles/utils/cycleDates.ts
@@ -0,0 +1,57 @@
+import type { Cycle, CycleStatus } from '@/lib/api';
+import { addDays, daysBetween, parseDate } from '@/utils/dates';
+
+export interface CycleSpan {
+ start: Date;
+ end: Date;
+}
+
+export function cycleSpan(cycle: Cycle): CycleSpan | null {
+ const start = parseDate(cycle.startDate);
+ const end = parseDate(cycle.endDate);
+ return start && end ? { start, end } : null;
+}
+
+// The cycle's length in days, both ends counted. 0 when a date does not parse.
+export function cycleLength(cycle: Cycle): number {
+ const span = cycleSpan(cycle);
+ return span ? daysBetween(span.start, span.end) + 1 : 0;
+}
+
+// Days from today to the last day, both counted; negative once the cycle is over.
+export function daysLeft(cycle: Cycle): number {
+ const span = cycleSpan(cycle);
+ return span ? daysBetween(new Date(), span.end) + 1 : 0;
+}
+
+// Which ends of a cycle may still move, mirroring what the API accepts: an upcoming
+// cycle moves freely, a running one may only be cut short or extended, a finished
+// one keeps its dates.
+export function movableEnds(status: CycleStatus): { move: boolean; start: boolean; end: boolean } {
+ return {
+ move: status === 'upcoming',
+ start: status === 'upcoming',
+ end: status !== 'completed',
+ };
+}
+
+// The days a cycle's dates may move within: the gap left by the cycles around it,
+// since cycles of one project may not overlap. Null on a side with no neighbour,
+// which leaves that direction open.
+export function dateWindow(cycles: Cycle[], cycle: Cycle): { from: Date | null; to: Date | null } {
+ const others = cycles.filter((c) => c.id !== cycle.id);
+ const before = others
+ .filter((c) => c.endDate < cycle.startDate)
+ .map((c) => c.endDate)
+ .sort();
+ const after = others
+ .filter((c) => c.startDate > cycle.endDate)
+ .map((c) => c.startDate)
+ .sort();
+ const prevEnd = parseDate(before[before.length - 1] ?? null);
+ const nextStart = parseDate(after[0] ?? null);
+ return {
+ from: prevEnd ? addDays(prevEnd, 1) : null,
+ to: nextStart ? addDays(nextStart, -1) : null,
+ };
+}
diff --git a/apps/web/src/features/cycles/utils/cycleDefaults.ts b/apps/web/src/features/cycles/utils/cycleDefaults.ts
new file mode 100644
index 00000000..9fdea52a
--- /dev/null
+++ b/apps/web/src/features/cycles/utils/cycleDefaults.ts
@@ -0,0 +1,53 @@
+import type { Cycle } from '@/lib/api';
+import { addDays, daysBetween, parseDate, toDateStr } from '@/utils/dates';
+
+// The lengths offered as one click each, in days. Two weeks is what a new cycle
+// opens with.
+export const CYCLE_LENGTHS = [7, 14, 21, 28];
+
+const DEFAULT_LENGTH = 14;
+
+// What a new cycle opens with, so it can be created without filling anything in: it
+// picks up where the last one ended and continues its numbering.
+export interface CycleDefaults {
+ name: string;
+ startDate: string;
+ endDate: string;
+}
+
+// Cycles are numbered rather than named, so the next one follows the last one:
+// "Sprint 12" gives "Sprint 13", and any prefix works the same way ("Q3 W4" →
+// "Q3 W5"). A last cycle whose name ends in no number, or no cycles at all, falls
+// back to counting them.
+function nextName(cycles: Cycle[]): string {
+ const last = cycles[cycles.length - 1];
+ const numbered = last?.name.match(/^(.*?)(\d+)\s*$/);
+ if (numbered) return `${numbered[1]}${Number(numbered[2]) + 1}`;
+ return `Sprint ${cycles.length + 1}`;
+}
+
+// The next Monday after `from`, never `from` itself — cycles are planned ahead, so
+// a new one starts on a week boundary that has not passed yet.
+function nextMonday(from: Date): Date {
+ const untilMonday = (8 - from.getDay()) % 7;
+ return addDays(from, untilMonday === 0 ? 7 : untilMonday);
+}
+
+// `cycles` comes oldest first, so the last one is the one to continue from. A cycle
+// still running or still ahead is followed the day after it ends — back to back, and
+// never overlapping, which the API rejects. With nothing ahead (the last cycle is
+// over, or there is none) the new cycle starts on the coming Monday rather than
+// mid-week.
+export function cycleDefaults(cycles: Cycle[]): CycleDefaults {
+ const today = new Date();
+ const previousEnd = parseDate(cycles[cycles.length - 1]?.endDate ?? null);
+ const start =
+ previousEnd && daysBetween(today, previousEnd) >= 0
+ ? addDays(previousEnd, 1)
+ : nextMonday(today);
+ return {
+ name: nextName(cycles),
+ startDate: toDateStr(start),
+ endDate: toDateStr(addDays(start, DEFAULT_LENGTH - 1)),
+ };
+}
diff --git a/apps/web/src/features/cycles/utils/cycleGroups.ts b/apps/web/src/features/cycles/utils/cycleGroups.ts
new file mode 100644
index 00000000..f2265ed0
--- /dev/null
+++ b/apps/web/src/features/cycles/utils/cycleGroups.ts
@@ -0,0 +1,21 @@
+import type { Cycle, CycleStatus } from '@/lib/api';
+import { CYCLE_STATUS_META, CYCLE_STATUS_ORDER } from '@/utils/cycleMeta';
+
+export interface CycleGroup {
+ status: CycleStatus;
+ label: string;
+ color: string;
+ cycles: Cycle[];
+}
+
+// The planned cycles as the groups both list views render, in reading order: what
+// is running, then what is next, each keeping the API's order (by start date). A
+// status with no cycles is left out. Finished cycles never reach here — the table
+// pages them in as an archive of its own (see CycleTableArchive).
+export function groupCycles(cycles: Cycle[]): CycleGroup[] {
+ return CYCLE_STATUS_ORDER.flatMap((status) => {
+ const group = cycles.filter((c) => c.status === status);
+ if (group.length === 0) return [];
+ return [{ status, ...CYCLE_STATUS_META[status], cycles: group }];
+ });
+}
diff --git a/apps/web/src/features/cycles/utils/cycleRanges.ts b/apps/web/src/features/cycles/utils/cycleRanges.ts
new file mode 100644
index 00000000..f67a154a
--- /dev/null
+++ b/apps/web/src/features/cycles/utils/cycleRanges.ts
@@ -0,0 +1,35 @@
+import type { Cycle } from '@/lib/api';
+import { addDays, parseDate } from '@/utils/dates';
+
+// The date-picker limits that mirror the API's rule: cycles of one project may not
+// overlap. Everything they leave selectable is accepted by the server, so a picked
+// range never comes back as a 400 (which still guards the API itself — MCP, direct
+// calls, and a cycle created elsewhere while this dialog was open).
+
+// The cycles a new or edited one has to fit around: all of the project's except the
+// one being edited.
+function others(cycles: Cycle[], editedId: number | undefined): Cycle[] {
+ return editedId === undefined ? cycles : cycles.filter((c) => c.id !== editedId);
+}
+
+// The days already taken by another cycle. A start date may not land on one.
+export function busyRanges(cycles: Cycle[], editedId?: number): { from: Date; to: Date }[] {
+ return others(cycles, editedId).flatMap((c) => {
+ const from = parseDate(c.startDate);
+ const to = parseDate(c.endDate);
+ return from && to ? [{ from, to }] : [];
+ });
+}
+
+// The last day a cycle starting on `startDate` may end on: the day before the next
+// cycle begins. Null when nothing follows, which leaves the end date open. Keeps a
+// range from spanning a whole cycle — both of its ends free, everything between them
+// taken.
+export function endLimit(cycles: Cycle[], startDate: string, editedId?: number): Date | null {
+ const starts = others(cycles, editedId)
+ .filter((c) => c.startDate > startDate)
+ .map((c) => c.startDate)
+ .sort();
+ const next = parseDate(starts[0] ?? null);
+ return next ? addDays(next, -1) : null;
+}
diff --git a/apps/web/src/features/cycles/utils/cycleTimeline.ts b/apps/web/src/features/cycles/utils/cycleTimeline.ts
new file mode 100644
index 00000000..7ef4ab69
--- /dev/null
+++ b/apps/web/src/features/cycles/utils/cycleTimeline.ts
@@ -0,0 +1,50 @@
+import type { Cycle } from '@/lib/api';
+import { buildDayTrack, type DayTrack } from '@/utils/timelineTrack';
+import { cycleSpan, type CycleSpan } from './cycleDates';
+import { groupCycles, type CycleGroup } from './cycleGroups';
+
+export const CYCLE_DAY_W = 12; // px per day: a two-week cycle is a legible bar
+export const CYCLE_ROW_H = 40;
+export const CYCLE_GROUP_H = 30;
+
+// The dragged label-column width is a client-only preference, kept per project.
+export function cycleLabelWidthKey(projectKey: string): string {
+ return `cycles-timeline-label-width:${projectKey}`;
+}
+
+// One entry per group header, then its cycles, so the sticky labels and the day
+// track share the same row order.
+export type CycleTimelineItem =
+ { kind: 'group'; group: CycleGroup } | { kind: 'cycle'; cycle: Cycle; span: CycleSpan };
+
+export interface CycleTimelineModel extends DayTrack {
+ rows: CycleTimelineItem[];
+}
+
+export function buildCycleTimeline({
+ cycles,
+ viewportW,
+ labelW,
+ dayW,
+}: {
+ cycles: Cycle[];
+ viewportW: number;
+ labelW: number;
+ dayW: number;
+}): CycleTimelineModel {
+ const rows: CycleTimelineItem[] = [];
+ let min: Date | null = null;
+ let max: Date | null = null;
+ for (const group of groupCycles(cycles)) {
+ rows.push({ kind: 'group', group });
+ for (const cycle of group.cycles) {
+ const span = cycleSpan(cycle);
+ if (!span) continue;
+ if (!min || span.start < min) min = span.start;
+ if (!max || span.end > max) max = span.end;
+ rows.push({ kind: 'cycle', cycle, span });
+ }
+ }
+
+ return { rows, ...buildDayTrack({ min, max, viewportW, labelW, dayW }) };
+}
diff --git a/apps/web/src/features/cycles/utils/cyclesView.ts b/apps/web/src/features/cycles/utils/cyclesView.ts
new file mode 100644
index 00000000..b1888e9b
--- /dev/null
+++ b/apps/web/src/features/cycles/utils/cyclesView.ts
@@ -0,0 +1,24 @@
+import { isCyclesView, type CyclesView } from '@/utils/paths';
+
+// Which layout the cycles list opens in, remembered per project. Client-only:
+// localStorage is what the list path reads to pick a layout (see CyclesRedirect),
+// and what switching a tab writes.
+
+const storageKey = (projectKey: string) => `cycles-view:${projectKey}`;
+
+export function readCyclesView(projectKey: string): CyclesView {
+ try {
+ const stored = localStorage.getItem(storageKey(projectKey));
+ return stored && isCyclesView(stored) ? stored : 'table';
+ } catch {
+ return 'table';
+ }
+}
+
+export function rememberCyclesView(projectKey: string, view: CyclesView) {
+ try {
+ localStorage.setItem(storageKey(projectKey), view);
+ } catch {
+ // ignore write failures (private mode / quota); the layout still switches.
+ }
+}
diff --git a/apps/web/src/features/initiatives/components/detail/InitiativeHeader.tsx b/apps/web/src/features/initiatives/components/detail/InitiativeHeader.tsx
index 35eb8cf7..aa649778 100644
--- a/apps/web/src/features/initiatives/components/detail/InitiativeHeader.tsx
+++ b/apps/web/src/features/initiatives/components/detail/InitiativeHeader.tsx
@@ -11,7 +11,7 @@ import PrioritySelect from '@/components/common/fields/PrioritySelect';
import InitiativeStatusSelect from '../shared/InitiativeStatusSelect';
import HealthBadge from '../shared/HealthBadge';
import HealthInfoPopover from '../shared/HealthInfoPopover';
-import ProgressBar from '../shared/ProgressBar';
+import ProgressBar from '@/components/common/ProgressBar';
import InitiativeActions from './InitiativeActions';
// The initiative detail header. The pills patch the initiative inline; title and
diff --git a/apps/web/src/features/initiatives/components/detail/InitiativeIssuesBoard.tsx b/apps/web/src/features/initiatives/components/detail/InitiativeIssuesBoard.tsx
index f3fa0e65..7af2d6a0 100644
--- a/apps/web/src/features/initiatives/components/detail/InitiativeIssuesBoard.tsx
+++ b/apps/web/src/features/initiatives/components/detail/InitiativeIssuesBoard.tsx
@@ -9,7 +9,10 @@ import KanbanBoard from '@/features/work-items/components/kanban/KanbanBoard';
import TableView from '@/features/work-items/components/table/TableView';
import TimelineView from '@/features/work-items/components/timeline/TimelineView';
import CalendarView from '@/features/work-items/components/calendar/CalendarView';
-import { useInitiativeBoardSettings } from '../../hooks/useInitiativeBoardSettings';
+import { useLocalBoardSettings } from '@/hooks/useLocalBoardSettings';
+
+// Where this board's layout and display settings are kept, per initiative.
+const INITIATIVE_BOARD_STORE_KEY = 'planner_initiative_board_settings';
// The initiative's issues rendered as the work items board (kanban/table/timeline/
// calendar) with filters and display settings, but no saved views. The board is
@@ -17,7 +20,7 @@ import { useInitiativeBoardSettings } from '../../hooks/useInitiativeBoardSettin
// real issues and the live board refresh keeps it current.
export default function InitiativeIssuesBoard({ initiativeId }: { initiativeId: number }) {
const { project, customFields, onOpenIssue, onAddIssue } = useShell();
- const board = useInitiativeBoardSettings(initiativeId);
+ const board = useLocalBoardSettings(INITIATIVE_BOARD_STORE_KEY, initiativeId);
const viewProject = useMemo(() => {
if (!project) return null;
diff --git a/apps/web/src/features/initiatives/components/list/InitiativeRow.tsx b/apps/web/src/features/initiatives/components/list/InitiativeRow.tsx
index 1688dee8..cc68b88f 100644
--- a/apps/web/src/features/initiatives/components/list/InitiativeRow.tsx
+++ b/apps/web/src/features/initiatives/components/list/InitiativeRow.tsx
@@ -10,7 +10,7 @@ import { colorDot } from '@/components/common/fields/colorDot';
import { TableCell, TableRow } from '@/components/ui/table';
import { STATUS_META } from '@/utils/initiativeMeta';
import HealthBadge from '../shared/HealthBadge';
-import ProgressBar from '../shared/ProgressBar';
+import ProgressBar from '@/components/common/ProgressBar';
// The whole row navigates to the detail page; the title is also a real anchor so
// middle/cmd-click opens it in a new tab.
diff --git a/apps/web/src/features/initiatives/components/shared/ProgressBar.tsx b/apps/web/src/features/initiatives/components/shared/ProgressBar.tsx
deleted file mode 100644
index 0c43cba4..00000000
--- a/apps/web/src/features/initiatives/components/shared/ProgressBar.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import type { InitiativeProgress } from '@/lib/api';
-
-// Issue progress as a thin bar plus a "completed/total" count. Canceled issues are
-// excluded from the denominator so the bar reflects deliverable work.
-export default function ProgressBar({ progress }: { progress: InitiativeProgress }) {
- const denom = progress.total - progress.canceled;
- const pct = denom > 0 ? Math.round((progress.completed / denom) * 100) : 0;
- return (
- <div className="flex items-center gap-2">
- <div className="h-1.5 w-16 overflow-hidden rounded-full bg-muted">
- <div className="h-full rounded-full bg-foreground/70" style={{ width: `${pct}%` }} />
- </div>
- <span className="text-xs text-muted-foreground tabular-nums">
- {progress.completed}/{denom}
- </span>
- </div>
- );
-}
diff --git a/apps/web/src/features/issue/components/actions/IssueContextMenu.tsx b/apps/web/src/features/issue/components/actions/IssueContextMenu.tsx
index dc499850..3a1c4890 100644
--- a/apps/web/src/features/issue/components/actions/IssueContextMenu.tsx
+++ b/apps/web/src/features/issue/components/actions/IssueContextMenu.tsx
@@ -9,6 +9,7 @@ import {
CircleDashed,
ClipboardCopy,
PanelRight,
+ RefreshCw,
SquareArrowOutUpRight,
Tag,
Target,
@@ -22,6 +23,7 @@ import { useActionsQuery } from '@/services/actions.service';
import { useRestoreIssue, useUpdateIssue } from '@/services/issues.service';
import { useInitiativesQuery } from '@/services/initiatives.service';
import { LINKABLE_STATUSES, STATUS_META } from '@/utils/initiativeMeta';
+import { CYCLE_STATUS_META } from '@/utils/cycleMeta';
import { usePermissions } from '@/hooks/usePermissions';
import { ShellCtx } from '@/context/shellContext';
import { useArchiveAction } from '../../hooks/useArchiveAction';
@@ -51,8 +53,8 @@ function SelectedCheck({ selected }: { selected: boolean }) {
}
// Wraps a issue card/row (any single element) so a right-click opens a context
-// menu that changes its status, priority, assignee, initiative, labels or due
-// date, or deletes it. Shared by every project view (Kanban, Table, Calendar, Timeline).
+// menu that changes its status, priority, assignee, initiative, cycle, labels or
+// due date, or deletes it. Shared by every project view (Kanban, Table, Calendar, Timeline).
// onDeleted lets a host that is showing this one issue (the detail panel/page)
// leave after deletion; the project views leave it unset — the card just
// disappears when the project cache updates.
@@ -255,6 +257,29 @@ export default function IssueContextMenu({
</ContextMenuSub>
)}
+ {project.project.cyclesEnabled && (
+ <ContextMenuSub>
+ <ContextMenuSubTrigger>
+ {issue.cycle ? <RefreshCw /> : <CircleDashed />}
+ Cycle
+ </ContextMenuSubTrigger>
+ <ContextMenuSubContent className="w-56">
+ <ContextMenuItem onSelect={() => patch({ cycleId: null })}>
+ <CircleDashed />
+ <span className="flex-1">No cycle</span>
+ <SelectedCheck selected={issue.cycle == null} />
+ </ContextMenuItem>
+ {project.plannedCycles.map((cycle) => (
+ <ContextMenuItem key={cycle.id} onSelect={() => patch({ cycleId: cycle.id })}>
+ {colorDot(CYCLE_STATUS_META[cycle.status].color)}
+ <span className="flex-1 truncate">{cycle.name}</span>
+ <SelectedCheck selected={cycle.id === issue.cycle?.id} />
+ </ContextMenuItem>
+ ))}
+ </ContextMenuSubContent>
+ </ContextMenuSub>
+ )}
+
<ContextMenuSub>
<ContextMenuSubTrigger>
<CalendarClock />
diff --git a/apps/web/src/features/issue/components/create/NewIssueModal.tsx b/apps/web/src/features/issue/components/create/NewIssueModal.tsx
index feeb3483..49278c8e 100644
--- a/apps/web/src/features/issue/components/create/NewIssueModal.tsx
+++ b/apps/web/src/features/issue/components/create/NewIssueModal.tsx
@@ -43,6 +43,7 @@ import {
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { Pill } from '@/components/common/fields/Pill';
import InitiativeSelect from '../fields/InitiativeSelect';
+import CycleSelect, { type CycleOption } from '../fields/CycleSelect';
export default function NewIssueModal({
project,
@@ -68,6 +69,11 @@ export default function NewIssueModal({
: defaults.typeId,
);
const [initiativeId, setInitiativeId] = useState<number | null>(defaults.initiativeId ?? null);
+ // A default cycle that is not among the planned ones has finished, and nothing new
+ // is planned into it — the issue is created without a cycle instead.
+ const [cycle, setCycle] = useState<CycleOption | null>(
+ () => project.plannedCycles.find((c) => c.id === defaults.cycleId) ?? null,
+ );
const { data: session } = useSession();
// Assignee defaults to the creating user unless the caller set one explicitly
// (defaults.assigneeUserId is null for the "No assignee" board group).
@@ -222,6 +228,7 @@ export default function NewIssueModal({
parentId: defaults.parentId ?? null,
typeId,
initiativeId,
+ cycleId: cycle?.id ?? null,
assigneeUserId,
delegateUserId,
priority: priority || null,
@@ -349,6 +356,10 @@ export default function NewIssueModal({
/>
)}
+ {project.project.cyclesEnabled && (
+ <CycleSelect projectKey={project.project.key} value={cycle} onChange={setCycle} />
+ )}
+
{project.labels.length > 0 && (
<LabelsSelect
labels={project.labels}
diff --git a/apps/web/src/features/issue/components/detail/IssueProperties.tsx b/apps/web/src/features/issue/components/detail/IssueProperties.tsx
index fcd50c1f..b5b94739 100644
--- a/apps/web/src/features/issue/components/detail/IssueProperties.tsx
+++ b/apps/web/src/features/issue/components/detail/IssueProperties.tsx
@@ -1,5 +1,5 @@
import { type ReactNode } from 'react';
-import { Target } from 'lucide-react';
+import { RefreshCw, Target } from 'lucide-react';
import {
type CustomField,
type ProjectDetail,
@@ -18,6 +18,7 @@ import PrioritySelect from '@/components/common/fields/PrioritySelect';
import StatusSelect from '@/components/common/fields/StatusSelect';
import TypeSelect from '@/components/common/fields/TypeSelect';
import InitiativeSelect from '../fields/InitiativeSelect';
+import CycleSelect from '../fields/CycleSelect';
import IssueCustomFieldControl from '../fields/IssueCustomFieldControl';
import IssueCustomFieldBody from '../fields/IssueCustomFieldBody';
import IssueWatchers from './IssueWatchers';
@@ -170,6 +171,27 @@ export default function IssueProperties({
</PropertyRow>
)}
+ {project.project.cyclesEnabled && (!readOnly || issue.cycle) && (
+ <PropertyRow label="Cycle">
+ {readOnly ? (
+ // Read-only shows the cycle from the issue itself, avoiding the
+ // authenticated cycles query the editable select runs.
+ <ReadOnlyPill>
+ <Pill active={!!issue.cycle}>
+ <RefreshCw />
+ {issue.cycle?.name ?? 'Cycle'}
+ </Pill>
+ </ReadOnlyPill>
+ ) : (
+ <CycleSelect
+ projectKey={project.project.key}
+ value={issue.cycle}
+ onChange={(cycle) => onPatch({ cycleId: cycle?.id ?? null })}
+ />
+ )}
+ </PropertyRow>
+ )}
+
<PropertyRow label="Start date">
<DatePill
value={issue.startDate}
diff --git a/apps/web/src/features/issue/components/fields/CycleSelect.tsx b/apps/web/src/features/issue/components/fields/CycleSelect.tsx
new file mode 100644
index 00000000..fd7fa632
--- /dev/null
+++ b/apps/web/src/features/issue/components/fields/CycleSelect.tsx
@@ -0,0 +1,77 @@
+import { useState } from 'react';
+import { Check, CircleDashed, RefreshCw } from 'lucide-react';
+import type { Cycle } from '@/lib/api';
+import { usePlannedCyclesQuery } from '@/services/cycles.service';
+import { colorDot } from '@/components/common/fields/colorDot';
+import { CYCLE_STATUS_META } from '@/utils/cycleMeta';
+import {
+ Command,
+ CommandEmpty,
+ CommandGroup,
+ CommandInput,
+ CommandItem,
+ CommandList,
+} from '@/components/ui/command';
+import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
+import { Pill } from '@/components/common/fields/Pill';
+
+export type CycleOption = Pick<Cycle, 'id' | 'name'>;
+
+// A Pill trigger opening the cycles an issue can be planned into: the ones that have
+// not finished. A completed cycle is not offered — it records what it delivered — but
+// the one the issue already sits on stays listed, so it can be read and unplanned.
+export default function CycleSelect({
+ projectKey,
+ value,
+ onChange,
+}: {
+ projectKey: string;
+ value: CycleOption | null;
+ onChange: (cycle: CycleOption | null) => void;
+}) {
+ const [open, setOpen] = useState(false);
+ const { data } = usePlannedCyclesQuery(projectKey);
+ const planned = data ?? [];
+ const cycles =
+ value && !planned.some((c) => c.id === value.id)
+ ? [{ ...value, status: 'completed' as const }, ...planned]
+ : planned;
+
+ const select = (cycle: CycleOption | null) => {
+ onChange(cycle);
+ setOpen(false);
+ };
+
+ return (
+ <Popover open={open} onOpenChange={setOpen}>
+ <PopoverTrigger asChild>
+ <Pill active={value != null}>
+ {value != null ? <RefreshCw /> : <CircleDashed />}
+ {value?.name ?? 'Cycle'}
+ </Pill>
+ </PopoverTrigger>
+ <PopoverContent className="w-56 p-0" align="start">
+ <Command>
+ <CommandInput placeholder="Plan into cycle…" />
+ <CommandList>
+ <CommandEmpty>No cycles.</CommandEmpty>
+ <CommandGroup>
+ <CommandItem value="No cycle" onSelect={() => select(null)}>
+ <CircleDashed />
+ <span className="flex-1">No cycle</span>
+ {value == null && <Check className="ml-auto" />}
+ </CommandItem>
+ {cycles.map((cycle) => (
+ <CommandItem key={cycle.id} value={cycle.name} onSelect={() => select(cycle)}>
+ {colorDot(CYCLE_STATUS_META[cycle.status].color)}
+ <span className="flex-1 truncate">{cycle.name}</span>
+ {cycle.id === value?.id && <Check className="ml-auto" />}
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ </CommandList>
+ </Command>
+ </PopoverContent>
+ </Popover>
+ );
+}
diff --git a/apps/web/src/features/issue/utils/activityText.tsx b/apps/web/src/features/issue/utils/activityText.tsx
index 491833ed..e9bddc04 100644
--- a/apps/web/src/features/issue/utils/activityText.tsx
+++ b/apps/web/src/features/issue/utils/activityText.tsx
@@ -12,6 +12,7 @@ import {
ListChecks,
ListTree,
Pencil,
+ RefreshCw,
Shapes,
SignalHigh,
Bot,
@@ -35,6 +36,7 @@ export const ACTION_ICON: Record<ActivityAction, LucideIcon> = {
delegate: Bot,
priority: SignalHigh,
type: Shapes,
+ cycle: RefreshCw,
start_date: Calendar,
due_date: Calendar,
label_add: Tag,
@@ -112,6 +114,17 @@ export function describeActivity(a: FeedItem): { line: ReactNode; popover?: stri
: { line: 'removed priority' };
case 'type':
return a.toText ? { line: <>set type to {strong(a.toText)}</> } : { line: 'removed type' };
+ case 'cycle':
+ if (!a.toText) return { line: <>removed from cycle {strong(a.fromText)}</> };
+ return {
+ line: a.fromText ? (
+ <>
+ moved from cycle {strong(a.fromText)} to {strong(a.toText)}
+ </>
+ ) : (
+ <>planned into cycle {strong(a.toText)}</>
+ ),
+ };
case 'start_date':
return a.toText
? { line: <>set start date to {strong(fmtDate(a.toText))}</> }
diff --git a/apps/web/src/features/settings/components/general/SettingsFeatures.tsx b/apps/web/src/features/settings/components/general/SettingsFeatures.tsx
index 1d9779b9..5aec4cb8 100644
--- a/apps/web/src/features/settings/components/general/SettingsFeatures.tsx
+++ b/apps/web/src/features/settings/components/general/SettingsFeatures.tsx
@@ -10,6 +10,7 @@ import type { FeatureTogglesForm } from '../../hooks/useFeatureToggles';
const FEATURES: { key: keyof ProjectFeatures; description: string }[] = [
{ key: 'dashboards', description: 'Charts and metrics on saved dashboards.' },
{ key: 'initiatives', description: 'Groups of issues tracked as one piece of work.' },
+ { key: 'cycles', description: 'Time-boxed periods of work the issues are planned into.' },
{ key: 'notes', description: 'Freeform boards of sticky notes.' },
];
diff --git a/apps/web/src/features/settings/hooks/useFeatureToggles.ts b/apps/web/src/features/settings/hooks/useFeatureToggles.ts
index 212903c5..57e20bec 100644
--- a/apps/web/src/features/settings/hooks/useFeatureToggles.ts
+++ b/apps/web/src/features/settings/hooks/useFeatureToggles.ts
@@ -20,7 +20,7 @@ export interface FeatureTogglesForm {
export function useFeatureToggles(project: ProjectDetail): FeatureTogglesForm {
const { isOwner } = usePermissions();
const update = useUpdateProjectFeatures(project.project.key);
- const { initiativesEnabled, dashboardsEnabled, notesEnabled } = project.project;
+ const { initiativesEnabled, cyclesEnabled, dashboardsEnabled, notesEnabled } = project.project;
async function toggle(feature: keyof ProjectFeatures, enabled: boolean) {
await update.mutateAsync({ [feature]: enabled });
@@ -30,6 +30,7 @@ export function useFeatureToggles(project: ProjectDetail): FeatureTogglesForm {
return {
features: {
initiatives: initiativesEnabled,
+ cycles: cyclesEnabled,
dashboards: dashboardsEnabled,
notes: notesEnabled,
},
diff --git a/apps/web/src/features/work-items/WorkItemsPage.tsx b/apps/web/src/features/work-items/WorkItemsPage.tsx
index c612847b..28d746e0 100644
--- a/apps/web/src/features/work-items/WorkItemsPage.tsx
+++ b/apps/web/src/features/work-items/WorkItemsPage.tsx
@@ -9,7 +9,11 @@ import { useLiveRefresh } from '@/hooks/useLiveRefresh';
import { api, type BoardIssues } from '@/lib/api';
import { qk } from '@/services/queryKeys';
import { buildGroups, groupIssues } from '@/utils/project';
-import { restoreInitiative, withoutInitiative, type ViewSettings } from '@/utils/viewSettings';
+import {
+ restoreHiddenSections,
+ withoutHiddenSections,
+ type ViewSettings,
+} from '@/utils/viewSettings';
import { cn } from '@/lib/utils';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
@@ -64,12 +68,12 @@ export default function WorkItemsPage() {
// client-side); only persisting is gated.
const canSaveView = can('views', editor.activeView ? 'edit' : 'create');
- // With the Initiatives section off, its property and grouping are left out of
- // what the layouts and the Display panel work with, and put back on the way out
- // so the stored display keeps them for when the section is on again.
- const settings = features.initiatives ? editor.settings : withoutInitiative(editor.settings);
+ // With an optional section off, its property and grouping are left out of what
+ // the layouts and the Display panel work with, and put back on the way out so the
+ // stored display keeps them for when the section is on again.
+ const settings = withoutHiddenSections(editor.settings, features);
const changeSettings = (next: ViewSettings) =>
- editor.changeSettings(features.initiatives ? next : restoreInitiative(next, editor.settings));
+ editor.changeSettings(restoreHiddenSections(next, editor.settings, features));
const timelineGroups = buildGroups(filteredProject, settings.group);
const timelineIssuesByGroup = groupIssues(timelineGroups, filteredProject.issues, settings.group);
diff --git a/apps/web/src/features/work-items/components/kanban/BulkActionBar.tsx b/apps/web/src/features/work-items/components/kanban/BulkActionBar.tsx
index 2c1ba17a..cd3363d3 100644
--- a/apps/web/src/features/work-items/components/kanban/BulkActionBar.tsx
+++ b/apps/web/src/features/work-items/components/kanban/BulkActionBar.tsx
@@ -1,11 +1,12 @@
'use client';
import { useState } from 'react';
-import { Archive, Bot, CircleDashed, Tag, Target, Trash2, User, X } from 'lucide-react';
+import { Archive, Bot, CircleDashed, RefreshCw, Tag, Target, Trash2, User, X } from 'lucide-react';
import { type ProjectDetail } from '@/lib/api';
import { usePermissions } from '@/hooks/usePermissions';
import { useInitiativesQuery } from '@/services/initiatives.service';
import { LINKABLE_STATUSES } from '@/utils/initiativeMeta';
+import { CYCLE_STATUS_META } from '@/utils/cycleMeta';
import { subtaskCount } from '@/utils/subtasks';
import { cn } from '@/lib/utils';
import { colorDot } from '@/components/common/fields/colorDot';
@@ -151,6 +152,24 @@ export function BulkActionBar({ project }: { project: ProjectDetail }) {
</BarMenu>
)}
+ {project.plannedCycles.length > 0 && (
+ <BarMenu icon={<RefreshCw className="size-4" />} label="Cycle" disabled={disabled}>
+ <DropdownMenuItem onSelect={() => void bulk.patch(ids, { cycleId: null })}>
+ <CircleDashed />
+ <span className="flex-1">No cycle</span>
+ </DropdownMenuItem>
+ {project.plannedCycles.map((cycle) => (
+ <DropdownMenuItem
+ key={cycle.id}
+ onSelect={() => void bulk.patch(ids, { cycleId: cycle.id })}
+ >
+ {colorDot(CYCLE_STATUS_META[cycle.status].color)}
+ <span className="flex-1 truncate">{cycle.name}</span>
+ </DropdownMenuItem>
+ ))}
+ </BarMenu>
+ )}
+
{project.labels.length > 0 && (
<BarMenu icon={<Tag className="size-4" />} label="Labels" disabled={disabled}>
{project.labels.map((l) => (
diff --git a/apps/web/src/features/work-items/components/kanban/IssueCardBody.tsx b/apps/web/src/features/work-items/components/kanban/IssueCardBody.tsx
index e68e87bc..71913cb5 100644
--- a/apps/web/src/features/work-items/components/kanban/IssueCardBody.tsx
+++ b/apps/web/src/features/work-items/components/kanban/IssueCardBody.tsx
@@ -1,4 +1,4 @@
-import { CalendarArrowUp, CalendarClock, Target, Timer } from 'lucide-react';
+import { CalendarArrowUp, CalendarClock, RefreshCw, Target, Timer } from 'lucide-react';
import { type BoardIssue } from '@/lib/api';
import { type Maps } from '@/utils/project';
import { formatDurationShort, formatShortDate, isDueOverdue } from '@/utils/dates';
@@ -36,6 +36,7 @@ export function IssueCardBody({
const delegate =
issue.delegateUserId != null ? maps.assigneeById.get(issue.delegateUserId) : undefined;
const initiative = issue.initiative ?? undefined;
+ const cycle = issue.cycle ?? undefined;
const column = maps.columnById.get(issue.columnId);
const metaShown =
has('statusAge') ||
@@ -43,6 +44,7 @@ export function IssueCardBody({
(has('startDate') && issue.startDate) ||
(has('type') && type) ||
(has('initiative') && initiative) ||
+ (has('cycle') && cycle) ||
(has('labels') && issue.labelIds.length > 0);
const footerShown =
has('created') ||
@@ -127,6 +129,15 @@ export function IssueCardBody({
<span className="truncate">{initiative.title}</span>
</Badge>
)}
+ {has('cycle') && cycle && (
+ <Badge
+ variant="outline"
+ className="max-w-full rounded-full px-1.5 py-0.5 text-[10px] text-muted-foreground"
+ >
+ <RefreshCw className="size-2.5 shrink-0" />
+ <span className="truncate">{cycle.name}</span>
+ </Badge>
+ )}
{has('labels') &&
issue.labelIds.map((id) => {
const label = maps.labelById.get(id);
diff --git a/apps/web/src/features/work-items/components/table/TableBuiltinCell.tsx b/apps/web/src/features/work-items/components/table/TableBuiltinCell.tsx
index 23a2533b..8e4db2ef 100644
--- a/apps/web/src/features/work-items/components/table/TableBuiltinCell.tsx
+++ b/apps/web/src/features/work-items/components/table/TableBuiltinCell.tsx
@@ -99,6 +99,10 @@ export function TableBuiltinCell({
{issue.initiative?.title ?? DASH}
</div>
);
+ case 'cycle':
+ return (
+ <div className="truncate text-xs text-muted-foreground">{issue.cycle?.name ?? DASH}</div>
+ );
case 'labels':
return (
<div className="flex min-w-0 flex-wrap items-center gap-1 overflow-hidden">
diff --git a/apps/web/src/features/work-items/components/timeline/TimelineView.tsx b/apps/web/src/features/work-items/components/timeline/TimelineView.tsx
index 94f94d35..9f7d0ab3 100644
--- a/apps/web/src/features/work-items/components/timeline/TimelineView.tsx
+++ b/apps/web/src/features/work-items/components/timeline/TimelineView.tsx
@@ -1,11 +1,13 @@
-import { Fragment, useEffect, useRef, useState } from 'react';
+import { Fragment, useRef, useState } from 'react';
import { buildMaps, issueColor, type WorkItemsViewProps } from '@/utils/project';
import { usePermissions } from '@/hooks/usePermissions';
+import { useElementWidth } from '@/hooks/useElementWidth';
+import { useTimelineLabelWidth } from '@/hooks/useTimelineLabelWidth';
+import { LABEL_NARROW_W } from '@/utils/timelineTrack';
+import { TimelineHeader } from '@/components/common/timeline/TimelineHeader';
+import { TimelineLabelResizer } from '@/components/common/timeline/TimelineLabelResizer';
import { useTimelineDrag } from '../../hooks/useTimelineDrag';
-import { useTimelineLabelWidth } from '../../hooks/useTimelineLabelWidth';
import { buildTimeline, labelWidthKey, SCALE_DAY_W } from '../../utils/timeline';
-import { TimelineHeader } from './TimelineHeader';
-import { TimelineLabelResizer } from './TimelineLabelResizer';
import { TimelineGroupRow } from './TimelineGroupRow';
import { TimelineIssueRow } from './TimelineIssueRow';
import { TimelineLinkRows } from './TimelineLinkRows';
@@ -56,23 +58,12 @@ export default function TimelineView({
});
// Width of the scroll area, so the track can extend with trailing days until it
// fills the viewport instead of leaving empty space on the right.
- const [viewportW, setViewportW] = useState(() =>
- typeof window !== 'undefined' ? window.innerWidth : 1200,
- );
-
- useEffect(() => {
- const el = scrollRef.current;
- if (!el) return;
- const ro = new ResizeObserver(() => setViewportW(el.clientWidth));
- ro.observe(el);
- setViewportW(el.clientWidth);
- return () => ro.disconnect();
- }, []);
+ const viewportW = useElementWidth(scrollRef);
// Narrow the sticky label column on small screens so the day track is usable;
// on wider ones it is the width the grip was dragged to.
const narrow = viewportW < 640;
- const labelW = narrow ? 140 : titleWidth;
+ const labelW = narrow ? LABEL_NARROW_W : titleWidth;
const { rows, days, months, trackWidth, todayLeft, todayInRange, dayLines, spanToRect } =
buildTimeline({
project,
diff --git a/apps/web/src/features/work-items/utils/table.ts b/apps/web/src/features/work-items/utils/table.ts
index 8712dedd..b40324dc 100644
--- a/apps/web/src/features/work-items/utils/table.ts
+++ b/apps/web/src/features/work-items/utils/table.ts
@@ -19,6 +19,7 @@ export const COLUMN_META: Record<TableColumn, { label: string; width: string }>
assignee: { label: '', width: '56px' },
delegate: { label: '', width: '56px' },
initiative: { label: 'Initiative', width: 'minmax(140px,220px)' },
+ cycle: { label: 'Cycle', width: 'minmax(120px,180px)' },
labels: { label: 'Labels', width: 'minmax(120px,220px)' },
startDate: { label: 'Start', width: '96px' },
dueDate: { label: 'Due', width: '96px' },
diff --git a/apps/web/src/features/work-items/utils/timeline.ts b/apps/web/src/features/work-items/utils/timeline.ts
index 4f2aeb5b..d03cbbcd 100644
--- a/apps/web/src/features/work-items/utils/timeline.ts
+++ b/apps/web/src/features/work-items/utils/timeline.ts
@@ -1,16 +1,14 @@
-import { format, startOfDay } from 'date-fns';
+import { startOfDay } from 'date-fns';
import { type BoardIssue, type Issue, type ProjectDetail } from '@/lib/api';
-import { addDays, daysBetween, parseDate } from '@/utils/dates';
+import { parseDate } from '@/utils/dates';
+import { buildDayTrack, type DayTrack } from '@/utils/timelineTrack';
import { buildGroups, groupIssues, type IssueGroup } from '@/utils/project';
import type { GroupField, TimelineScale } from '@/utils/viewSettings';
// px per day at each zoom level. Wider days keep the per-day numbers legible;
// narrower days fit longer ranges and fall back to weekly gridlines.
export const SCALE_DAY_W: Record<TimelineScale, number> = { week: 32, month: 12, quarter: 5 };
-export const LABEL_W = 256; // px, the left issue-label column (matches w-64)
export const ROW_H = 36; // px, an issue row
-export const LABEL_MIN_W = 160;
-export const LABEL_MAX_W = 640;
export const LINK_ROW_H = 26; // px, a linked-issue sub-row under an issue row
export const GROUP_H = 32; // px, a state group header row
@@ -53,26 +51,10 @@ export type TimelineRow =
}
| { kind: 'issue'; issue: BoardIssue; span: Span; groupKey: string };
-// A consecutive same-month run, for the month labels above the day numbers.
-export interface MonthLabel {
- label: string;
- left: number;
- width: number;
-}
-
// The whole timeline layout derived from the project and the current viewport:
-// the flattened rows, the day columns and their month labels, the track width
-// (extended with trailing days so it always fills the viewport), the today
-// marker, the gridline background, and a helper to place a span's bar.
-export interface TimelineModel {
+// the flattened rows plus the day track they are placed on.
+export interface TimelineModel extends DayTrack {
rows: TimelineRow[];
- days: Date[];
- months: MonthLabel[];
- trackWidth: number;
- todayLeft: number;
- todayInRange: boolean;
- dayLines: { backgroundImage: string };
- spanToRect: (start: Date, end: Date) => { left: number; width: number };
}
export function buildTimeline({
@@ -94,9 +76,8 @@ export function buildTimeline({
}): TimelineModel {
const groups = buildGroups(project, group);
const issuesByGroup = groupIssues(groups, project.issues, group);
- // Rows, and the date range that covers every bar (plus padding and today).
+ // Rows, and the date range that covers every bar.
const rows: TimelineRow[] = [];
- const today = startOfDay(new Date());
let min: Date | null = null;
let max: Date | null = null;
for (const issueGroup of groups) {
@@ -121,37 +102,5 @@ export function buildTimeline({
}
}
- const rangeStart = addDays(min ?? today, -3);
- const rangeEnd = addDays(max ?? addDays(today, 28), 7);
- // Extend the range on the right with trailing days so the track always fills
- // the available width; the day size stays fixed.
- const naturalDays = Math.max(1, daysBetween(rangeStart, rangeEnd) + 1);
- const daysToFill = Math.ceil(Math.max(0, viewportW - labelW) / dayW);
- const totalDays = Math.max(naturalDays, daysToFill);
- const trackWidth = totalDays * dayW;
- const days = Array.from({ length: totalDays }, (_, i) => addDays(rangeStart, i));
-
- const months: MonthLabel[] = [];
- for (let i = 0; i < days.length; i++) {
- const label = format(days[i], 'MMMM yyyy');
- const last = months[months.length - 1];
- if (last && last.label === label) last.width += dayW;
- else months.push({ label, left: i * dayW, width: dayW });
- }
-
- // Per-day gridlines when days are wide; weekly gridlines when zoomed out, so
- // narrow days do not turn the track into solid lines.
- const gridPeriod = dayW >= 20 ? dayW : dayW * 7;
- const dayLines = {
- backgroundImage: `repeating-linear-gradient(to right, transparent 0, transparent ${gridPeriod - 1}px, var(--border) ${gridPeriod - 1}px, var(--border) ${gridPeriod}px)`,
- };
- const todayLeft = daysBetween(rangeStart, today) * dayW;
- const todayInRange = today >= rangeStart && today <= rangeEnd;
-
- const spanToRect = (start: Date, end: Date) => ({
- left: daysBetween(rangeStart, start) * dayW,
- width: (daysBetween(start, end) + 1) * dayW,
- });
-
- return { rows, days, months, trackWidth, todayLeft, todayInRange, dayLines, spanToRect };
+ return { rows, ...buildDayTrack({ min, max, viewportW, labelW, dayW }) };
}
diff --git a/apps/web/src/hooks/useElementWidth.ts b/apps/web/src/hooks/useElementWidth.ts
new file mode 100644
index 00000000..44a86dbc
--- /dev/null
+++ b/apps/web/src/hooks/useElementWidth.ts
@@ -0,0 +1,21 @@
+import { useEffect, useState, type RefObject } from 'react';
+
+// Live width of the element `ref` points at, for layouts that size themselves to
+// the room they are given. Until the element is measured it reports the window
+// width, which is also what the server render has to go on.
+export function useElementWidth(ref: RefObject<HTMLElement | null>): number {
+ const [width, setWidth] = useState(() =>
+ typeof window !== 'undefined' ? window.innerWidth : 1200,
+ );
+
+ useEffect(() => {
+ const el = ref.current;
+ if (!el) return;
+ const ro = new ResizeObserver(() => setWidth(el.clientWidth));
+ ro.observe(el);
+ setWidth(el.clientWidth);
+ return () => ro.disconnect();
+ }, [ref]);
+
+ return width;
+}
diff --git a/apps/web/src/features/initiatives/hooks/useInitiativeBoardSettings.ts b/apps/web/src/hooks/useLocalBoardSettings.ts
similarity index 60%
rename from apps/web/src/features/initiatives/hooks/useInitiativeBoardSettings.ts
rename to apps/web/src/hooks/useLocalBoardSettings.ts
index d4404681..7fb84d3b 100644
--- a/apps/web/src/features/initiatives/hooks/useInitiativeBoardSettings.ts
+++ b/apps/web/src/hooks/useLocalBoardSettings.ts
@@ -3,36 +3,34 @@ import type { WorkItemsView } from '@/utils/viewTypes';
import { normalizeViewSettings, type ViewSettings } from '@/utils/viewSettings';
import { EMPTY_FILTER_SET, type FilterSet } from '@/utils/filters';
-// Display settings for an initiative's issue board, persisted per initiative in
-// localStorage (there are no saved views here). Filters stay transient in state.
-// Layout (kanban/table) and its display settings are stored under one key so a
-// reload restores them. Mirrors the localStorage store in lib/viewSettings but
-// keyed by initiative id and layout.
-
-const STORE_KEY = 'planner_initiative_board_settings';
+// Display settings for an issue board that has no saved views — the one an
+// initiative or a cycle shows. Persisted in localStorage under `storeKey`, keyed by
+// the id of the thing the board belongs to; filters stay transient in state. Layout
+// (kanban/table) and its display settings are stored together so a reload restores
+// them. Mirrors the localStorage store in lib/viewSettings.
type Stored = { layout?: WorkItemsView } & Partial<ViewSettings>;
type Store = Record<string, Stored>;
-function readStore(): Store {
+function readStore(storeKey: string): Store {
if (typeof window === 'undefined') return {};
try {
- const parsed = JSON.parse(localStorage.getItem(STORE_KEY) ?? 'null');
+ const parsed = JSON.parse(localStorage.getItem(storeKey) ?? 'null');
return parsed && typeof parsed === 'object' ? (parsed as Store) : {};
} catch {
return {};
}
}
-function writeStore(store: Store) {
+function writeStore(storeKey: string, store: Store) {
if (typeof window === 'undefined') return;
- localStorage.setItem(STORE_KEY, JSON.stringify(store));
+ localStorage.setItem(storeKey, JSON.stringify(store));
}
-export function useInitiativeBoardSettings(initiativeId: number) {
- const key = String(initiativeId);
+export function useLocalBoardSettings(storeKey: string, id: number) {
+ const key = String(id);
const [state, setState] = useState<{ view: WorkItemsView; settings: ViewSettings }>(() => {
- const stored = readStore()[key];
+ const stored = readStore(storeKey)[key];
const view: WorkItemsView = stored?.layout ?? 'kanban';
return { view, settings: normalizeViewSettings(stored, view) };
});
@@ -40,20 +38,20 @@ export function useInitiativeBoardSettings(initiativeId: number) {
const persist = useCallback(
(view: WorkItemsView, settings: ViewSettings) => {
- const store = readStore();
+ const store = readStore(storeKey);
store[key] = { layout: view, ...settings };
- writeStore(store);
+ writeStore(storeKey, store);
},
- [key],
+ [storeKey, key],
);
const changeView = useCallback(
(view: WorkItemsView) => {
- const settings = normalizeViewSettings(readStore()[key], view);
+ const settings = normalizeViewSettings(readStore(storeKey)[key], view);
persist(view, settings);
setState({ view, settings });
},
- [key, persist],
+ [storeKey, key, persist],
);
const changeSettings = useCallback(
diff --git a/apps/web/src/hooks/useProjectFeatures.ts b/apps/web/src/hooks/useProjectFeatures.ts
index 59a7ed33..02cbd56d 100644
--- a/apps/web/src/hooks/useProjectFeatures.ts
+++ b/apps/web/src/hooks/useProjectFeatures.ts
@@ -10,9 +10,10 @@ import type { ProjectFeatures } from '@/lib/api';
// the same way usePermissions grants nothing until the project is there.
export function useProjectFeatures(): ProjectFeatures {
const project = useContext(ShellCtx)?.project ?? null;
- if (!project) return { initiatives: false, dashboards: false, notes: false };
+ if (!project) return { initiatives: false, cycles: false, dashboards: false, notes: false };
return {
initiatives: project.project.initiativesEnabled,
+ cycles: project.project.cyclesEnabled,
dashboards: project.project.dashboardsEnabled,
notes: project.project.notesEnabled,
};
diff --git a/apps/web/src/hooks/useShellProject.ts b/apps/web/src/hooks/useShellProject.ts
index f2383be7..41e1cfdb 100644
--- a/apps/web/src/hooks/useShellProject.ts
+++ b/apps/web/src/hooks/useShellProject.ts
@@ -6,6 +6,7 @@ import {
useProjectsQuery,
} from '@/services/projects.service';
import { useViewsQuery } from '@/services/views.service';
+import { usePlannedCyclesQuery } from '@/services/cycles.service';
import { ApiError } from '@/lib/api';
import { applyFilters } from '@/utils/filters';
import { withoutShownSubtasks } from '@/utils/subtasks';
@@ -32,6 +33,16 @@ export function useShellProject(projectKey: string | null, activeViewId: number
const projectQuery = useProjectQuery(projectKey);
const boardIssuesQuery = useBoardIssuesQuery(projectKey);
const scaffold = projectQuery.data ?? null;
+ // The planned cycles join the composite so grouping by cycle can lay out a lane
+ // per cycle a board plans into, not only per cycle an issue is already in. The
+ // whole list is not loaded: it grows with every finished cycle, and a finished
+ // one only needs a lane while its issues name it. Fetched while the section is
+ // on and the viewer may read it.
+ const canReadCycles =
+ scaffold?.viewer.role === 'owner' || scaffold?.permissions.cycles?.read === true;
+ const cyclesQuery = usePlannedCyclesQuery(
+ scaffold?.project.cyclesEnabled && canReadCycles ? projectKey : null,
+ );
const project = useMemo(
() =>
scaffold
@@ -39,9 +50,10 @@ export function useShellProject(projectKey: string | null, activeViewId: number
...scaffold,
issues: boardIssuesQuery.data?.issues ?? [],
rev: boardIssuesQuery.data?.rev ?? '',
+ plannedCycles: cyclesQuery.data ?? [],
}
: null,
- [scaffold, boardIssuesQuery.data],
+ [scaffold, boardIssuesQuery.data, cyclesQuery.data],
);
const viewsQuery = useViewsQuery(projectKey);
diff --git a/apps/web/src/hooks/useShellRoute.ts b/apps/web/src/hooks/useShellRoute.ts
index 86457237..eaffa83d 100644
--- a/apps/web/src/hooks/useShellRoute.ts
+++ b/apps/web/src/hooks/useShellRoute.ts
@@ -20,6 +20,7 @@ export type ShellRoute = {
// The project-scoped issue number from the URL, not the internal id.
routeIssueSeq: number | null;
routeInitiativeId: number | null;
+ routeCycleId: number | null;
// The work items routes, where the layout and selection commands apply.
onBoard: boolean;
};
@@ -47,6 +48,8 @@ export function useShellRoute(): ShellRoute {
// /initiatives/details/:id — the segment right after 'initiatives' is a list tab.
routeInitiativeId:
sub === 'initiatives' && segs[3] === 'details' && segs[4] ? Number(segs[4]) : null,
+ // /cycles/details/:id — the segment right after 'cycles' is a list layout.
+ routeCycleId: sub === 'cycles' && segs[3] === 'details' && segs[4] ? Number(segs[4]) : null,
onBoard: sub == null || sub === 'view',
};
}
diff --git a/apps/web/src/features/work-items/hooks/useTimelineLabelWidth.ts b/apps/web/src/hooks/useTimelineLabelWidth.ts
similarity index 77%
rename from apps/web/src/features/work-items/hooks/useTimelineLabelWidth.ts
rename to apps/web/src/hooks/useTimelineLabelWidth.ts
index 81e5ed32..dcdcba21 100644
--- a/apps/web/src/features/work-items/hooks/useTimelineLabelWidth.ts
+++ b/apps/web/src/hooks/useTimelineLabelWidth.ts
@@ -1,9 +1,10 @@
import { useCallback, useEffect, useState } from 'react';
-import { LABEL_MAX_W, LABEL_MIN_W, LABEL_W } from '../utils/timeline';
+import { LABEL_MAX_W, LABEL_MIN_W, LABEL_W } from '@/utils/timelineTrack';
-// Width of the Timeline's label column, dragged by the header's resize handle and
-// stored under `storageKey` (see labelWidthKey: one width per project and view).
-// Reloads when the key changes, so switching tabs picks up that tab's width.
+// Width of a timeline's label column, dragged by the header's resize handle and
+// stored under `storageKey` (see labelWidthKey and cycleLabelWidthKey: one width
+// per project and view). Reloads when the key changes, so switching tabs picks up
+// that tab's width.
//
// The stored value is read in an effect, not in the state initializer: the
// initializer also runs in the server render, where a client-only value would not
diff --git a/apps/web/src/lib/api.ts b/apps/web/src/lib/api.ts
index 5d866112..f6c60c57 100644
--- a/apps/web/src/lib/api.ts
+++ b/apps/web/src/lib/api.ts
@@ -66,6 +66,7 @@ export interface Project {
initiativesEnabled: boolean;
dashboardsEnabled: boolean;
notesEnabled: boolean;
+ cyclesEnabled: boolean;
createdAt: string;
// The caller's role in this project. Only present on the /projects list
// response (used to gate owner-only actions like deletion); absent on the
@@ -512,6 +513,9 @@ export interface Issue {
// The initiative this issue is linked to, expanded to id + title for rendering,
// or null. Set through updateIssue by initiativeId.
initiative: InitiativeOption | null;
+ // The cycle this issue is planned into, expanded to id + name for rendering, or
+ // null. Set through updateIssue by cycleId.
+ cycle: CycleOption | null;
assigneeUserId: string | null;
delegateUserId: string | null;
columnId: number;
@@ -553,6 +557,7 @@ export interface IssueSearchHit {
columnId: number;
typeId: number | null;
initiativeId: number | null;
+ cycleId: number | null;
parentId: number | null;
assigneeUserId: string | null;
delegateUserId: string | null;
@@ -574,6 +579,7 @@ export interface AutoArchiveSettings {
// hides its navigation entry and its section, keeping the rows behind it.
export interface ProjectFeatures {
initiatives: boolean;
+ cycles: boolean;
dashboards: boolean;
notes: boolean;
}
@@ -1289,6 +1295,7 @@ export type ActivityAction =
| 'delegate'
| 'priority'
| 'type'
+ | 'cycle'
| 'start_date'
| 'due_date'
| 'label_add'
@@ -1405,6 +1412,11 @@ export interface InitiativeOption {
title: string;
}
+export interface CycleOption {
+ id: number;
+ name: string;
+}
+
// The board scaffold, returned by getProject: everything the work-items UI needs
// except the issues themselves (those come from getBoardIssues).
export interface ProjectScaffold {
@@ -1441,9 +1453,12 @@ export interface BoardIssues {
rev: string;
}
-// The scaffold composed with its issues, as the Shell assembles it and passes it
-// down. Downstream reads project.issues / project.rev off this composite.
-export type ProjectDetail = ProjectScaffold & BoardIssues;
+// The scaffold composed with its issues and the project's unfinished cycles, as
+// the Shell assembles it and passes it down. Downstream reads project.issues /
+// project.rev off this composite. `plannedCycles` is empty while the Cycles section
+// is off, on a public share (whose bundle carries no cycle list), and for a viewer
+// who may not read cycles.
+export type ProjectDetail = ProjectScaffold & BoardIssues & { plannedCycles: Cycle[] };
export interface IssueDetail extends Issue {
fields: IssueFieldValue[];
@@ -1573,6 +1588,7 @@ export interface SharedViewBundle {
export interface NewIssueInput {
typeId?: number | null;
initiativeId?: number | null;
+ cycleId?: number | null;
assigneeUserId?: string | null;
delegateUserId?: string | null;
columnId: number;
@@ -1591,6 +1607,7 @@ export interface BulkIssuePatch {
columnId?: number;
typeId?: number | null;
initiativeId?: number | null;
+ cycleId?: number | null;
assigneeUserId?: string | null;
delegateUserId?: string | null;
priority?: string | null;
@@ -1604,6 +1621,7 @@ export interface IssuePatch {
typeId?: number | null;
parentId?: number | null;
initiativeId?: number | null;
+ cycleId?: number | null;
assigneeUserId?: string | null;
delegateUserId?: string | null;
title?: string;
@@ -1645,6 +1663,53 @@ export interface Initiative {
health: InitiativeHealth | null;
}
+// A time-boxed period of work (a sprint). status follows from the dates against
+// today and progress from the linked issues' states — neither is stored.
+export type CycleStatus = 'upcoming' | 'active' | 'completed';
+
+export interface CycleProgress {
+ completed: number;
+ canceled: number;
+ total: number;
+}
+
+export interface Cycle {
+ id: number;
+ projectId: number;
+ name: string;
+ // What the team commits to in this cycle (the sprint goal). Empty when unset.
+ goal: string;
+ startDate: string;
+ endDate: string;
+ status: CycleStatus;
+ createdAt: string;
+ updatedAt: string;
+ progress: CycleProgress;
+}
+
+// One page of the finished cycles. `total` counts all of them, so the archive can
+// say how many there are without loading them.
+export interface CyclePage {
+ items: Cycle[];
+ total: number;
+ page: number;
+ pageSize: number;
+}
+
+export interface NewCycleInput {
+ name: string;
+ goal?: string;
+ startDate: string;
+ endDate: string;
+}
+
+export interface CyclePatch {
+ name?: string;
+ goal?: string;
+ startDate?: string;
+ endDate?: string;
+}
+
// Columns the initiative list can be sorted by, server-side. progress and health
// are derived and not sortable.
export const INITIATIVE_SORTS = ['title', 'priority', 'targetDate', 'owner'] as const;
@@ -1738,6 +1803,7 @@ export type PermissionAction = 'create' | 'edit' | 'read' | 'delete';
export type PermissionResource =
| 'work_items'
| 'initiatives'
+ | 'cycles'
| 'dashboards'
| 'views'
| 'members_invite'
@@ -2258,6 +2324,30 @@ export const api = {
return request<InitiativeFeedPage>(`/initiatives/${id}/feed${qs ? `?${qs}` : ''}`);
},
+ // Cycles — same shape as initiatives: the list takes projectKey, ops on one cycle
+ // take its own id and hit /cycles/:id.
+ listCycles: (projectKey: string) => request<Cycle[]>(`/projects/${projectKey}/cycles`),
+ listPlannedCycles: (projectKey: string) =>
+ request<Cycle[]>(`/projects/${projectKey}/cycles?status=planned`),
+ listCompletedCycles: (projectKey: string, params: { page: number; pageSize: number }) =>
+ request<CyclePage>(
+ `/projects/${projectKey}/cycles/completed?page=${params.page}&pageSize=${params.pageSize}`,
+ ),
+ getCycle: (id: number) => request<Cycle>(`/cycles/${id}`),
+ createCycle: (projectKey: string, input: NewCycleInput) =>
+ request<Cycle>(`/projects/${projectKey}/cycles`, {
+ method: 'POST',
+ body: JSON.stringify(input),
+ }),
+ updateCycle: (id: number, patch: CyclePatch) =>
+ request<Cycle>(`/cycles/${id}`, { method: 'PATCH', body: JSON.stringify(patch) }),
+ deleteCycle: (id: number) => request<void>(`/cycles/${id}`, { method: 'DELETE' }),
+ transferCycleIssues: (id: number, targetCycleId: number | null) =>
+ request<{ moved: number }>(`/cycles/${id}/transfer`, {
+ method: 'POST',
+ body: JSON.stringify({ targetCycleId }),
+ }),
+
listViews: (projectKey: string) => request<View[]>(`/projects/${projectKey}/views`),
createView: (projectKey: string, input: NewViewInput) =>
request<View>(`/projects/${projectKey}/views`, { method: 'POST', body: JSON.stringify(input) }),
diff --git a/apps/web/src/services/cycles.service.ts b/apps/web/src/services/cycles.service.ts
new file mode 100644
index 00000000..3332a7a8
--- /dev/null
+++ b/apps/web/src/services/cycles.service.ts
@@ -0,0 +1,100 @@
+import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
+import { api, type CyclePatch, type NewCycleInput } from '@/lib/api';
+import { qk } from '@/services/queryKeys';
+
+// How many finished cycles the archive loads at a time.
+const COMPLETED_CYCLES_PAGE = 25;
+
+// Every cycle write changes the list and can change the cycle a detail page is
+// showing.
+function invalidateCycles(qc: ReturnType<typeof useQueryClient>, projectKey: string) {
+ void qc.invalidateQueries({ queryKey: qk.cycles(projectKey) });
+ void qc.invalidateQueries({ queryKey: qk.anyCycle });
+}
+
+// Deleting a cycle and transferring its issues both unlink issues from it. Which
+// ones is not known here, so the board and the open issues are invalidated by prefix.
+function invalidateCycleIssues(qc: ReturnType<typeof useQueryClient>, projectKey: string) {
+ void qc.invalidateQueries({ queryKey: qk.boardIssues(projectKey) });
+ void qc.invalidateQueries({ queryKey: qk.anyIssue });
+}
+
+export function useCyclesQuery(projectKey: string | null) {
+ return useQuery({
+ queryKey: qk.cycles(projectKey ?? ''),
+ queryFn: () => api.listCycles(projectKey!),
+ enabled: projectKey != null,
+ });
+}
+
+// What the cycles page lists, and what the pickers offer: the cycles that have not
+// finished. The whole list (useCyclesQuery) stays for the cycle form, which needs the
+// finished ones too — to name a cycle after the last one and to keep dates off an
+// existing range.
+export function usePlannedCyclesQuery(projectKey: string | null) {
+ return useQuery({
+ queryKey: qk.plannedCycles(projectKey ?? ''),
+ queryFn: () => api.listPlannedCycles(projectKey!),
+ enabled: projectKey != null,
+ });
+}
+
+// The finished cycles, newest first, a page at a time.
+export function useCompletedCyclesQuery(projectKey: string | null) {
+ return useInfiniteQuery({
+ queryKey: qk.completedCycles(projectKey ?? ''),
+ queryFn: ({ pageParam }) =>
+ api.listCompletedCycles(projectKey!, { page: pageParam, pageSize: COMPLETED_CYCLES_PAGE }),
+ initialPageParam: 1,
+ getNextPageParam: (lastPage) =>
+ lastPage.page * lastPage.pageSize < lastPage.total ? lastPage.page + 1 : undefined,
+ enabled: projectKey != null,
+ });
+}
+
+export function useCycleQuery(cycleId: number | null) {
+ return useQuery({
+ queryKey: qk.cycle(cycleId ?? -1),
+ queryFn: () => api.getCycle(cycleId!),
+ enabled: cycleId != null,
+ });
+}
+
+export function useCreateCycle(projectKey: string) {
+ const qc = useQueryClient();
+ return useMutation({
+ mutationFn: (input: NewCycleInput) => api.createCycle(projectKey, input),
+ onSuccess: () => invalidateCycles(qc, projectKey),
+ });
+}
+
+export function useUpdateCycle(projectKey: string) {
+ const qc = useQueryClient();
+ return useMutation({
+ mutationFn: ({ id, patch }: { id: number; patch: CyclePatch }) => api.updateCycle(id, patch),
+ onSuccess: () => invalidateCycles(qc, projectKey),
+ });
+}
+
+export function useDeleteCycle(projectKey: string) {
+ const qc = useQueryClient();
+ return useMutation({
+ mutationFn: (id: number) => api.deleteCycle(id),
+ onSuccess: () => {
+ invalidateCycles(qc, projectKey);
+ invalidateCycleIssues(qc, projectKey);
+ },
+ });
+}
+
+export function useTransferCycleIssues(projectKey: string) {
+ const qc = useQueryClient();
+ return useMutation({
+ mutationFn: ({ id, targetCycleId }: { id: number; targetCycleId: number | null }) =>
+ api.transferCycleIssues(id, targetCycleId),
+ onSuccess: () => {
+ invalidateCycles(qc, projectKey);
+ invalidateCycleIssues(qc, projectKey);
+ },
+ });
+}
diff --git a/apps/web/src/services/issues.service.ts b/apps/web/src/services/issues.service.ts
index 7e226491..34c8b47a 100644
--- a/apps/web/src/services/issues.service.ts
+++ b/apps/web/src/services/issues.service.ts
@@ -94,18 +94,21 @@ export function useUpdateIssue(projectKey: string | null) {
if (projectKey) void qc.invalidateQueries({ queryKey: qk.boardIssues(projectKey) });
void qc.invalidateQueries({ queryKey: qk.issue(id) });
void qc.invalidateQueries({ queryKey: qk.feed(id) });
- invalidateInitiatives(qc);
+ invalidateGroupings(qc);
},
});
}
// An issue write changes its initiative's progress/health and activity, and the
-// initiatives list shows that progress. The mutations do not know the initiative
-// id, so they invalidate by prefix; only active queries refetch.
-function invalidateInitiatives(qc: ReturnType<typeof useQueryClient>) {
+// initiatives list shows that progress. The same holds for the cycle it is planned
+// into. The mutations do not know either id, so they invalidate by prefix; only
+// active queries refetch.
+function invalidateGroupings(qc: ReturnType<typeof useQueryClient>) {
void qc.invalidateQueries({ queryKey: qk.anyInitiative });
void qc.invalidateQueries({ queryKey: qk.anyInitiativeFeed });
void qc.invalidateQueries({ queryKey: qk.anyInitiatives });
+ void qc.invalidateQueries({ queryKey: qk.anyCycle });
+ void qc.invalidateQueries({ queryKey: qk.anyCycles });
}
// Deletes an issue. Drops it from the project detail immediately and discards its
@@ -130,7 +133,7 @@ export function useDeleteIssue(projectKey: string | null) {
qc.removeQueries({ queryKey: qk.issue(id) });
qc.removeQueries({ queryKey: qk.feed(id) });
qc.removeQueries({ queryKey: qk.attachments(id) });
- invalidateInitiatives(qc);
+ invalidateGroupings(qc);
},
});
}
@@ -153,7 +156,7 @@ export function useArchiveIssue(projectKey: string | null) {
}
void qc.invalidateQueries({ queryKey: qk.issue(id) });
void qc.invalidateQueries({ queryKey: qk.feed(id) });
- invalidateInitiatives(qc);
+ invalidateGroupings(qc);
},
});
}
@@ -171,7 +174,7 @@ export function useRestoreIssue(projectKey: string | null) {
}
void qc.invalidateQueries({ queryKey: qk.issue(id) });
void qc.invalidateQueries({ queryKey: qk.feed(id) });
- invalidateInitiatives(qc);
+ invalidateGroupings(qc);
},
});
}
@@ -230,7 +233,7 @@ export function useBulkUpdateIssues(projectKey: string) {
},
onSettled: () => {
void qc.invalidateQueries({ queryKey: qk.boardIssues(projectKey) });
- invalidateInitiatives(qc);
+ invalidateGroupings(qc);
},
});
}
@@ -260,7 +263,7 @@ export function useBulkAddLabels(projectKey: string) {
},
onSettled: () => {
void qc.invalidateQueries({ queryKey: qk.boardIssues(projectKey) });
- invalidateInitiatives(qc);
+ invalidateGroupings(qc);
},
});
}
@@ -287,7 +290,7 @@ function useBulkRemoval(
qc.removeQueries({ queryKey: qk.issue(id) });
qc.removeQueries({ queryKey: qk.feed(id) });
}
- invalidateInitiatives(qc);
+ invalidateGroupings(qc);
},
});
}
@@ -311,7 +314,7 @@ export function useCreateIssue() {
api.createIssue(projectKey, input),
onSuccess: (_data, { projectKey }) => {
void qc.invalidateQueries({ queryKey: qk.boardIssues(projectKey) });
- invalidateInitiatives(qc);
+ invalidateGroupings(qc);
},
});
}
diff --git a/apps/web/src/services/queryKeys.ts b/apps/web/src/services/queryKeys.ts
index a2cd287e..5bec9d1e 100644
--- a/apps/web/src/services/queryKeys.ts
+++ b/apps/web/src/services/queryKeys.ts
@@ -108,6 +108,16 @@ export const qk = {
anyInitiative: ['initiative'] as const,
anyInitiativeFeed: ['initiativeFeed'] as const,
anyInitiatives: ['initiatives'] as const,
+ // Cycles: a project's list and one cycle. Issue mutations invalidate the whole
+ // 'cycles' subtree, since planning an issue moves a cycle's progress. The list the
+ // page reads is split in two — what is still planned, and the paged archive —
+ // under the same prefix, so one invalidation covers all three.
+ cycles: (projectKey: string) => ['cycles', projectKey] as const,
+ plannedCycles: (projectKey: string) => ['cycles', projectKey, 'planned'] as const,
+ completedCycles: (projectKey: string) => ['cycles', projectKey, 'completed'] as const,
+ cycle: (id: number) => ['cycle', id] as const,
+ anyCycles: ['cycles'] as const,
+ anyCycle: ['cycle'] as const,
attachments: (id: number) => ['attachments', id] as const,
// A project's inbox notifications (the list, scoped by the active filters) and the
// project's unread count (the sidebar badge + live-refresh target).
diff --git a/apps/web/src/utils/cycleMeta.ts b/apps/web/src/utils/cycleMeta.ts
new file mode 100644
index 00000000..f32df484
--- /dev/null
+++ b/apps/web/src/utils/cycleMeta.ts
@@ -0,0 +1,14 @@
+import type { CycleStatus } from '@/lib/api';
+
+// Display metadata for the cycle status, which the API derives from the dates.
+// Colors are raw hex so they can drive both a dot and a text color, like the
+// initiative status meta.
+export const CYCLE_STATUS_META: Record<CycleStatus, { label: string; color: string }> = {
+ upcoming: { label: 'Upcoming', color: '#6366f1' },
+ active: { label: 'Active', color: '#eab308' },
+ completed: { label: 'Completed', color: '#22c55e' },
+};
+
+// The order the list groups cycles in: what is running now, what is next, what is
+// behind.
+export const CYCLE_STATUS_ORDER: CycleStatus[] = ['active', 'upcoming', 'completed'];
diff --git a/apps/web/src/utils/paths.ts b/apps/web/src/utils/paths.ts
index b65a5ec8..bfb5975d 100644
--- a/apps/web/src/utils/paths.ts
+++ b/apps/web/src/utils/paths.ts
@@ -102,6 +102,24 @@ export const initiativePath = (
return tab === 'overview' ? base : `${base}/${tab}`;
};
+export const cyclesPath = (key: string) => `${projectPath(key)}/cycles`;
+
+// Each layout of the cycles list is a route of its own, so a reload or a shared
+// link reopens the one the user was on. The list path itself holds no layout: it
+// redirects to the one remembered for the project (see CyclesRedirect).
+const CYCLES_VIEWS = ['table', 'timeline'] as const;
+
+export type CyclesView = (typeof CYCLES_VIEWS)[number];
+
+export const isCyclesView = (value: string): value is CyclesView =>
+ (CYCLES_VIEWS as readonly string[]).includes(value);
+
+export const cyclesViewPath = (key: string, view: CyclesView) => `${cyclesPath(key)}/${view}`;
+
+// The cycle detail sits under /details/ so the layout segment of the list above
+// stays unambiguous.
+export const cyclePath = (key: string, cycleId: number) => `${cyclesPath(key)}/details/${cycleId}`;
+
// Where the app root sends the user, from their start page preference. The section
// opens in the project they were last in (see app/page.tsx).
export const startPagePath = (key: string, startPage: StartPage) => {
diff --git a/apps/web/src/utils/permissions.ts b/apps/web/src/utils/permissions.ts
index 9605af78..2fabb95f 100644
--- a/apps/web/src/utils/permissions.ts
+++ b/apps/web/src/utils/permissions.ts
@@ -5,6 +5,7 @@ import type { PermissionAction, PermissionResource } from '@/lib/api';
const RESOURCE_LABELS: Record<string, string> = {
work_items: 'Work items',
initiatives: 'Initiatives',
+ cycles: 'Cycles',
dashboards: 'Dashboards',
views: 'Work item views',
members_invite: 'Invites',
@@ -56,7 +57,7 @@ export interface PermissionGroup {
// The resources shown together in the role editor. Ordering is display order.
const GROUP_DEFS: PermissionGroup[] = [
- { title: 'Work items', resources: ['work_items', 'initiatives', 'views'] },
+ { title: 'Work items', resources: ['work_items', 'initiatives', 'cycles', 'views'] },
{ title: 'Dashboards', resources: ['dashboards'] },
{ title: 'Notes', resources: ['note_boards'] },
{ title: 'AI', resources: ['ai_agents', 'integrations', 'agent_skills', 'agent_tools'] },
diff --git a/apps/web/src/utils/progress.ts b/apps/web/src/utils/progress.ts
new file mode 100644
index 00000000..ffeb00b6
--- /dev/null
+++ b/apps/web/src/utils/progress.ts
@@ -0,0 +1,10 @@
+// How much of a set of issues is done, as a percentage. Canceled issues leave the
+// denominator so the number reflects deliverable work.
+export function progressPercent(progress: {
+ completed: number;
+ canceled: number;
+ total: number;
+}): number {
+ const denom = progress.total - progress.canceled;
+ return denom > 0 ? Math.round((progress.completed / denom) * 100) : 0;
+}
diff --git a/apps/web/src/utils/project.ts b/apps/web/src/utils/project.ts
index 762d8096..de807b5f 100644
--- a/apps/web/src/utils/project.ts
+++ b/apps/web/src/utils/project.ts
@@ -14,6 +14,7 @@ import type {
IssueType,
NewIssueInput,
} from '@/lib/api';
+import { CYCLE_STATUS_META } from '@/utils/cycleMeta';
import { PRIORITIES, PRIORITY_RANK } from '@/utils/fieldOptions';
import type { GroupField, ViewSettings } from '@/utils/viewSettings';
import type { Sort } from '@/utils/viewTypes';
@@ -22,7 +23,13 @@ export type { Sort, SortField } from '@/utils/viewTypes';
export type NewIssueDefaults = Pick<
NewIssueInput,
- 'columnId' | 'typeId' | 'initiativeId' | 'assigneeUserId' | 'delegateUserId' | 'priority'
+ | 'columnId'
+ | 'typeId'
+ | 'initiativeId'
+ | 'cycleId'
+ | 'assigneeUserId'
+ | 'delegateUserId'
+ | 'priority'
> &
Partial<Pick<NewIssueInput, 'title' | 'description' | 'parentId'>>;
@@ -239,6 +246,30 @@ export function buildGroups(project: ProjectDetail, group: GroupField): IssueGro
.map(([id, title]) => ({ key: `i${id}`, name: title, assign: { initiativeId: id } }));
return [...options, { key: 'i-none', name: 'No initiative', assign: { initiativeId: null } }];
}
+ case 'cycle': {
+ // A column per cycle the board plans into — the unfinished ones the project
+ // carries, oldest first (the API orders them by start date) — and one per
+ // cycle only the issues name, so the work of a finished cycle stays reachable.
+ // Those come first: they ended before the unfinished ones start. They take no
+ // drop: a finished cycle records what it delivered. A public share carries no
+ // cycle list, so all of its columns come from the issues.
+ const namedByIssues = new Map<number, string>();
+ for (const issue of project.issues)
+ if (issue.cycle) namedByIssues.set(issue.cycle.id, issue.cycle.name);
+ for (const c of project.plannedCycles) namedByIssues.delete(c.id);
+ return [
+ ...[...namedByIssues.entries()]
+ .sort((a, b) => a[1].localeCompare(b[1]))
+ .map(([id, name]) => ({ key: `y${id}`, name, assign: null })),
+ ...project.plannedCycles.map((c) => ({
+ key: `y${c.id}`,
+ name: c.name,
+ color: CYCLE_STATUS_META[c.status].color,
+ assign: { cycleId: c.id },
+ })),
+ { key: 'y-none', name: 'No cycle', assign: { cycleId: null } },
+ ];
+ }
case 'none':
return [{ key: 'all', name: '', assign: null }];
}
@@ -260,6 +291,8 @@ export function groupKeyOf(issue: Issue, group: GroupField): string {
return issue.typeId != null ? `t${issue.typeId}` : 't-none';
case 'initiative':
return issue.initiative != null ? `i${issue.initiative.id}` : 'i-none';
+ case 'cycle':
+ return issue.cycle != null ? `y${issue.cycle.id}` : 'y-none';
case 'none':
return 'all';
}
diff --git a/apps/web/src/utils/projectFeatures.ts b/apps/web/src/utils/projectFeatures.ts
index 9a2990f2..6e90f9a2 100644
--- a/apps/web/src/utils/projectFeatures.ts
+++ b/apps/web/src/utils/projectFeatures.ts
@@ -5,6 +5,7 @@ import type { ProjectFeatures } from '@/lib/api';
// while it is off, so it is named the same everywhere.
export const FEATURE_LABEL: Record<keyof ProjectFeatures, string> = {
initiatives: 'Initiatives',
+ cycles: 'Cycles',
dashboards: 'Dashboards',
notes: 'Notes',
};
diff --git a/apps/web/src/utils/publicProject.ts b/apps/web/src/utils/publicProject.ts
index 37d4cd3e..f70a4e32 100644
--- a/apps/web/src/utils/publicProject.ts
+++ b/apps/web/src/utils/publicProject.ts
@@ -22,5 +22,8 @@ export function toPublicProjectDetail(
permissions: {} as Permissions,
issues,
rev: '',
+ // A share bundle carries no cycle list; a view grouped by cycle gets its lanes
+ // from the cycles the shared issues are planned into.
+ plannedCycles: [],
};
}
diff --git a/apps/web/src/utils/timelineTrack.ts b/apps/web/src/utils/timelineTrack.ts
new file mode 100644
index 00000000..0f67a29b
--- /dev/null
+++ b/apps/web/src/utils/timelineTrack.ts
@@ -0,0 +1,86 @@
+import { format, startOfDay } from 'date-fns';
+import { addDays, daysBetween } from '@/utils/dates';
+
+// The day track the date-laid-out views place their bars on: the work items
+// timeline and the cycles timeline. Holds the geometry only — which rows exist and
+// what a bar means is the view's own.
+
+// The label column on the left of a timeline: its default width, what a drag of the
+// resize grip may take it down to and up to, and the fixed width small screens get
+// instead, where the day track needs the room more than the labels do.
+export const LABEL_W = 256;
+export const LABEL_NARROW_W = 140;
+export const LABEL_MIN_W = 160;
+export const LABEL_MAX_W = 640;
+
+// A consecutive same-month run, for the month labels above the day numbers.
+export interface MonthLabel {
+ label: string;
+ left: number;
+ width: number;
+}
+
+export interface DayTrack {
+ days: Date[];
+ months: MonthLabel[];
+ trackWidth: number;
+ todayLeft: number;
+ todayInRange: boolean;
+ dayLines: { backgroundImage: string };
+ spanToRect: (start: Date, end: Date) => { left: number; width: number };
+}
+
+// The track covering `min`..`max` with padding on both sides, extended on the right
+// with trailing days so it fills the viewport instead of leaving empty space; the
+// day size stays fixed. An empty range (both null) falls back to the four weeks
+// after today.
+export function buildDayTrack({
+ min,
+ max,
+ viewportW,
+ labelW,
+ dayW,
+}: {
+ min: Date | null;
+ max: Date | null;
+ viewportW: number;
+ labelW: number;
+ dayW: number;
+}): DayTrack {
+ const today = startOfDay(new Date());
+ const rangeStart = addDays(min ?? today, -3);
+ const rangeEnd = addDays(max ?? addDays(today, 28), 7);
+ const naturalDays = Math.max(1, daysBetween(rangeStart, rangeEnd) + 1);
+ const daysToFill = Math.ceil(Math.max(0, viewportW - labelW) / dayW);
+ const totalDays = Math.max(naturalDays, daysToFill);
+ const trackWidth = totalDays * dayW;
+ const days = Array.from({ length: totalDays }, (_, i) => addDays(rangeStart, i));
+
+ const months: MonthLabel[] = [];
+ for (let i = 0; i < days.length; i++) {
+ const label = format(days[i], 'MMMM yyyy');
+ const last = months[months.length - 1];
+ if (last && last.label === label) last.width += dayW;
+ else months.push({ label, left: i * dayW, width: dayW });
+ }
+
+ // Per-day gridlines when days are wide; weekly gridlines when zoomed out, so
+ // narrow days do not turn the track into solid lines.
+ const gridPeriod = dayW >= 20 ? dayW : dayW * 7;
+ const dayLines = {
+ backgroundImage: `repeating-linear-gradient(to right, transparent 0, transparent ${gridPeriod - 1}px, var(--border) ${gridPeriod - 1}px, var(--border) ${gridPeriod}px)`,
+ };
+
+ return {
+ days,
+ months,
+ trackWidth,
+ todayLeft: daysBetween(rangeStart, today) * dayW,
+ todayInRange: today >= rangeStart && today <= rangeEnd,
+ dayLines,
+ spanToRect: (start: Date, end: Date) => ({
+ left: daysBetween(rangeStart, start) * dayW,
+ width: (daysBetween(start, end) + 1) * dayW,
+ }),
+ };
+}
diff --git a/apps/web/src/utils/viewSettings.ts b/apps/web/src/utils/viewSettings.ts
index fcb786ee..2356e14e 100644
--- a/apps/web/src/utils/viewSettings.ts
+++ b/apps/web/src/utils/viewSettings.ts
@@ -4,13 +4,14 @@
// shows only the controls that apply to the active view. Missing fields fall
// back to per-view defaults, so the store grows new options without a migration.
+import type { ProjectFeatures } from '@/lib/api';
import type { Sort, WorkItemsView } from '@/utils/viewTypes';
// Field the Project columns / Table sections group by. 'none' is a single flat
// list (Table only). Project always groups by something. `subgroup` (below) adds a
// second level: Project swimlanes / Table sub-sections, and may be 'none'.
export type GroupField =
- 'none' | 'status' | 'assignee' | 'delegate' | 'priority' | 'type' | 'initiative';
+ 'none' | 'status' | 'assignee' | 'delegate' | 'priority' | 'type' | 'initiative' | 'cycle';
// Issue properties that can be shown on a Project card or as a Table column.
// 'id' is the issue identifier; 'status' the state; the rest map to issue
@@ -23,6 +24,7 @@ export type DisplayProperty =
| 'assignee'
| 'delegate'
| 'initiative'
+ | 'cycle'
| 'labels'
| 'startDate'
| 'dueDate'
@@ -51,6 +53,7 @@ export const DISPLAY_PROPERTIES: { value: DisplayProperty; label: string }[] = [
{ value: 'assignee', label: 'Assignee' },
{ value: 'delegate', label: 'Delegate' },
{ value: 'initiative', label: 'Initiative' },
+ { value: 'cycle', label: 'Cycle' },
{ value: 'labels', label: 'Labels' },
{ value: 'startDate', label: 'Start date' },
{ value: 'dueDate', label: 'Due date' },
@@ -59,14 +62,30 @@ export const DISPLAY_PROPERTIES: { value: DisplayProperty; label: string }[] = [
{ value: 'statusAge', label: 'Time in status' },
];
-// The display properties a project offers: Initiative only while its Initiatives
-// section is on.
+// The grouping fields and display properties that name an optional section's
+// entity, with the section each one needs. Grouping by one while its section is off
+// would render columns for something the project does not show, and its property
+// would print a value from there.
+const SECTION_FIELDS: Partial<Record<GroupField | DisplayProperty, keyof ProjectFeatures>> = {
+ initiative: 'initiatives',
+ cycle: 'cycles',
+};
+
+// Whether a grouping field or display property applies to a project: the ones behind
+// an optional section only while it is on. A custom field key is never section-bound.
+export function isFieldEnabled(
+ field: GroupField | PropertyKey,
+ features: ProjectFeatures,
+): boolean {
+ const section = SECTION_FIELDS[field as GroupField];
+ return section === undefined || features[section];
+}
+
+// The display properties a project offers, without the ones whose section is off.
export function offeredDisplayProperties(
- initiativesEnabled: boolean,
+ features: ProjectFeatures,
): { value: DisplayProperty; label: string }[] {
- return initiativesEnabled
- ? DISPLAY_PROPERTIES
- : DISPLAY_PROPERTIES.filter((p) => p.value !== 'initiative');
+ return DISPLAY_PROPERTIES.filter((p) => isFieldEnabled(p.value, features));
}
// Timeline zoom: how much horizontal space one day gets, which sets whether day
@@ -170,6 +189,7 @@ const GROUP_FIELDS: GroupField[] = [
'priority',
'type',
'initiative',
+ 'cycle',
];
const DISPLAY_VALUES = DISPLAY_PROPERTIES.map((p) => p.value);
const TIMELINE_SCALES: TimelineScale[] = ['week', 'month', 'quarter'];
@@ -267,36 +287,45 @@ export function normalizeViewSettings(
};
}
-// The same settings without the Initiative property, grouping and sub-grouping,
-// for a project with the Initiatives section turned off: a display built while it
-// was on then renders no dead column or lane.
-export function withoutInitiative(settings: ViewSettings): ViewSettings {
+// The same settings without the grouping, sub-grouping and display properties of a
+// section the project has turned off: a display built while the section was on then
+// renders no dead column, lane or property.
+export function withoutHiddenSections(
+ settings: ViewSettings,
+ features: ProjectFeatures,
+): ViewSettings {
return {
...settings,
- group: settings.group === 'initiative' ? 'status' : settings.group,
- subgroup: settings.subgroup === 'initiative' ? 'none' : settings.subgroup,
- properties: settings.properties.filter((p) => p !== 'initiative'),
+ group: isFieldEnabled(settings.group, features) ? settings.group : 'status',
+ subgroup: isFieldEnabled(settings.subgroup, features) ? settings.subgroup : 'none',
+ properties: settings.properties.filter((p) => isFieldEnabled(p, features)),
};
}
-// The counterpart of withoutInitiative: puts the stored Initiative choices back
-// into a display edited while the section was off, at the column position they
-// had. The panel could not show them, so an edit made then must not drop them —
-// the display comes back as it was once the section is on again. A value the user
-// did change carries through, since it then differs from what stripping left.
-export function restoreInitiative(edited: ViewSettings, stored: ViewSettings): ViewSettings {
- const at = stored.properties.indexOf('initiative');
+// The counterpart of withoutHiddenSections: puts the stored choices of a hidden
+// section back into a display edited while it was off, each property at the column
+// position it had. The panel could not show them, so an edit made then must not
+// drop them — the display comes back as it was once the section is on again. A
+// value the user did change carries through, since it then differs from what
+// stripping left.
+export function restoreHiddenSections(
+ edited: ViewSettings,
+ stored: ViewSettings,
+ features: ProjectFeatures,
+): ViewSettings {
+ const hidden = (field: GroupField | PropertyKey) => !isFieldEnabled(field, features);
+ // Stored order is ascending, so every insert lands at the index it had once the
+ // earlier hidden properties are back.
+ const properties = [...edited.properties];
+ stored.properties.forEach((p, index) => {
+ if (hidden(p)) properties.splice(index, 0, p);
+ });
return {
...edited,
- group: stored.group === 'initiative' && edited.group === 'status' ? 'initiative' : edited.group,
+ group: hidden(stored.group) && edited.group === 'status' ? stored.group : edited.group,
subgroup:
- stored.subgroup === 'initiative' && edited.subgroup === 'none'
- ? 'initiative'
- : edited.subgroup,
- properties:
- at === -1
- ? edited.properties
- : [...edited.properties.slice(0, at), 'initiative', ...edited.properties.slice(at)],
+ hidden(stored.subgroup) && edited.subgroup === 'none' ? stored.subgroup : edited.subgroup,
+ properties,
};
}
diff --git a/packages/db/drizzle/0064_gifted_taskmaster.sql b/packages/db/drizzle/0064_gifted_taskmaster.sql
new file mode 100644
index 00000000..af316e9f
--- /dev/null
+++ b/packages/db/drizzle/0064_gifted_taskmaster.sql
@@ -0,0 +1,17 @@
+CREATE TABLE "cycle" (
+ "id" serial PRIMARY KEY NOT NULL,
+ "project_id" integer NOT NULL,
+ "name" text NOT NULL,
+ "goal" text DEFAULT '' NOT NULL,
+ "start_date" date NOT NULL,
+ "end_date" date NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
+ CONSTRAINT "cycle_dates_check" CHECK ("cycle"."end_date" >= "cycle"."start_date")
+);
+--> statement-breakpoint
+ALTER TABLE "issue" ADD COLUMN "cycle_id" integer;--> statement-breakpoint
+ALTER TABLE "project" ADD COLUMN "cycles_enabled" boolean DEFAULT true NOT NULL;--> statement-breakpoint
+ALTER TABLE "cycle" ADD CONSTRAINT "cycle_project_id_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+CREATE INDEX "cycle_project_idx" ON "cycle" USING btree ("project_id","start_date");--> statement-breakpoint
+ALTER TABLE "issue" ADD CONSTRAINT "issue_cycle_id_cycle_id_fk" FOREIGN KEY ("cycle_id") REFERENCES "public"."cycle"("id") ON DELETE set null ON UPDATE no action;
\ No newline at end of file
diff --git a/packages/db/drizzle/0065_backfill_cycles_permission.sql b/packages/db/drizzle/0065_backfill_cycles_permission.sql
new file mode 100644
index 00000000..927afb50
--- /dev/null
+++ b/packages/db/drizzle/0065_backfill_cycles_permission.sql
@@ -0,0 +1,15 @@
+-- Custom SQL migration file, put your code below! --
+-- Seed the new `cycles` permission resource on existing roles. Cycles are planned
+-- alongside work items, so mirror each role's `work_items` flags onto `cycles`.
+-- A role that can create/edit issues can create/edit cycles; a read-only role gets
+-- read-only cycles. Roles missing `work_items` get all flags false.
+UPDATE "project_role"
+SET "permissions" = "permissions"
+ || jsonb_build_object(
+ 'cycles',
+ COALESCE(
+ "permissions" -> 'work_items',
+ '{"create": false, "edit": false, "read": false, "delete": false}'::jsonb
+ )
+ )
+WHERE NOT ("permissions" ? 'cycles');
diff --git a/packages/db/drizzle/0066_tidy_golden_guardian.sql b/packages/db/drizzle/0066_tidy_golden_guardian.sql
new file mode 100644
index 00000000..fa9f753e
--- /dev/null
+++ b/packages/db/drizzle/0066_tidy_golden_guardian.sql
@@ -0,0 +1 @@
+CREATE INDEX "issue_cycle_idx" ON "issue" USING btree ("cycle_id") WHERE "issue"."cycle_id" IS NOT NULL;
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0064_snapshot.json b/packages/db/drizzle/meta/0064_snapshot.json
new file mode 100644
index 00000000..25b1db2e
--- /dev/null
+++ b/packages/db/drizzle/meta/0064_snapshot.json
@@ -0,0 +1,5943 @@
+{
+ "id": "e65fb143-0d2e-4a6e-9ecb-ea5fdefff985",
+ "prevId": "41dcb1c2-382f-483b-8a05-d89608223850",
+ "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": 86400000
+ },
+ "rate_limit_max": {
+ "name": "rate_limit_max",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 10
+ },
+ "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.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()"
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'user'"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "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_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
+ },
+ "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
+ },
+ "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
+ },
+ "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_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": {}
+ }
+ },
+ "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_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"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_run_status_check": {
+ "name": "agent_run_status_check",
+ "value": "\"agent_run\".\"status\" IN ('pending', 'success', 'failed')"
+ },
+ "agent_run_trigger_check": {
+ "name": "agent_run_trigger_check",
+ "value": "\"agent_run\".\"trigger\" IN ('mention', 'delegation', 'schedule', 'manual')"
+ }
+ },
+ "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
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cron": {
+ "name": "cron",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "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": true
+ },
+ "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": {}
+ }
+ },
+ "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"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_schedule_agent_id_name_unique": {
+ "name": "agent_schedule_agent_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "agent_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "agent_schedule_status_check": {
+ "name": "agent_schedule_status_check",
+ "value": "\"agent_schedule\".\"status\" IN ('active', 'paused')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_skill": {
+ "name": "agent_skill",
+ "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": "''"
+ },
+ "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_project_idx": {
+ "name": "agent_skill_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_skill_project_id_project_id_fk": {
+ "name": "agent_skill_project_id_project_id_fk",
+ "tableFrom": "agent_skill",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_skill_project_id_name_unique": {
+ "name": "agent_skill_project_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_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
+ },
+ "project_id": {
+ "name": "project_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": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_tool_project_idx": {
+ "name": "agent_tool_project_idx",
+ "columns": [
+ {
+ "expression": "project_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_project_id_project_id_fk": {
+ "name": "agent_tool_project_id_project_id_fk",
+ "tableFrom": "agent_tool",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_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_project_id_tool_key_credential_id_unique": {
+ "name": "agent_tool_project_id_tool_key_credential_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_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
+ },
+ "project_id": {
+ "name": "project_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
+ },
+ "max_steps": {
+ "name": "max_steps",
+ "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
+ },
+ "role_id": {
+ "name": "role_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "ai_agent_project_idx": {
+ "name": "ai_agent_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "ai_agent_project_id_project_id_fk": {
+ "name": "ai_agent_project_id_project_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_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_role_id_project_role_id_fk": {
+ "name": "ai_agent_role_id_project_role_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "project_role",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "ai_agent_project_id_username_unique": {
+ "name": "ai_agent_project_id_username_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "username"
+ ]
+ },
+ "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')"
+ }
+ },
+ "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.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
+ },
+ "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', 'select', 'multi_select')"
+ }
+ },
+ "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
+ },
+ "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.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_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
+ },
+ "project_id": {
+ "name": "project_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_project_idx": {
+ "name": "integration_credential_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "integration_credential_project_id_project_id_fk": {
+ "name": "integration_credential_project_id_project_id_fk",
+ "tableFrom": "integration_credential",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_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
+ },
+ "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
+ },
+ "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_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": {}
+ }
+ },
+ "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": {},
+ "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
+ },
+ "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
+ },
+ "subject": {
+ "name": "subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "from_text": {
+ "name": "from_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "to_text": {
+ "name": "to_text",
+ "type": "text",
+ "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_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_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_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
+ }
+ },
+ "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"
+ }
+ },
+ "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_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_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.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.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": true
+ },
+ "source_activity_id": {
+ "name": "source_activity_id",
+ "type": "integer",
+ "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": {}
+ }
+ },
+ "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_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')"
+ }
+ },
+ "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
+ },
+ "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
+ },
+ "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
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_key_unique": {
+ "name": "project_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "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
+ },
+ "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"
+ }
+ },
+ "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')"
+ }
+ },
+ "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_invite": {
+ "name": "project_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()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "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
+ },
+ "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": {
+ "project_invite_pending_uq": {
+ "name": "project_invite_pending_uq",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"project_invite\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_invite_project_idx": {
+ "name": "project_invite_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_invite_project_id_project_id_fk": {
+ "name": "project_invite_project_id_project_id_fk",
+ "tableFrom": "project_invite",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_invite_role_id_project_role_id_fk": {
+ "name": "project_invite_role_id_project_role_id_fk",
+ "tableFrom": "project_invite",
+ "tableTo": "project_role",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_invite_invited_by_user_id_user_id_fk": {
+ "name": "project_invite_invited_by_user_id_user_id_fk",
+ "tableFrom": "project_invite",
+ "tableTo": "user",
+ "columnsFrom": [
+ "invited_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_invite_accepted_by_user_id_user_id_fk": {
+ "name": "project_invite_accepted_by_user_id_user_id_fk",
+ "tableFrom": "project_invite",
+ "tableTo": "user",
+ "columnsFrom": [
+ "accepted_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_invite_token_unique": {
+ "name": "project_invite_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "project_invite_role_check": {
+ "name": "project_invite_role_check",
+ "value": "\"project_invite\".\"role\" IN ('owner', 'member')"
+ },
+ "project_invite_status_check": {
+ "name": "project_invite_status_check",
+ "value": "\"project_invite\".\"status\" IN ('pending', 'accepted', 'rejected')"
+ }
+ },
+ "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": "''"
+ },
+ "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_project_role_id_fk": {
+ "name": "project_member_role_id_project_role_id_fk",
+ "tableFrom": "project_member",
+ "tableTo": "project_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')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_notification_setting": {
+ "name": "project_notification_setting",
+ "schema": "",
+ "columns": {
+ "project_id": {
+ "name": "project_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": {
+ "project_notification_setting_project_id_project_id_fk": {
+ "name": "project_notification_setting_project_id_project_id_fk",
+ "tableFrom": "project_notification_setting",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_role": {
+ "name": "project_role",
+ "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
+ },
+ "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": {
+ "project_role_default_uq": {
+ "name": "project_role_default_uq",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"project_role\".\"is_default\"",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_role_project_idx": {
+ "name": "project_role_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_role_project_id_project_id_fk": {
+ "name": "project_role_project_id_project_id_fk",
+ "tableFrom": "project_role",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_role_project_id_name_unique": {
+ "name": "project_role_project_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "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_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
+ },
+ "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": {}
+ }
+ },
+ "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"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_view_share_token_unique": {
+ "name": "project_view_share_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "share_token"
+ ]
+ }
+ },
+ "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'"
+ },
+ "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
+ },
+ "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', 'ai-chat')"
+ },
+ "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
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0065_snapshot.json b/packages/db/drizzle/meta/0065_snapshot.json
new file mode 100644
index 00000000..1be43abe
--- /dev/null
+++ b/packages/db/drizzle/meta/0065_snapshot.json
@@ -0,0 +1,5943 @@
+{
+ "id": "133a8ed7-42b9-4889-b300-3fab552816a7",
+ "prevId": "e65fb143-0d2e-4a6e-9ecb-ea5fdefff985",
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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": 86400000
+ },
+ "rate_limit_max": {
+ "name": "rate_limit_max",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 10
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ },
+ "apikey_referenceId_idx": {
+ "name": "apikey_referenceId_idx",
+ "columns": [
+ {
+ "expression": "reference_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ },
+ "apikey_key_idx": {
+ "name": "apikey_key_idx",
+ "columns": [
+ {
+ "expression": "key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ },
+ "passkey_credentialID_idx": {
+ "name": "passkey_credentialID_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "passkey_user_id_user_id_fk": {
+ "name": "passkey_user_id_user_id_fk",
+ "tableFrom": "passkey",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "columns": [
+ "token"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "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()"
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'user'"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "columns": [
+ "email"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "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
+ },
+ "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
+ },
+ "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
+ },
+ "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_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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ },
+ "agent_run_schedule_idx": {
+ "name": "agent_run_schedule_idx",
+ "columns": [
+ {
+ "expression": "schedule_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "agent_run_agent_id_ai_agent_id_fk": {
+ "name": "agent_run_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_run",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "tableTo": "ai_agent",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "agent_run_issue_id_issue_id_fk": {
+ "name": "agent_run_issue_id_issue_id_fk",
+ "tableFrom": "agent_run",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "tableTo": "issue",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "agent_run_schedule_id_agent_schedule_id_fk": {
+ "name": "agent_run_schedule_id_agent_schedule_id_fk",
+ "tableFrom": "agent_run",
+ "columnsFrom": [
+ "schedule_id"
+ ],
+ "tableTo": "agent_schedule",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "agent_run_source_activity_id_issue_activity_id_fk": {
+ "name": "agent_run_source_activity_id_issue_activity_id_fk",
+ "tableFrom": "agent_run",
+ "columnsFrom": [
+ "source_activity_id"
+ ],
+ "tableTo": "issue_activity",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_run_status_check": {
+ "name": "agent_run_status_check",
+ "value": "\"agent_run\".\"status\" IN ('pending', 'success', 'failed')"
+ },
+ "agent_run_trigger_check": {
+ "name": "agent_run_trigger_check",
+ "value": "\"agent_run\".\"trigger\" IN ('mention', 'delegation', 'schedule', 'manual')"
+ }
+ },
+ "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
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cron": {
+ "name": "cron",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "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": true
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ },
+ "agent_schedule_agent_idx": {
+ "name": "agent_schedule_agent_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "agent_schedule_agent_id_ai_agent_id_fk": {
+ "name": "agent_schedule_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_schedule",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "tableTo": "ai_agent",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_schedule_agent_id_name_unique": {
+ "name": "agent_schedule_agent_id_name_unique",
+ "columns": [
+ "agent_id",
+ "name"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "agent_schedule_status_check": {
+ "name": "agent_schedule_status_check",
+ "value": "\"agent_schedule\".\"status\" IN ('active', 'paused')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_skill": {
+ "name": "agent_skill",
+ "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": "''"
+ },
+ "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_project_idx": {
+ "name": "agent_skill_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "agent_skill_project_id_project_id_fk": {
+ "name": "agent_skill_project_id_project_id_fk",
+ "tableFrom": "agent_skill",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_skill_project_id_name_unique": {
+ "name": "agent_skill_project_id_name_unique",
+ "columns": [
+ "project_id",
+ "name"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "agent_skill_link_agent_id_ai_agent_id_fk": {
+ "name": "agent_skill_link_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_skill_link",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "tableTo": "ai_agent",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "agent_skill_link_skill_id_agent_skill_id_fk": {
+ "name": "agent_skill_link_skill_id_agent_skill_id_fk",
+ "tableFrom": "agent_skill_link",
+ "columnsFrom": [
+ "skill_id"
+ ],
+ "tableTo": "agent_skill",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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
+ },
+ "project_id": {
+ "name": "project_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": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_tool_project_idx": {
+ "name": "agent_tool_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ },
+ "agent_tool_credential_idx": {
+ "name": "agent_tool_credential_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "agent_tool_project_id_project_id_fk": {
+ "name": "agent_tool_project_id_project_id_fk",
+ "tableFrom": "agent_tool",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "agent_tool_credential_id_integration_credential_id_fk": {
+ "name": "agent_tool_credential_id_integration_credential_id_fk",
+ "tableFrom": "agent_tool",
+ "columnsFrom": [
+ "credential_id"
+ ],
+ "tableTo": "integration_credential",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_tool_project_id_tool_key_credential_id_unique": {
+ "name": "agent_tool_project_id_tool_key_credential_id_unique",
+ "columns": [
+ "project_id",
+ "tool_key",
+ "credential_id"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "agent_tool_link_agent_id_ai_agent_id_fk": {
+ "name": "agent_tool_link_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_tool_link",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "tableTo": "ai_agent",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "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",
+ "columnsFrom": [
+ "agent_tool_id"
+ ],
+ "tableTo": "agent_tool",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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
+ },
+ "project_id": {
+ "name": "project_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
+ },
+ "max_steps": {
+ "name": "max_steps",
+ "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
+ },
+ "role_id": {
+ "name": "role_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "ai_agent_project_idx": {
+ "name": "ai_agent_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "ai_agent_project_id_project_id_fk": {
+ "name": "ai_agent_project_id_project_id_fk",
+ "tableFrom": "ai_agent",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "ai_agent_user_id_user_id_fk": {
+ "name": "ai_agent_user_id_user_id_fk",
+ "tableFrom": "ai_agent",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "ai_agent_model_credential_id_integration_credential_id_fk": {
+ "name": "ai_agent_model_credential_id_integration_credential_id_fk",
+ "tableFrom": "ai_agent",
+ "columnsFrom": [
+ "model_credential_id"
+ ],
+ "tableTo": "integration_credential",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ },
+ "ai_agent_role_id_project_role_id_fk": {
+ "name": "ai_agent_role_id_project_role_id_fk",
+ "tableFrom": "ai_agent",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "tableTo": "project_role",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "ai_agent_project_id_username_unique": {
+ "name": "ai_agent_project_id_username_unique",
+ "columns": [
+ "project_id",
+ "username"
+ ],
+ "nullsNotDistinct": false
+ },
+ "ai_agent_user_id_unique": {
+ "name": "ai_agent_user_id_unique",
+ "columns": [
+ "user_id"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "ai_agent_kind_check": {
+ "name": "ai_agent_kind_check",
+ "value": "\"ai_agent\".\"kind\" IN ('external', 'internal')"
+ }
+ },
+ "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.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
+ },
+ "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",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "custom_field_issue_type_id_issue_type_id_fk": {
+ "name": "custom_field_issue_type_id_issue_type_id_fk",
+ "tableFrom": "custom_field",
+ "columnsFrom": [
+ "issue_type_id"
+ ],
+ "tableTo": "issue_type",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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', 'select', 'multi_select')"
+ }
+ },
+ "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",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "tableTo": "custom_field",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "custom_field_option_field_id_value_unique": {
+ "name": "custom_field_option_field_id_value_unique",
+ "columns": [
+ "field_id",
+ "value"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "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
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "cycle_project_id_project_id_fk": {
+ "name": "cycle_project_id_project_id_fk",
+ "tableFrom": "cycle",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "cycle_dates_check": {
+ "name": "cycle_dates_check",
+ "value": "\"cycle\".\"end_date\" >= \"cycle\".\"start_date\""
+ }
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "initiative_project_id_project_id_fk": {
+ "name": "initiative_project_id_project_id_fk",
+ "tableFrom": "initiative",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "initiative_owner_user_id_user_id_fk": {
+ "name": "initiative_owner_user_id_user_id_fk",
+ "tableFrom": "initiative",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "initiative_status_check": {
+ "name": "initiative_status_check",
+ "value": "\"initiative\".\"status\" IN ('proposed', 'planned', 'active', 'completed', 'canceled')"
+ }
+ },
+ "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",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "tableTo": "initiative",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "initiative_label_label_id_label_id_fk": {
+ "name": "initiative_label_label_id_label_id_fk",
+ "tableFrom": "initiative_label",
+ "columnsFrom": [
+ "label_id"
+ ],
+ "tableTo": "label",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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
+ },
+ "project_id": {
+ "name": "project_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_project_idx": {
+ "name": "integration_credential_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "integration_credential_project_id_project_id_fk": {
+ "name": "integration_credential_project_id_project_id_fk",
+ "tableFrom": "integration_credential",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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
+ },
+ "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
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "where": "\"issue\".\"archived_at\" IS NULL",
+ "concurrently": false
+ },
+ "issue_parent_idx": {
+ "name": "issue_parent_idx",
+ "columns": [
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "with": {},
+ "method": "btree",
+ "where": "\"issue\".\"parent_id\" IS NOT NULL",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "issue_project_id_project_id_fk": {
+ "name": "issue_project_id_project_id_fk",
+ "tableFrom": "issue",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "issue_type_id_issue_type_id_fk": {
+ "name": "issue_type_id_issue_type_id_fk",
+ "tableFrom": "issue",
+ "columnsFrom": [
+ "type_id"
+ ],
+ "tableTo": "issue_type",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ },
+ "issue_initiative_id_initiative_id_fk": {
+ "name": "issue_initiative_id_initiative_id_fk",
+ "tableFrom": "issue",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "tableTo": "initiative",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ },
+ "issue_cycle_id_cycle_id_fk": {
+ "name": "issue_cycle_id_cycle_id_fk",
+ "tableFrom": "issue",
+ "columnsFrom": [
+ "cycle_id"
+ ],
+ "tableTo": "cycle",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ },
+ "issue_column_id_project_column_id_fk": {
+ "name": "issue_column_id_project_column_id_fk",
+ "tableFrom": "issue",
+ "columnsFrom": [
+ "column_id"
+ ],
+ "tableTo": "project_column",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "no action"
+ },
+ "issue_parent_id_issue_id_fk": {
+ "name": "issue_parent_id_issue_id_fk",
+ "tableFrom": "issue",
+ "columnsFrom": [
+ "parent_id"
+ ],
+ "tableTo": "issue",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ },
+ "issue_assignee_user_id_user_id_fk": {
+ "name": "issue_assignee_user_id_user_id_fk",
+ "tableFrom": "issue",
+ "columnsFrom": [
+ "assignee_user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ },
+ "issue_delegate_user_id_user_id_fk": {
+ "name": "issue_delegate_user_id_user_id_fk",
+ "tableFrom": "issue",
+ "columnsFrom": [
+ "delegate_user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_share_token_unique": {
+ "name": "issue_share_token_unique",
+ "columns": [
+ "share_token"
+ ],
+ "nullsNotDistinct": false
+ },
+ "issue_project_id_sequence_number_unique": {
+ "name": "issue_project_id_sequence_number_unique",
+ "columns": [
+ "project_id",
+ "sequence_number"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "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
+ },
+ "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
+ },
+ "subject": {
+ "name": "subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "from_text": {
+ "name": "from_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "to_text": {
+ "name": "to_text",
+ "type": "text",
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "issue_activity_issue_id_issue_id_fk": {
+ "name": "issue_activity_issue_id_issue_id_fk",
+ "tableFrom": "issue_activity",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "tableTo": "issue",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "issue_activity_initiative_id_initiative_id_fk": {
+ "name": "issue_activity_initiative_id_initiative_id_fk",
+ "tableFrom": "issue_activity",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "tableTo": "initiative",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "issue_activity_actor_user_id_user_id_fk": {
+ "name": "issue_activity_actor_user_id_user_id_fk",
+ "tableFrom": "issue_activity",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ }
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "issue_attachment_issue_id_issue_id_fk": {
+ "name": "issue_attachment_issue_id_issue_id_fk",
+ "tableFrom": "issue_attachment",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "tableTo": "issue",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_attachment_public_id_unique": {
+ "name": "issue_attachment_public_id_unique",
+ "columns": [
+ "public_id"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "issue_checklist_issue_id_issue_id_fk": {
+ "name": "issue_checklist_issue_id_issue_id_fk",
+ "tableFrom": "issue_checklist",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "tableTo": "issue",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "issue_checklist_item_checklist_id_issue_checklist_id_fk": {
+ "name": "issue_checklist_item_checklist_id_issue_checklist_id_fk",
+ "tableFrom": "issue_checklist_item",
+ "columnsFrom": [
+ "checklist_id"
+ ],
+ "tableTo": "issue_checklist",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "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",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "tableTo": "issue",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "issue_field_option_field_id_custom_field_id_fk": {
+ "name": "issue_field_option_field_id_custom_field_id_fk",
+ "tableFrom": "issue_field_option",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "tableTo": "custom_field",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "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",
+ "columnsFrom": [
+ "option_id"
+ ],
+ "tableTo": "custom_field_option",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_field_value_issue_id_issue_id_fk": {
+ "name": "issue_field_value_issue_id_issue_id_fk",
+ "tableFrom": "issue_field_value",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "tableTo": "issue",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "issue_field_value_field_id_custom_field_id_fk": {
+ "name": "issue_field_value_field_id_custom_field_id_fk",
+ "tableFrom": "issue_field_value",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "tableTo": "custom_field",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_field_value_issue_id_field_id_unique": {
+ "name": "issue_field_value_issue_id_field_id_unique",
+ "columns": [
+ "issue_id",
+ "field_id"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "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",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "tableTo": "issue",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "issue_label_label_id_label_id_fk": {
+ "name": "issue_label_label_id_label_id_fk",
+ "tableFrom": "issue_label",
+ "columnsFrom": [
+ "label_id"
+ ],
+ "tableTo": "label",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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\")",
+ "isExpression": true,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "greatest(\"source_issue_id\", \"target_issue_id\")",
+ "isExpression": true,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ },
+ "issue_link_source_idx": {
+ "name": "issue_link_source_idx",
+ "columns": [
+ {
+ "expression": "source_issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ },
+ "issue_link_target_idx": {
+ "name": "issue_link_target_idx",
+ "columns": [
+ {
+ "expression": "target_issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "issue_link_source_issue_id_issue_id_fk": {
+ "name": "issue_link_source_issue_id_issue_id_fk",
+ "tableFrom": "issue_link",
+ "columnsFrom": [
+ "source_issue_id"
+ ],
+ "tableTo": "issue",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "issue_link_target_issue_id_issue_id_fk": {
+ "name": "issue_link_target_issue_id_issue_id_fk",
+ "tableFrom": "issue_link",
+ "columnsFrom": [
+ "target_issue_id"
+ ],
+ "tableTo": "issue",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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_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",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_type_project_id_name_unique": {
+ "name": "issue_type_project_id_name_unique",
+ "columns": [
+ "project_id",
+ "name"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "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",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "tableTo": "issue",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "issue_watcher_user_id_user_id_fk": {
+ "name": "issue_watcher_user_id_user_id_fk",
+ "tableFrom": "issue_watcher",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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.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",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "label_group_id_label_group_id_fk": {
+ "name": "label_group_id_label_group_id_fk",
+ "tableFrom": "label",
+ "columnsFrom": [
+ "group_id"
+ ],
+ "tableTo": "label_group",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "label_project_id_name_unique": {
+ "name": "label_project_id_name_unique",
+ "columns": [
+ "project_id",
+ "name"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "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",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "label_group_project_id_name_unique": {
+ "name": "label_group_project_id_name_unique",
+ "columns": [
+ "project_id",
+ "name"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "note_board_project_id_project_id_fk": {
+ "name": "note_board_project_id_project_id_fk",
+ "tableFrom": "note_board",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "note_board_owner_user_id_user_id_fk": {
+ "name": "note_board_owner_user_id_user_id_fk",
+ "tableFrom": "note_board",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "note_board_created_by_user_id_user_id_fk": {
+ "name": "note_board_created_by_user_id_user_id_fk",
+ "tableFrom": "note_board",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ }
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "note_board_member_board_id_note_board_id_fk": {
+ "name": "note_board_member_board_id_note_board_id_fk",
+ "tableFrom": "note_board_member",
+ "columnsFrom": [
+ "board_id"
+ ],
+ "tableTo": "note_board",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "note_board_member_user_id_user_id_fk": {
+ "name": "note_board_member_user_id_user_id_fk",
+ "tableFrom": "note_board_member",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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": true
+ },
+ "source_activity_id": {
+ "name": "source_activity_id",
+ "type": "integer",
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "where": "\"notification\".\"read_at\" IS NULL",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "notification_user_id_user_id_fk": {
+ "name": "notification_user_id_user_id_fk",
+ "tableFrom": "notification",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "notification_project_id_project_id_fk": {
+ "name": "notification_project_id_project_id_fk",
+ "tableFrom": "notification",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "notification_issue_id_issue_id_fk": {
+ "name": "notification_issue_id_issue_id_fk",
+ "tableFrom": "notification",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "tableTo": "issue",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "notification_source_activity_id_issue_activity_id_fk": {
+ "name": "notification_source_activity_id_issue_activity_id_fk",
+ "tableFrom": "notification",
+ "columnsFrom": [
+ "source_activity_id"
+ ],
+ "tableTo": "issue_activity",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ },
+ "notification_actor_user_id_user_id_fk": {
+ "name": "notification_actor_user_id_user_id_fk",
+ "tableFrom": "notification",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "notification_type_check": {
+ "name": "notification_type_check",
+ "value": "\"notification\".\"type\" IN ('assigned', 'mentioned', 'commented', 'state_changed')"
+ }
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "where": "\"notification_delivery\".\"status\" = 'pending'",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "notification_delivery_project_id_project_id_fk": {
+ "name": "notification_delivery_project_id_project_id_fk",
+ "tableFrom": "notification_delivery",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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
+ },
+ "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
+ },
+ "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
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_key_unique": {
+ "name": "project_key_unique",
+ "columns": [
+ "key"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "project_action_project_id_project_id_fk": {
+ "name": "project_action_project_id_project_id_fk",
+ "tableFrom": "project_action",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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
+ },
+ "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",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_column_project_id_position_unique": {
+ "name": "project_column_project_id_position_unique",
+ "columns": [
+ "project_id",
+ "position"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "project_column_state_type_check": {
+ "name": "project_column_state_type_check",
+ "value": "\"project_column\".\"state_type\" IN ('backlog', 'unstarted', 'started', 'completed', 'canceled')"
+ }
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "project_dashboard_project_id_project_id_fk": {
+ "name": "project_dashboard_project_id_project_id_fk",
+ "tableFrom": "project_dashboard",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_invite": {
+ "name": "project_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()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "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
+ },
+ "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": {
+ "project_invite_pending_uq": {
+ "name": "project_invite_pending_uq",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "with": {},
+ "method": "btree",
+ "where": "\"project_invite\".\"status\" = 'pending'",
+ "concurrently": false
+ },
+ "project_invite_project_idx": {
+ "name": "project_invite_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "project_invite_project_id_project_id_fk": {
+ "name": "project_invite_project_id_project_id_fk",
+ "tableFrom": "project_invite",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "project_invite_role_id_project_role_id_fk": {
+ "name": "project_invite_role_id_project_role_id_fk",
+ "tableFrom": "project_invite",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "tableTo": "project_role",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ },
+ "project_invite_invited_by_user_id_user_id_fk": {
+ "name": "project_invite_invited_by_user_id_user_id_fk",
+ "tableFrom": "project_invite",
+ "columnsFrom": [
+ "invited_by_user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ },
+ "project_invite_accepted_by_user_id_user_id_fk": {
+ "name": "project_invite_accepted_by_user_id_user_id_fk",
+ "tableFrom": "project_invite",
+ "columnsFrom": [
+ "accepted_by_user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_invite_token_unique": {
+ "name": "project_invite_token_unique",
+ "columns": [
+ "token"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "project_invite_role_check": {
+ "name": "project_invite_role_check",
+ "value": "\"project_invite\".\"role\" IN ('owner', 'member')"
+ },
+ "project_invite_status_check": {
+ "name": "project_invite_status_check",
+ "value": "\"project_invite\".\"status\" IN ('pending', 'accepted', 'rejected')"
+ }
+ },
+ "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": "''"
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "project_member_project_id_project_id_fk": {
+ "name": "project_member_project_id_project_id_fk",
+ "tableFrom": "project_member",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "project_member_user_id_user_id_fk": {
+ "name": "project_member_user_id_user_id_fk",
+ "tableFrom": "project_member",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "project_member_role_id_project_role_id_fk": {
+ "name": "project_member_role_id_project_role_id_fk",
+ "tableFrom": "project_member",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "tableTo": "project_role",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ }
+ },
+ "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')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_notification_setting": {
+ "name": "project_notification_setting",
+ "schema": "",
+ "columns": {
+ "project_id": {
+ "name": "project_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": {
+ "project_notification_setting_project_id_project_id_fk": {
+ "name": "project_notification_setting_project_id_project_id_fk",
+ "tableFrom": "project_notification_setting",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_role": {
+ "name": "project_role",
+ "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
+ },
+ "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": {
+ "project_role_default_uq": {
+ "name": "project_role_default_uq",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "with": {},
+ "method": "btree",
+ "where": "\"project_role\".\"is_default\"",
+ "concurrently": false
+ },
+ "project_role_project_idx": {
+ "name": "project_role_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "project_role_project_id_project_id_fk": {
+ "name": "project_role_project_id_project_id_fk",
+ "tableFrom": "project_role",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_role_project_id_name_unique": {
+ "name": "project_role_project_id_name_unique",
+ "columns": [
+ "project_id",
+ "name"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "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",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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_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
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "project_view_project_id_project_id_fk": {
+ "name": "project_view_project_id_project_id_fk",
+ "tableFrom": "project_view",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_view_share_token_unique": {
+ "name": "project_view_share_token_unique",
+ "columns": [
+ "share_token"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "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",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "user_notification_preference_project_id_project_id_fk": {
+ "name": "user_notification_preference_project_id_project_id_fk",
+ "tableFrom": "user_notification_preference",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_notification_pref_user_project_unique": {
+ "name": "user_notification_pref_user_project_unique",
+ "columns": [
+ "user_id",
+ "project_id"
+ ],
+ "nullsNotDistinct": false
+ }
+ },
+ "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'"
+ },
+ "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
+ },
+ "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",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ },
+ "user_preference_last_project_id_project_id_fk": {
+ "name": "user_preference_last_project_id_project_id_fk",
+ "tableFrom": "user_preference",
+ "columnsFrom": [
+ "last_project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "set null"
+ }
+ },
+ "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', 'ai-chat')"
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "where": "\"user_telegram_account\".\"chat_id\" IS NOT NULL",
+ "concurrently": false
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "where": "\"user_telegram_account\".\"link_code\" IS NOT NULL",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "user_telegram_account_user_id_user_id_fk": {
+ "name": "user_telegram_account_user_id_user_id_fk",
+ "tableFrom": "user_telegram_account",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "tableTo": "user",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "webhook_project_id_project_id_fk": {
+ "name": "webhook_project_id_project_id_fk",
+ "tableFrom": "webhook",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "tableTo": "project",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "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,
+ "with": {},
+ "method": "btree",
+ "where": "\"webhook_delivery\".\"status\" = 'pending'",
+ "concurrently": false
+ },
+ "webhook_delivery_webhook_idx": {
+ "name": "webhook_delivery_webhook_idx",
+ "columns": [
+ {
+ "expression": "webhook_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "with": {},
+ "method": "btree",
+ "concurrently": false
+ }
+ },
+ "foreignKeys": {
+ "webhook_delivery_webhook_id_webhook_id_fk": {
+ "name": "webhook_delivery_webhook_id_webhook_id_fk",
+ "tableFrom": "webhook_delivery",
+ "columnsFrom": [
+ "webhook_id"
+ ],
+ "tableTo": "webhook",
+ "columnsTo": [
+ "id"
+ ],
+ "onUpdate": "no action",
+ "onDelete": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "views": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0066_snapshot.json b/packages/db/drizzle/meta/0066_snapshot.json
new file mode 100644
index 00000000..dc2cba4f
--- /dev/null
+++ b/packages/db/drizzle/meta/0066_snapshot.json
@@ -0,0 +1,5959 @@
+{
+ "id": "09897703-5a1e-4bda-bb6a-8016470f8954",
+ "prevId": "133a8ed7-42b9-4889-b300-3fab552816a7",
+ "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": 86400000
+ },
+ "rate_limit_max": {
+ "name": "rate_limit_max",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 10
+ },
+ "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.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()"
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'user'"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "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_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
+ },
+ "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
+ },
+ "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
+ },
+ "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_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": {}
+ }
+ },
+ "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_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"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_run_status_check": {
+ "name": "agent_run_status_check",
+ "value": "\"agent_run\".\"status\" IN ('pending', 'success', 'failed')"
+ },
+ "agent_run_trigger_check": {
+ "name": "agent_run_trigger_check",
+ "value": "\"agent_run\".\"trigger\" IN ('mention', 'delegation', 'schedule', 'manual')"
+ }
+ },
+ "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
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cron": {
+ "name": "cron",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "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": true
+ },
+ "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": {}
+ }
+ },
+ "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"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_schedule_agent_id_name_unique": {
+ "name": "agent_schedule_agent_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "agent_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "agent_schedule_status_check": {
+ "name": "agent_schedule_status_check",
+ "value": "\"agent_schedule\".\"status\" IN ('active', 'paused')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_skill": {
+ "name": "agent_skill",
+ "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": "''"
+ },
+ "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_project_idx": {
+ "name": "agent_skill_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_skill_project_id_project_id_fk": {
+ "name": "agent_skill_project_id_project_id_fk",
+ "tableFrom": "agent_skill",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_skill_project_id_name_unique": {
+ "name": "agent_skill_project_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_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
+ },
+ "project_id": {
+ "name": "project_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": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_tool_project_idx": {
+ "name": "agent_tool_project_idx",
+ "columns": [
+ {
+ "expression": "project_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_project_id_project_id_fk": {
+ "name": "agent_tool_project_id_project_id_fk",
+ "tableFrom": "agent_tool",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_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_project_id_tool_key_credential_id_unique": {
+ "name": "agent_tool_project_id_tool_key_credential_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_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
+ },
+ "project_id": {
+ "name": "project_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
+ },
+ "max_steps": {
+ "name": "max_steps",
+ "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
+ },
+ "role_id": {
+ "name": "role_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "ai_agent_project_idx": {
+ "name": "ai_agent_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "ai_agent_project_id_project_id_fk": {
+ "name": "ai_agent_project_id_project_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_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_role_id_project_role_id_fk": {
+ "name": "ai_agent_role_id_project_role_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "project_role",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "ai_agent_project_id_username_unique": {
+ "name": "ai_agent_project_id_username_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "username"
+ ]
+ },
+ "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')"
+ }
+ },
+ "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.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
+ },
+ "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', 'select', 'multi_select')"
+ }
+ },
+ "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
+ },
+ "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.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_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
+ },
+ "project_id": {
+ "name": "project_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_project_idx": {
+ "name": "integration_credential_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "integration_credential_project_id_project_id_fk": {
+ "name": "integration_credential_project_id_project_id_fk",
+ "tableFrom": "integration_credential",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_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
+ },
+ "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
+ },
+ "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_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": {}
+ }
+ },
+ "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": {},
+ "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
+ },
+ "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
+ },
+ "subject": {
+ "name": "subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "from_text": {
+ "name": "from_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "to_text": {
+ "name": "to_text",
+ "type": "text",
+ "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_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_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_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
+ }
+ },
+ "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"
+ }
+ },
+ "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_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_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.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.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": true
+ },
+ "source_activity_id": {
+ "name": "source_activity_id",
+ "type": "integer",
+ "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": {}
+ }
+ },
+ "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_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')"
+ }
+ },
+ "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
+ },
+ "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
+ },
+ "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
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_key_unique": {
+ "name": "project_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "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
+ },
+ "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"
+ }
+ },
+ "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')"
+ }
+ },
+ "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_invite": {
+ "name": "project_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()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "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
+ },
+ "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": {
+ "project_invite_pending_uq": {
+ "name": "project_invite_pending_uq",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"project_invite\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_invite_project_idx": {
+ "name": "project_invite_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_invite_project_id_project_id_fk": {
+ "name": "project_invite_project_id_project_id_fk",
+ "tableFrom": "project_invite",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_invite_role_id_project_role_id_fk": {
+ "name": "project_invite_role_id_project_role_id_fk",
+ "tableFrom": "project_invite",
+ "tableTo": "project_role",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_invite_invited_by_user_id_user_id_fk": {
+ "name": "project_invite_invited_by_user_id_user_id_fk",
+ "tableFrom": "project_invite",
+ "tableTo": "user",
+ "columnsFrom": [
+ "invited_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_invite_accepted_by_user_id_user_id_fk": {
+ "name": "project_invite_accepted_by_user_id_user_id_fk",
+ "tableFrom": "project_invite",
+ "tableTo": "user",
+ "columnsFrom": [
+ "accepted_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_invite_token_unique": {
+ "name": "project_invite_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "project_invite_role_check": {
+ "name": "project_invite_role_check",
+ "value": "\"project_invite\".\"role\" IN ('owner', 'member')"
+ },
+ "project_invite_status_check": {
+ "name": "project_invite_status_check",
+ "value": "\"project_invite\".\"status\" IN ('pending', 'accepted', 'rejected')"
+ }
+ },
+ "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": "''"
+ },
+ "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_project_role_id_fk": {
+ "name": "project_member_role_id_project_role_id_fk",
+ "tableFrom": "project_member",
+ "tableTo": "project_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')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_notification_setting": {
+ "name": "project_notification_setting",
+ "schema": "",
+ "columns": {
+ "project_id": {
+ "name": "project_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": {
+ "project_notification_setting_project_id_project_id_fk": {
+ "name": "project_notification_setting_project_id_project_id_fk",
+ "tableFrom": "project_notification_setting",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_role": {
+ "name": "project_role",
+ "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
+ },
+ "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": {
+ "project_role_default_uq": {
+ "name": "project_role_default_uq",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"project_role\".\"is_default\"",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_role_project_idx": {
+ "name": "project_role_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_role_project_id_project_id_fk": {
+ "name": "project_role_project_id_project_id_fk",
+ "tableFrom": "project_role",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_role_project_id_name_unique": {
+ "name": "project_role_project_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "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_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
+ },
+ "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": {}
+ }
+ },
+ "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"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_view_share_token_unique": {
+ "name": "project_view_share_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "share_token"
+ ]
+ }
+ },
+ "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'"
+ },
+ "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
+ },
+ "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', 'ai-chat')"
+ },
+ "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
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.json
index 91231a87..c5622cd5 100644
--- a/packages/db/drizzle/meta/_journal.json
+++ b/packages/db/drizzle/meta/_journal.json
@@ -449,6 +449,27 @@
"when": 1785880921407,
"tag": "0063_solid_shatterstar",
"breakpoints": true
+ },
+ {
+ "idx": 64,
+ "version": "7",
+ "when": 1785918404465,
+ "tag": "0064_gifted_taskmaster",
+ "breakpoints": true
+ },
+ {
+ "idx": 65,
+ "version": "7",
+ "when": 1785918411701,
+ "tag": "0065_backfill_cycles_permission",
+ "breakpoints": true
+ },
+ {
+ "idx": 66,
+ "version": "7",
+ "when": 1785961218376,
+ "tag": "0066_tidy_golden_guardian",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/packages/db/src/schema/app.ts b/packages/db/src/schema/app.ts
index 87cbfe1b..78d64831 100644
--- a/packages/db/src/schema/app.ts
+++ b/packages/db/src/schema/app.ts
@@ -67,6 +67,7 @@ export const project = pgTable('project', {
initiativesEnabled: boolean('initiatives_enabled').notNull().default(true),
dashboardsEnabled: boolean('dashboards_enabled').notNull().default(true),
notesEnabled: boolean('notes_enabled').notNull().default(true),
+ cyclesEnabled: boolean('cycles_enabled').notNull().default(true),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
});
@@ -795,6 +796,32 @@ export const initiativeLabel = pgTable(
(t) => [primaryKey({ columns: [t.initiativeId, t.labelId] })],
);
+// A time-boxed period of work inside a project (a sprint). Issues point at it
+// through issue.cycle_id. The state of a cycle — upcoming, active, completed — is
+// not stored: it follows from start_date/end_date against the current date, so a
+// cycle never has to be started or closed by hand. Cycles of one project may not
+// overlap, which is what makes at most one of them active; the API enforces that.
+export const cycle = pgTable(
+ 'cycle',
+ {
+ id: serial('id').primaryKey(),
+ projectId: integer('project_id')
+ .notNull()
+ .references(() => project.id, { onDelete: 'cascade' }),
+ name: text('name').notNull(),
+ // What the team commits to in this cycle (the sprint goal). Empty when unset.
+ goal: text('goal').notNull().default(''),
+ startDate: date('start_date').notNull(),
+ endDate: date('end_date').notNull(),
+ createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
+ updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
+ },
+ (t) => [
+ check('cycle_dates_check', sql`${t.endDate} >= ${t.startDate}`),
+ index('cycle_project_idx').on(t.projectId, t.startDate),
+ ],
+);
+
export const issue = pgTable(
'issue',
{
@@ -811,6 +838,11 @@ export const issue = pgTable(
initiativeId: integer('initiative_id').references(() => initiative.id, {
onDelete: 'set null',
}),
+ // The cycle this issue is planned into (project-scoped). Nullable; deleting a
+ // cycle unlinks its issues rather than deleting them.
+ cycleId: integer('cycle_id').references(() => cycle.id, {
+ onDelete: 'set null',
+ }),
columnId: integer('column_id')
.notNull()
.references(() => projectColumn.id),
@@ -862,6 +894,11 @@ export const issue = pgTable(
index('issue_parent_idx')
.on(t.parentId)
.where(sql`${t.parentId} IS NOT NULL`),
+ // Backs the progress counts of a cycles list, the transfer of a cycle's issues,
+ // and the ON DELETE SET NULL a cycle delete runs.
+ index('issue_cycle_idx')
+ .on(t.cycleId)
+ .where(sql`${t.cycleId} IS NOT NULL`),
],
);