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: finish a cycle early and start the next one today (#212)

Croff3863a1c009a2
diff --git a/apps/api/src/modules/cycles/__tests__/integration/cycles.test.ts b/apps/api/src/modules/cycles/__tests__/integration/cycles.test.ts
index c854ba1e..5a8512a0 100644
--- a/apps/api/src/modules/cycles/__tests__/integration/cycles.test.ts
+++ b/apps/api/src/modules/cycles/__tests__/integration/cycles.test.ts
@@ -29,6 +29,7 @@ async function setup() {
columnId: columns[0].id,
startedColumnId: columns.find((c) => c.stateType === 'started')!.id,
doneColumnId: columns.find((c) => c.stateType === 'completed')!.id,
+ canceledColumnId: columns.find((c) => c.stateType === 'canceled')!.id,
};
}
@@ -442,6 +443,147 @@ describe('cycles', () => {
});
});
+ describe('finish', () => {
+ it('completes a running cycle without touching its planned end date', async () => {
+ const { asOwner } = await setup();
+ const cycle = (await createCycle(asOwner, {})).data!;
+
+ const res = await asOwner.cycles({ cycleId: cycle.id }).finish.post();
+ expect(res.status).toBe(200);
+ expect(res.data).toMatchObject({ status: 'completed', endDate: cycle.endDate });
+ expect(res.data!.completedAt).not.toBeNull();
+ });
+
+ it('moves the cycle out of the planned list and the options into the archive', async () => {
+ const { asOwner } = await setup();
+ const cycle = (await createCycle(asOwner, {})).data!;
+ await asOwner.cycles({ cycleId: cycle.id }).finish.post();
+
+ expect((await cycles(asOwner).get({ query: { status: 'planned' } })).data).toEqual([]);
+ expect((await cycles(asOwner).options.get()).data).toEqual([]);
+ const archive = await cycles(asOwner).completed.get({ query: {} });
+ expect(archive.data!.items.map((c) => c.id)).toEqual([cycle.id]);
+ });
+
+ it('takes no new issue once it is finished', async () => {
+ const { asOwner, columnId } = await setup();
+ const cycle = (await createCycle(asOwner, {})).data!;
+ await asOwner.cycles({ cycleId: cycle.id }).finish.post();
+
+ expect((await createIssue(asOwner, columnId, { cycleId: cycle.id })).status).toBe(400);
+ });
+
+ it('keeps its issues, which the transfer route still moves out', async () => {
+ const { asOwner, columnId } = await setup();
+ const cycle = (await createCycle(asOwner, {})).data!;
+ const issue = (await createIssue(asOwner, columnId, { cycleId: cycle.id })).data!;
+ await asOwner.cycles({ cycleId: cycle.id }).finish.post();
+
+ expect((await asOwner.issues({ issueId: issue.id }).get()).data!.cycle).toMatchObject({
+ id: cycle.id,
+ });
+
+ const moved = await asOwner
+ .cycles({ cycleId: cycle.id })
+ .transfer.post({ targetCycleId: null });
+ expect(moved.data).toMatchObject({ moved: 1 });
+ expect((await asOwner.issues({ issueId: issue.id }).get()).data!.cycle).toBeNull();
+ });
+
+ it('rejects an upcoming cycle and one that is already finished', async () => {
+ const { asOwner } = await setup();
+ const upcoming = (await createCycle(asOwner, { startDate: day(10), endDate: day(16) })).data!;
+ expect((await asOwner.cycles({ cycleId: upcoming.id }).finish.post()).status).toBe(400);
+
+ const past = (await createCycle(asOwner, { startDate: day(-14), endDate: day(-8) })).data!;
+ expect((await asOwner.cycles({ cycleId: past.id }).finish.post()).status).toBe(400);
+
+ const cycle = (await createCycle(asOwner, {})).data!;
+ expect((await asOwner.cycles({ cycleId: cycle.id }).finish.post()).status).toBe(200);
+ expect((await asOwner.cycles({ cycleId: cycle.id }).finish.post()).status).toBe(400);
+ });
+
+ it('frees the days it gave up and keeps the ones it ran', async () => {
+ const { asOwner } = await setup();
+ const cycle = (await createCycle(asOwner, { startDate: day(-2), endDate: day(6) })).data!;
+ await asOwner.cycles({ cycleId: cycle.id }).finish.post();
+
+ expect((await createCycle(asOwner, { startDate: day(1), endDate: day(6) })).status).toBe(201);
+ expect((await createCycle(asOwner, { startDate: day(-4), endDate: day(-2) })).status).toBe(
+ 400,
+ );
+ });
+
+ it('404s on an unknown cycle', async () => {
+ const { asOwner } = await setup();
+ expect((await asOwner.cycles({ cycleId: 999999 }).finish.post()).status).toBe(404);
+ });
+ });
+
+ describe('start next', () => {
+ it('finishes the running cycle, starts the next one today and carries the work over', async () => {
+ const { asOwner, columnId, doneColumnId, canceledColumnId } = await setup();
+ const running = (await createCycle(asOwner, { startDate: day(-2), endDate: day(6) })).data!;
+ const next = (await createCycle(asOwner, { startDate: day(10), endDate: day(16) })).data!;
+ const open = (await createIssue(asOwner, columnId, { cycleId: running.id })).data!;
+ const done = (await createIssue(asOwner, doneColumnId, { cycleId: running.id })).data!;
+ const canceled = (await createIssue(asOwner, canceledColumnId, { cycleId: running.id }))
+ .data!;
+
+ const res = await asOwner.cycles({ cycleId: running.id })['start-next'].post();
+ expect(res.status).toBe(200);
+ expect(res.data).toMatchObject({
+ moved: 1,
+ cycle: { id: next.id, endDate: next.endDate, status: 'active' },
+ });
+ expect(new Date(res.data!.cycle.startDate).toISOString().slice(0, 10)).toBe(day(0));
+
+ const finished = (await asOwner.cycles({ cycleId: running.id }).get()).data!;
+ expect(finished.status).toBe('completed');
+ expect(finished.endDate).toEqual(running.endDate);
+
+ expect((await asOwner.issues({ issueId: open.id }).get()).data!.cycle).toMatchObject({
+ id: next.id,
+ });
+ for (const stayed of [done, canceled]) {
+ expect((await asOwner.issues({ issueId: stayed.id }).get()).data!.cycle).toMatchObject({
+ id: running.id,
+ });
+ }
+ });
+
+ it('rejects a project with no upcoming cycle', async () => {
+ const { asOwner } = await setup();
+ const running = (await createCycle(asOwner, {})).data!;
+ await createCycle(asOwner, { startDate: day(-14), endDate: day(-8) });
+
+ const res = await asOwner.cycles({ cycleId: running.id })['start-next'].post();
+ expect(res.status).toBe(400);
+ expect((await asOwner.cycles({ cycleId: running.id }).get()).data!.status).toBe('active');
+ });
+
+ it('leaves the started cycle free to move its end date', async () => {
+ const { asOwner } = await setup();
+ const running = (await createCycle(asOwner, { startDate: day(-2), endDate: day(6) })).data!;
+ const next = (await createCycle(asOwner, { startDate: day(10), endDate: day(16) })).data!;
+ await asOwner.cycles({ cycleId: running.id })['start-next'].post();
+
+ expect((await asOwner.cycles({ cycleId: next.id }).patch({ endDate: day(20) })).status).toBe(
+ 200,
+ );
+ });
+
+ it('rejects a cycle that is not running', async () => {
+ const { asOwner } = await setup();
+ const upcoming = (await createCycle(asOwner, { startDate: day(10), endDate: day(16) })).data!;
+ await createCycle(asOwner, { startDate: day(20), endDate: day(26) });
+
+ expect((await asOwner.cycles({ cycleId: upcoming.id })['start-next'].post()).status).toBe(
+ 400,
+ );
+ });
+ });
+
describe('options', () => {
it('offers the cycles that have not finished', async () => {
const { asOwner } = await setup();
@@ -504,6 +646,8 @@ describe('cycles', () => {
(await outsider.cycles({ cycleId: cycle.id }).transfer.post({ targetCycleId: null }))
.status,
).toBe(403);
+ expect((await outsider.cycles({ cycleId: cycle.id }).finish.post()).status).toBe(403);
+ expect((await outsider.cycles({ cycleId: cycle.id })['start-next'].post()).status).toBe(403);
expect((await outsider.cycles({ cycleId: cycle.id }).delete()).status).toBe(403);
});
});
diff --git a/apps/api/src/modules/cycles/index.ts b/apps/api/src/modules/cycles/index.ts
index 5ba4b964..b927cd76 100644
--- a/apps/api/src/modules/cycles/index.ts
+++ b/apps/api/src/modules/cycles/index.ts
@@ -12,6 +12,7 @@ import {
CycleOptionListResponse,
CyclePageResponse,
CycleResponse,
+ StartNextCycleResponse,
TransferCycleResponse,
completedCyclesQuery,
createCycleBody,
@@ -29,6 +30,8 @@ import {
createCycle,
updateCycle,
deleteCycle,
+ finishCycle,
+ startNextCycle,
} from './service';
export const cycleRoutes = new Elysia({
@@ -177,6 +180,54 @@ export const cycleRoutes = new Elysia({
},
)
+ .post(
+ '/cycles/:cycleId/finish',
+ async ({ params }) => {
+ const finished = await finishCycle(params.cycleId);
+ if (!finished) throw new HttpError(404, 'Cycle not found');
+ return finished;
+ },
+ {
+ params: cycleParams,
+ cycle: 'edit',
+ response: { 200: CycleResponse, ...commonErrors },
+ detail: {
+ summary: 'Finish a cycle',
+ description:
+ 'Close a running cycle before its planned end date. Final: a finished cycle cannot be reopened, keeps its planned end date, and keeps its issues.',
+ ...mcpTool('finish_cycle', { destructiveHint: true }),
+ },
+ },
+ )
+
+ .post(
+ '/cycles/:cycleId/start-next',
+ async ({ params, user, projectId }) => {
+ const started = await startNextCycle(params.cycleId);
+ if (!started) throw new HttpError(404, 'Cycle not found');
+ const moved = await transferCycleIssues(
+ projectId,
+ params.cycleId,
+ started.id,
+ requireUser(user).id,
+ );
+ // Read back after the transfer, so the started cycle carries the issues it
+ // just received in its progress counts.
+ return { cycle: (await getCycle(started.id)) ?? started, moved };
+ },
+ {
+ params: cycleParams,
+ cycle: 'edit',
+ response: { 200: StartNextCycleResponse, ...commonErrors },
+ detail: {
+ summary: 'Start the next cycle today',
+ description:
+ "Finish the running cycle and start the project's next upcoming cycle today, moving the unfinished issues over. The started cycle keeps its planned end date.",
+ ...mcpTool('start_next_cycle', { destructiveHint: true }),
+ },
+ },
+ )
+
.post(
'/cycles/:cycleId/transfer',
// projectId comes from the cycle guard, which resolved it to check access.
diff --git a/apps/api/src/modules/cycles/model.ts b/apps/api/src/modules/cycles/model.ts
index ef5f1b47..10e86e69 100644
--- a/apps/api/src/modules/cycles/model.ts
+++ b/apps/api/src/modules/cycles/model.ts
@@ -19,7 +19,8 @@ export const listCyclesQuery = t.Object({
export const completedCyclesQuery = t.Object(pageQueryFields);
// CycleRow from the service. status follows from the dates against today (upcoming /
-// active / completed) and progress is derived issue counts; neither is stored.
+// active / completed), unless completedAt marks the cycle as finished early; progress
+// is derived issue counts.
export const CycleResponse = t.Object({
id: t.Number(),
projectId: t.Number(),
@@ -27,6 +28,7 @@ export const CycleResponse = t.Object({
goal: t.String(),
startDate: t.String(),
endDate: t.String(),
+ completedAt: t.Nullable(t.String()),
status: t.String(),
createdAt: t.String(),
updatedAt: t.String(),
@@ -59,3 +61,7 @@ export const transferCycleBody = t.Object({
});
export const TransferCycleResponse = t.Object({ moved: t.Number() });
+
+// The cycle that was started, with how many issues came over from the one that was
+// finished to start it.
+export const StartNextCycleResponse = t.Object({ cycle: CycleResponse, moved: t.Number() });
diff --git a/apps/api/src/modules/cycles/service.ts b/apps/api/src/modules/cycles/service.ts
index 1e43d69b..0ff297c6 100644
--- a/apps/api/src/modules/cycles/service.ts
+++ b/apps/api/src/modules/cycles/service.ts
@@ -1,10 +1,12 @@
import { db, cycle, issue, projectColumn } from '@repo/db';
-import { and, asc, desc, eq, ne, sql, type SQL } from 'drizzle-orm';
+import { and, asc, desc, eq, isNull, 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.
+// The one thing that is stored is completed_at, set when a cycle is finished ahead
+// of its dates.
export type CycleStatus = 'upcoming' | 'active' | 'completed';
@@ -21,6 +23,8 @@ export interface CycleRow {
goal: string;
startDate: string;
endDate: string;
+ // When the cycle was finished ahead of its planned end date, or null.
+ completedAt: string | null;
status: CycleStatus;
createdAt: string;
updatedAt: string;
@@ -28,8 +32,14 @@ export interface CycleRow {
}
// 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.
-export function cycleStatus(startDate: string, endDate: string): CycleStatus {
+// its own boundary days regardless of the reader's zone. A cycle finished early is
+// completed from the moment it was finished, whatever its dates say.
+export function cycleStatus(
+ startDate: string,
+ endDate: string,
+ completedAt: Date | null,
+): CycleStatus {
+ if (completedAt) return 'completed';
const today = new Date().toISOString().slice(0, 10);
if (today < startDate) return 'upcoming';
if (today > endDate) return 'completed';
@@ -44,7 +54,8 @@ function toCycle(row: typeof cycle.$inferSelect, progress: CycleProgress): Cycle
goal: row.goal,
startDate: row.startDate,
endDate: row.endDate,
- status: cycleStatus(row.startDate, row.endDate),
+ completedAt: row.completedAt ? iso(row.completedAt) : null,
+ status: cycleStatus(row.startDate, row.endDate, row.completedAt),
createdAt: iso(row.createdAt),
updatedAt: iso(row.updatedAt),
progress,
@@ -83,6 +94,18 @@ function mapCycle(r: CycleAggregate): CycleRow {
// Today in UTC, the same boundary cycleStatus compares against.
const TODAY = sql`(now() at time zone 'utc')::date`;
+const NOW = sql`now()` as unknown as Date;
+
+// The last day a cycle blocks another one from starting. A cycle finished early gave
+// up the rest of its planned range, and it shares the day it was finished with
+// whatever starts next — which is what "start the next cycle today" does — so it
+// blocks only up to the day before that.
+const OCCUPIED_UNTIL = sql`coalesce((${cycle.completedAt} at time zone 'utc')::date - 1, ${cycle.endDate})`;
+
+// A cycle has finished when it was finished early or when its planned end date has
+// passed. The planned list and the archive split on exactly this.
+const FINISHED = sql`(${cycle.completedAt} is not null or ${cycle.endDate} < ${TODAY})`;
+
// 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(
@@ -97,7 +120,7 @@ export async function listCycles(projectId: number): Promise<CycleRow[]> {
// 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}`),
+ and(eq(cycle.projectId, projectId), sql`not ${FINISHED}`),
).orderBy(asc(cycle.startDate), asc(cycle.id));
return rows.map(mapCycle);
}
@@ -113,7 +136,7 @@ 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 where = and(eq(cycle.projectId, projectId), FINISHED);
const rows = await selectCycles(where)
.orderBy(desc(cycle.startDate), desc(cycle.id))
.limit(limit)
@@ -138,11 +161,21 @@ 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 })
+ .select({
+ projectId: cycle.projectId,
+ startDate: cycle.startDate,
+ endDate: cycle.endDate,
+ completedAt: cycle.completedAt,
+ })
.from(cycle)
.where(eq(cycle.id, id));
const row = rows[0];
- return row ? { projectId: row.projectId, status: cycleStatus(row.startDate, row.endDate) } : null;
+ return row
+ ? {
+ projectId: row.projectId,
+ status: cycleStatus(row.startDate, row.endDate, row.completedAt),
+ }
+ : null;
}
// Used by the access check on routes that address a cycle by its own id.
@@ -163,7 +196,7 @@ async function assertRange(
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}`,
+ sql`${cycle.startDate} <= ${endDate} and ${OCCUPIED_UNTIL} >= ${startDate}`,
];
if (excludeId !== undefined) conds.push(ne(cycle.id, excludeId));
const rows = await db
@@ -223,7 +256,11 @@ export async function updateCycle(id: number, patch: CyclePatch): Promise<CycleR
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);
+ assertDatesMovable(
+ cycleStatus(before.startDate, before.endDate, before.completedAt),
+ movesStart,
+ movesEnd,
+ );
if (movesStart || movesEnd) {
await assertRange(
before.projectId,
@@ -239,7 +276,7 @@ export async function updateCycle(id: number, patch: CyclePatch): Promise<CycleR
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;
+ set.updatedAt = NOW;
await db.update(cycle).set(set).where(eq(cycle.id, id));
}
return getCycle(id);
@@ -249,3 +286,59 @@ export async function updateCycle(id: number, patch: CyclePatch): Promise<CycleR
export async function deleteCycle(id: number): Promise<void> {
await db.delete(cycle).where(eq(cycle.id, id));
}
+
+// The cycle a finish acts on. Only a running one can be finished: an upcoming cycle
+// has nothing to close, and a finished one stays finished — there is no way to
+// reopen it.
+async function loadRunning(id: number): Promise<typeof cycle.$inferSelect | null> {
+ const [row] = await db.select().from(cycle).where(eq(cycle.id, id));
+ if (!row) return null;
+ if (cycleStatus(row.startDate, row.endDate, row.completedAt) !== 'active')
+ throw new HttpError(400, 'Only a running cycle can be finished');
+ return row;
+}
+
+// Marks a cycle as finished from now on, leaving its dates and its issues alone.
+async function markFinished(id: number): Promise<void> {
+ await db.update(cycle).set({ completedAt: NOW, updatedAt: NOW }).where(eq(cycle.id, id));
+}
+
+// Finishes a running cycle before its planned end date. The issues keep their
+// cycle_id, so the cycle keeps recording what it held; the transfer route moves the
+// unfinished ones out afterwards. Returns null if the cycle does not exist, which
+// the route maps to a 404.
+export async function finishCycle(id: number): Promise<CycleRow | null> {
+ const running = await loadRunning(id);
+ if (!running) return null;
+ await markFinished(id);
+ return getCycle(id);
+}
+
+// Finishes the running cycle and moves the project's next upcoming cycle to start
+// today; the caller carries the unfinished issues over. The started cycle keeps its
+// planned end date, so starting it early makes it longer. Returns null if the cycle
+// does not exist.
+export async function startNextCycle(id: number): Promise<CycleRow | null> {
+ const running = await loadRunning(id);
+ if (!running) return null;
+ const [next] = await db
+ .select({ id: cycle.id })
+ .from(cycle)
+ .where(
+ and(
+ eq(cycle.projectId, running.projectId),
+ isNull(cycle.completedAt),
+ sql`${cycle.startDate} > ${TODAY}`,
+ ),
+ )
+ .orderBy(asc(cycle.startDate), asc(cycle.id))
+ .limit(1);
+ if (!next) throw new HttpError(400, 'The project has no upcoming cycle to start');
+
+ await markFinished(id);
+ await db
+ .update(cycle)
+ .set({ startDate: TODAY as unknown as string, updatedAt: NOW })
+ .where(eq(cycle.id, next.id));
+ return getCycle(next.id);
+}
diff --git a/apps/api/src/modules/issues/__tests__/integration/cycle-history.test.ts b/apps/api/src/modules/issues/__tests__/integration/cycle-history.test.ts
index 41ab8d50..73f124ea 100644
--- a/apps/api/src/modules/issues/__tests__/integration/cycle-history.test.ts
+++ b/apps/api/src/modules/issues/__tests__/integration/cycle-history.test.ts
@@ -185,6 +185,23 @@ describe('issue cycle history', () => {
}
});
+ it('counts a cycle the issue was still on when it was finished early', async () => {
+ const { asOwner, columnId } = await setup();
+ const { first, second } = await twoCycles(asOwner);
+ const carried = (await createIssue(asOwner, columnId, { cycleId: first.id })).data!;
+ const dropped = (await createIssue(asOwner, columnId, { cycleId: first.id })).data!;
+ await asOwner.issues({ issueId: dropped.id }).patch({ cycleId: null });
+
+ await asOwner.cycles({ cycleId: first.id }).finish.post();
+ await asOwner.issues({ issueId: carried.id }).patch({ cycleId: second.id });
+
+ expect((await history(asOwner, carried.id)).data!.map((e) => e.name)).toEqual([
+ 'Sprint 1',
+ 'Sprint 2',
+ ]);
+ expect((await history(asOwner, dropped.id)).data).toEqual([]);
+ });
+
it('drops a deleted cycle from the history', async () => {
const { asOwner, columnId } = await setup();
const { first, second } = await twoCycles(asOwner);
diff --git a/apps/api/src/modules/issues/cycle-history.ts b/apps/api/src/modules/issues/cycle-history.ts
index 3156b32d..670fed9e 100644
--- a/apps/api/src/modules/issues/cycle-history.ts
+++ b/apps/api/src/modules/issues/cycle-history.ts
@@ -58,6 +58,7 @@ export async function listIssueCycles(issueId: number): Promise<IssueCycleRow[]>
name: cycle.name,
startDate: cycle.startDate,
endDate: cycle.endDate,
+ completedAt: cycle.completedAt,
enteredAt: issueCycle.enteredAt,
leftAt: issueCycle.leftAt,
})
@@ -67,10 +68,11 @@ export async function listIssueCycles(issueId: number): Promise<IssueCycleRow[]>
and(
eq(issueCycle.issueId, issueId),
// Compared in UTC, the zone a cycle's dates are read in everywhere else. A
- // cycle covers its end date, so it ends the day after.
+ // cycle covers its end date, so it ends the day after — unless it was
+ // finished early, which ended it at that moment.
or(
isNull(issueCycle.leftAt),
- sql`${issueCycle.leftAt} at time zone 'utc' >= ${cycle.endDate} + interval '1 day'`,
+ sql`${issueCycle.leftAt} >= coalesce(${cycle.completedAt}, (${cycle.endDate} + interval '1 day') at time zone 'utc')`,
),
),
)
@@ -89,7 +91,7 @@ export async function listIssueCycles(issueId: number): Promise<IssueCycleRow[]>
name: r.name,
startDate: r.startDate,
endDate: r.endDate,
- status: cycleStatus(r.startDate, r.endDate),
+ status: cycleStatus(r.startDate, r.endDate, r.completedAt),
enteredAt: iso(r.enteredAt),
leftAt: r.leftAt ? iso(r.leftAt) : null,
});
diff --git a/apps/api/src/modules/issues/service.ts b/apps/api/src/modules/issues/service.ts
index 70aa7a00..499c1f47 100644
--- a/apps/api/src/modules/issues/service.ts
+++ b/apps/api/src/modules/issues/service.ts
@@ -483,6 +483,7 @@ async function attachGroupings(issues: IssueRow[]): Promise<void> {
cycleName: cycle.name,
cycleStart: cycle.startDate,
cycleEnd: cycle.endDate,
+ cycleCompletedAt: cycle.completedAt,
})
.from(issue)
.leftJoin(initiative, eq(initiative.id, issue.initiativeId))
@@ -508,7 +509,7 @@ async function attachGroupings(issues: IssueRow[]): Promise<void> {
? {
id: r.cycleId,
name: r.cycleName!,
- status: cycleStatus(r.cycleStart!, r.cycleEnd!),
+ status: cycleStatus(r.cycleStart!, r.cycleEnd!, r.cycleCompletedAt),
}
: null;
}
diff --git a/apps/web/messages/ar/cycles.json b/apps/web/messages/ar/cycles.json
index d46e2629..c1c4fca5 100644
--- a/apps/web/messages/ar/cycles.json
+++ b/apps/web/messages/ar/cycles.json
@@ -22,7 +22,8 @@
"nothingPlannedTitle": "لا شيء مخطَّط",
"nothingPlannedDescription": "الخط الزمني بيعرض الدورات الشغالة والجاية. اللي خلصت تلاقيها في الجدول.",
"options": "خيارات الدورة",
- "transferIssues": "نقل المهام غير المنتهية",
+ "transferIssues": "{count, plural, one {نقل مهمة واحدة غير منتهية} two {نقل مهمتين غير منتهيين} few {نقل # مهام غير منتهية} many {نقل # مهمة غير منتهية} other {نقل # مهمة غير منتهية}}",
+ "finishedEarly": "اتقفلت بدري، وكانت مخططة تنتهي {date}",
"form": {
"editTitle": "تعديل الدورة",
"newTitle": "دورة جديدة",
@@ -38,7 +39,7 @@
"weeks": "{count, plural, zero {مفيش أسابيع} one {أسبوع واحد} two {أسبوعين} few {# أسابيع} many {# أسبوع} other {# أسبوع}}",
"transfer": {
"title": "نقل المهام غير المنتهية",
- "description": "المهام اللي لسه مخلصتش أو مش ملغية هتتنقل للدورة اللي تختارها. والباقي هيفضل مكانه.",
+ "description": "المهام غير المنتهية هتتنقل للدورة اللي تختارها. المنتهية والملغية هتفضل هنا.",
"moveTo": "النقل إلى",
"noCycle": "بلا دورة",
"submit": "نقل المهام",
@@ -46,6 +47,23 @@
"moved": "{count, plural, zero {مفيش مهام اتنقلت} one {مهمة واحدة اتنقلت} two {مهمتين اتنقلوا} few {# مهام اتنقلت} many {# مهمة اتنقلت} other {# مهمة اتنقلت}}",
"failed": "تعذّر نقل المهام"
},
+ "finish": {
+ "action": "إنهاء الدورة",
+ "title": "إنهاء الدورة بدري",
+ "description": "{cycle} هتتقفل النهارده بدل {date}، ومش هينفع ترجّعها. {count, plural, zero {مفيش مهام غير منتهية.} one {مهمة واحدة غير منتهية هتفضل فيها.} two {مهمتين غير منتهيين هيفضلوا فيها.} few {# مهام غير منتهية هتفضل فيها.} many {# مهمة غير منتهية هتفضل فيها.} other {# مهمة غير منتهية هتفضل فيها.}}",
+ "submit": "إنهاء الدورة"
+ },
+ "startNext": {
+ "action": "ابدأ الدورة الجاية النهارده",
+ "title": "ابدأ الدورة الجاية النهارده",
+ "description": "{cycle} هتتقفل النهارده ومش هينفع ترجّعها. {next} هتبدأ النهارده وهتفضل تنتهي {date}. {count, plural, zero {مفيش حاجة تتنقل.} one {مهمة واحدة غير منتهية هتتنقل ليها.} two {مهمتين غير منتهيين هيتنقلوا ليها.} few {# مهام غير منتهية هتتنقل ليها.} many {# مهمة غير منتهية هتتنقل ليها.} other {# مهمة غير منتهية هتتنقل ليها.}} المهام المنتهية والملغية هتفضل في {cycle}.",
+ "submit": "ابدأ الدورة",
+ "started": "بدأت {cycle}. {count, plural, zero {مفيش مهام اتنقلت.} one {اتنقلت مهمة واحدة.} two {اتنقلت مهمتين.} few {اتنقلت # مهام.} many {اتنقلت # مهمة.} other {اتنقلت # مهمة.}}"
+ },
+ "delete": {
+ "title": "حذف الدورة",
+ "description": "{cycle} هتتمسح خالص. {count, plural, zero {مفيش مهام فيها.} one {مهمة واحدة هتفضل في المشروع من غير دورة.} two {مهمتين هيفضلوا في المشروع من غير دورة.} few {# مهام هتفضل في المشروع من غير دورة.} many {# مهمة هتفضل في المشروع من غير دورة.} other {# مهمة هتفضل في المشروع من غير دورة.}}"
+ },
"details": "تفاصيل الدورة",
"goal": "الهدف",
"noGoal": "لم يُحدَّد هدف.",
diff --git a/apps/web/messages/en/cycles.json b/apps/web/messages/en/cycles.json
index e53db30e..eba94bd9 100644
--- a/apps/web/messages/en/cycles.json
+++ b/apps/web/messages/en/cycles.json
@@ -22,7 +22,8 @@
"nothingPlannedTitle": "Nothing planned",
"nothingPlannedDescription": "The timeline shows active and upcoming cycles. Finished ones are in the table.",
"options": "Cycle options",
- "transferIssues": "Transfer unfinished issues",
+ "transferIssues": "{count, plural, one {Move # unfinished issue} other {Move # unfinished issues}}",
+ "finishedEarly": "Finished early, planned to end {date}",
"form": {
"editTitle": "Edit cycle",
"newTitle": "New cycle",
@@ -37,8 +38,8 @@
},
"weeks": "{count, plural, one {# week} other {# weeks}}",
"transfer": {
- "title": "Transfer unfinished issues",
- "description": "Issues that are not completed or canceled move to the cycle you pick. The rest stay here.",
+ "title": "Move unfinished issues",
+ "description": "Unfinished issues move to the cycle you pick. Finished and canceled ones stay here.",
"moveTo": "Move to",
"noCycle": "No cycle",
"submit": "Move issues",
@@ -46,6 +47,23 @@
"moved": "{count, plural, one {# issue moved} other {# issues moved}}",
"failed": "Could not move the issues"
},
+ "finish": {
+ "action": "Finish cycle",
+ "title": "Finish cycle early",
+ "description": "{cycle} closes today instead of {date}. You can't reopen it. {count, plural, =0 {Nothing is left unfinished.} one {# unfinished issue stays on it.} other {# unfinished issues stay on it.}}",
+ "submit": "Finish cycle"
+ },
+ "startNext": {
+ "action": "Start next cycle today",
+ "title": "Start the next cycle today",
+ "description": "{cycle} closes today and you can't reopen it. {next} starts today and still ends on {date}. {count, plural, =0 {Nothing carries over.} one {# unfinished issue moves to it.} other {# unfinished issues move to it.}} Finished and canceled issues stay on {cycle}.",
+ "submit": "Start next cycle",
+ "started": "{cycle} started. {count, plural, =0 {No issues carried over.} one {# issue carried over.} other {# issues carried over.}}"
+ },
+ "delete": {
+ "title": "Delete cycle",
+ "description": "{cycle} is deleted for good. {count, plural, =0 {It holds no issues.} one {# issue stays in the project, without a cycle.} other {# issues stay in the project, without a cycle.}}"
+ },
"details": "Cycle details",
"goal": "Goal",
"noGoal": "No goal set.",
diff --git a/apps/web/messages/ru/cycles.json b/apps/web/messages/ru/cycles.json
index f45de36c..b15cff88 100644
--- a/apps/web/messages/ru/cycles.json
+++ b/apps/web/messages/ru/cycles.json
@@ -22,7 +22,8 @@
"nothingPlannedTitle": "Ничего не запланировано",
"nothingPlannedDescription": "Таймлайн показывает активные и предстоящие циклы. Завершённые — в таблице.",
"options": "Действия цикла",
- "transferIssues": "Перенести незавершённые задачи",
+ "transferIssues": "{count, plural, one {Перенести # незавершённую задачу} few {Перенести # незавершённые задачи} many {Перенести # незавершённых задач} other {Перенести # незавершённой задачи}}",
+ "finishedEarly": "Завершён досрочно, по плану до {date}",
"form": {
"editTitle": "Редактировать цикл",
"newTitle": "Новый цикл",
@@ -38,7 +39,7 @@
"weeks": "{count, plural, one {# неделя} few {# недели} many {# недель} other {# недели}}",
"transfer": {
"title": "Перенести незавершённые задачи",
- "description": "Задачи, которые не завершены и не отменены, перейдут в выбранный цикл. Остальные останутся здесь.",
+ "description": "Незавершённые задачи перейдут в выбранный цикл. Завершённые и отменённые останутся здесь.",
"moveTo": "Перенести в",
"noCycle": "Без цикла",
"submit": "Перенести задачи",
@@ -46,6 +47,23 @@
"moved": "Перенесено {count, plural, one {# задача} few {# задачи} many {# задач} other {# задачи}}",
"failed": "Не удалось перенести задачи"
},
+ "finish": {
+ "action": "Завершить цикл",
+ "title": "Завершить цикл досрочно",
+ "description": "{cycle} закроется сегодня, а не {date}. Открыть его заново нельзя. {count, plural, =0 {Незавершённых задач нет.} one {# незавершённая задача останется в нём.} few {# незавершённые задачи останутся в нём.} many {# незавершённых задач останутся в нём.} other {# незавершённой задачи останутся в нём.}}",
+ "submit": "Завершить цикл"
+ },
+ "startNext": {
+ "action": "Начать следующий цикл сегодня",
+ "title": "Начать следующий цикл сегодня",
+ "description": "{cycle} закроется сегодня, и открыть его заново нельзя. {next} начнётся сегодня и всё так же закончится {date}. {count, plural, =0 {Переносить нечего.} one {# незавершённая задача перейдёт в него.} few {# незавершённые задачи перейдут в него.} many {# незавершённых задач перейдут в него.} other {# незавершённой задачи перейдут в него.}} Завершённые и отменённые задачи останутся в цикле {cycle}.",
+ "submit": "Начать цикл",
+ "started": "{cycle} начат. {count, plural, =0 {Задачи не переносились.} one {Перенесена # задача.} few {Перенесено # задачи.} many {Перенесено # задач.} other {Перенесено # задачи.}}"
+ },
+ "delete": {
+ "title": "Удалить цикл",
+ "description": "{cycle} удалится безвозвратно. {count, plural, =0 {Задач в нём нет.} one {# задача останется в проекте, без цикла.} few {# задачи останутся в проекте, без цикла.} many {# задач останутся в проекте, без цикла.} other {# задачи останутся в проекте, без цикла.}}"
+ },
"details": "Детали цикла",
"goal": "Цель",
"noGoal": "Цель не задана.",
diff --git a/apps/web/messages/uk/cycles.json b/apps/web/messages/uk/cycles.json
index 5e110392..dc88d20b 100644
--- a/apps/web/messages/uk/cycles.json
+++ b/apps/web/messages/uk/cycles.json
@@ -22,7 +22,8 @@
"nothingPlannedTitle": "Нічого не заплановано",
"nothingPlannedDescription": "Таймлайн показує активні та майбутні цикли. Завершені — у таблиці.",
"options": "Дії циклу",
- "transferIssues": "Перенести незавершені задачі",
+ "transferIssues": "{count, plural, one {Перенести # незавершену задачу} few {Перенести # незавершені задачі} many {Перенести # незавершених задач} other {Перенести # незавершеної задачі}}",
+ "finishedEarly": "Завершено достроково, за планом до {date}",
"form": {
"editTitle": "Редагувати цикл",
"newTitle": "Новий цикл",
@@ -38,7 +39,7 @@
"weeks": "{count, plural, one {# тиждень} few {# тижні} many {# тижнів} other {# тижня}}",
"transfer": {
"title": "Перенести незавершені задачі",
- "description": "Задачі, які не завершені й не скасовані, перейдуть у вибраний цикл. Решта залишиться тут.",
+ "description": "Незавершені задачі перейдуть у вибраний цикл. Завершені та скасовані залишаться тут.",
"moveTo": "Перенести до",
"noCycle": "Без циклу",
"submit": "Перенести задачі",
@@ -46,6 +47,23 @@
"moved": "Перенесено {count, plural, one {# задачу} few {# задачі} many {# задач} other {# задачі}}",
"failed": "Не вдалося перенести задачі"
},
+ "finish": {
+ "action": "Завершити цикл",
+ "title": "Завершити цикл достроково",
+ "description": "{cycle} закриється сьогодні, а не {date}. Відкрити його знову не можна. {count, plural, =0 {Незавершених задач немає.} one {# незавершена задача залишиться в ньому.} few {# незавершені задачі залишаться в ньому.} many {# незавершених задач залишаться в ньому.} other {# незавершеної задачі залишаться в ньому.}}",
+ "submit": "Завершити цикл"
+ },
+ "startNext": {
+ "action": "Почати наступний цикл сьогодні",
+ "title": "Почати наступний цикл сьогодні",
+ "description": "{cycle} закриється сьогодні, і відкрити його знову не можна. {next} почнеться сьогодні й так само завершиться {date}. {count, plural, =0 {Переносити нічого.} one {# незавершена задача перейде до нього.} few {# незавершені задачі перейдуть до нього.} many {# незавершених задач перейдуть до нього.} other {# незавершеної задачі перейдуть до нього.}} Завершені та скасовані задачі залишаться в циклі {cycle}.",
+ "submit": "Почати цикл",
+ "started": "{cycle} розпочато. {count, plural, =0 {Задачі не переносилися.} one {Перенесено # задачу.} few {Перенесено # задачі.} many {Перенесено # задач.} other {Перенесено # задачі.}}"
+ },
+ "delete": {
+ "title": "Видалити цикл",
+ "description": "{cycle} видалиться безповоротно. {count, plural, =0 {Задач у ньому немає.} one {# задача залишиться в проєкті, без циклу.} few {# задачі залишаться в проєкті, без циклу.} many {# задач залишаться в проєкті, без циклу.} other {# задачі залишаться в проєкті, без циклу.}}"
+ },
"details": "Деталі циклу",
"goal": "Мета",
"noGoal": "Мету не задано.",
diff --git a/apps/web/messages/zh-CN/cycles.json b/apps/web/messages/zh-CN/cycles.json
index 13efb023..a5669e59 100644
--- a/apps/web/messages/zh-CN/cycles.json
+++ b/apps/web/messages/zh-CN/cycles.json
@@ -22,7 +22,8 @@
"nothingPlannedTitle": "暂无周期计划",
"nothingPlannedDescription": "时间线显示当前和即将开始的周期,已结束的周期显示在表格中。",
"options": "周期选项",
- "transferIssues": "转移未完成的工作项",
+ "transferIssues": "转移 {count} 个未完成的工作项",
+ "finishedEarly": "提前结束,原计划至 {date}",
"form": {
"editTitle": "编辑周期",
"newTitle": "新建周期",
@@ -38,7 +39,7 @@
"weeks": "{count, plural, other {# 周}}",
"transfer": {
"title": "转移未完成的工作项",
- "description": "未处于已完成或已取消状态的工作项会移至所选周期,其余工作项保留在此周期。",
+ "description": "未完成的工作项会移至所选周期,已完成和已取消的留在这里。",
"moveTo": "移至",
"noCycle": "不属于任何周期",
"submit": "移动工作项",
@@ -46,6 +47,23 @@
"moved": "{count, plural, other {已移动 # 个工作项}}",
"failed": "无法移动工作项"
},
+ "finish": {
+ "action": "结束周期",
+ "title": "提前结束周期",
+ "description": "{cycle} 将于今天结束,而不是 {date},且无法重新打开。{count, plural, =0 {没有未完成的工作项。} other {# 个未完成的工作项会留在这里。}}",
+ "submit": "结束周期"
+ },
+ "startNext": {
+ "action": "今天开始下一个周期",
+ "title": "今天开始下一个周期",
+ "description": "{cycle} 将于今天结束,且无法重新打开。{next} 从今天开始,结束日期仍为 {date}。{count, plural, =0 {没有需要转移的工作项。} other {# 个未完成的工作项会转移过去。}}已完成和已取消的工作项留在 {cycle}。",
+ "submit": "开始周期",
+ "started": "{cycle} 已开始。{count, plural, =0 {没有转移工作项。} other {已转移 # 个工作项。}}"
+ },
+ "delete": {
+ "title": "删除周期",
+ "description": "{cycle} 将被永久删除。{count, plural, =0 {里面没有工作项。} other {# 个工作项会留在项目中,不属于任何周期。}}"
+ },
"details": "周期详情",
"goal": "目标",
"noGoal": "未设置目标。",
diff --git a/apps/web/src/features/cycles/components/CycleActions.tsx b/apps/web/src/features/cycles/components/CycleActions.tsx
index 42adc83d..e857d77b 100644
--- a/apps/web/src/features/cycles/components/CycleActions.tsx
+++ b/apps/web/src/features/cycles/components/CycleActions.tsx
@@ -2,11 +2,19 @@
import { useState } from 'react';
import { useRouter } from 'next/navigation';
-import { ArrowRightLeft, MoreHorizontal, Pencil, Trash2 } from 'lucide-react';
+import {
+ ArrowRightLeft,
+ CircleCheck,
+ MoreHorizontal,
+ Pencil,
+ SkipForward,
+ Trash2,
+} from 'lucide-react';
import { useTranslations } from 'next-intl';
import type { Cycle } from '@/lib/api';
import { cyclesPath } from '@/utils/paths';
import { usePermissions } from '@/hooks/usePermissions';
+import { unfinishedCount } from '@/utils/progress';
import {
DropdownMenu,
DropdownMenuContent,
@@ -14,29 +22,46 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
-import { useDeleteCycle } from '@/services/cycles.service';
+import { usePlannedCyclesQuery } from '@/services/cycles.service';
import CycleFormDialog from './CycleFormDialog';
-import TransferIssuesDialog from './TransferIssuesDialog';
+import DeleteCycleDialog from './DeleteCycleDialog';
+import FinishCycleDialog from './FinishCycleDialog';
+import StartNextCycleDialog from './StartNextCycleDialog';
// 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 }) {
+// deleted cycle stay, without one. Finishing a running cycle early and handing over
+// to the next one are offered only while it runs — both are final.
+//
+// The transfer dialog is the caller's to render: finishing a cycle moves it into
+// another group of the cycles list, which unmounts this menu along with anything it
+// was showing. `onTransfer` asks for the dialog, both from the menu item and once a
+// finish leaves unfinished issues behind.
+export default function CycleActions({
+ cycle,
+ projectKey,
+ onTransfer,
+}: {
+ cycle: Cycle;
+ projectKey: string;
+ onTransfer: (cycle: Cycle) => void;
+}) {
const t = useTranslations('cycles');
const tCommon = useTranslations('common');
const { can } = usePermissions();
- const del = useDeleteCycle(projectKey);
const router = useRouter();
const [editing, setEditing] = useState(false);
- const [transferring, setTransferring] = useState(false);
+ const [finishing, setFinishing] = useState(false);
+ const [startingNext, setStartingNext] = useState(false);
+ const [deleting, setDeleting] = useState(false);
+ // The planned list is ordered by start date, so the first upcoming cycle is the
+ // one "start next cycle today" hands over to.
+ const next = (usePlannedCyclesQuery(projectKey).data ?? []).find((c) => c.status === 'upcoming');
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));
- };
+ const running = cycle.status === 'active';
+ const unfinished = unfinishedCount(cycle.progress);
return (
<>
@@ -57,18 +82,38 @@ export default function CycleActions({ cycle, projectKey }: { cycle: Cycle; proj
{tCommon('edit')}
</DropdownMenuItem>
)}
- {canEdit && (
- <DropdownMenuItem onClick={() => setTransferring(true)}>
- <ArrowRightLeft className="size-4" />
- {t('transferIssues')}
- </DropdownMenuItem>
+ {canEdit && unfinished > 0 && (
+ <>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem onClick={() => onTransfer(cycle)}>
+ <ArrowRightLeft className="size-4" />
+ {t('transferIssues', { count: unfinished })}
+ </DropdownMenuItem>
+ </>
+ )}
+ {canEdit && running && (
+ <>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem onClick={() => setFinishing(true)}>
+ <CircleCheck className="size-4" />
+ {t('finish.action')}
+ </DropdownMenuItem>
+ {next && (
+ <DropdownMenuItem onClick={() => setStartingNext(true)}>
+ <SkipForward className="size-4" />
+ {t('startNext.action')}
+ </DropdownMenuItem>
+ )}
+ </>
)}
- {canEdit && canDelete && <DropdownMenuSeparator />}
{canDelete && (
- <DropdownMenuItem variant="destructive" onClick={() => void remove()}>
- <Trash2 className="size-4" />
- {tCommon('delete')}
- </DropdownMenuItem>
+ <>
+ {canEdit && <DropdownMenuSeparator />}
+ <DropdownMenuItem variant="destructive" onClick={() => setDeleting(true)}>
+ <Trash2 className="size-4" />
+ {tCommon('delete')}
+ </DropdownMenuItem>
+ </>
)}
</DropdownMenuContent>
</DropdownMenu>
@@ -76,11 +121,30 @@ export default function CycleActions({ cycle, projectKey }: { cycle: Cycle; proj
{editing && (
<CycleFormDialog cycle={cycle} projectKey={projectKey} onClose={() => setEditing(false)} />
)}
- {transferring && (
- <TransferIssuesDialog
+ {finishing && (
+ <FinishCycleDialog
+ cycle={cycle}
+ projectKey={projectKey}
+ onClose={() => setFinishing(false)}
+ onFinished={() => {
+ if (unfinished > 0) onTransfer(cycle);
+ }}
+ />
+ )}
+ {startingNext && next && (
+ <StartNextCycleDialog
+ cycle={cycle}
+ next={next}
+ projectKey={projectKey}
+ onClose={() => setStartingNext(false)}
+ />
+ )}
+ {deleting && (
+ <DeleteCycleDialog
cycle={cycle}
projectKey={projectKey}
- onClose={() => setTransferring(false)}
+ onClose={() => setDeleting(false)}
+ onDeleted={() => router.push(cyclesPath(projectKey))}
/>
)}
</>
diff --git a/apps/web/src/features/cycles/components/CycleRange.tsx b/apps/web/src/features/cycles/components/CycleRange.tsx
new file mode 100644
index 00000000..c7981ad0
--- /dev/null
+++ b/apps/web/src/features/cycles/components/CycleRange.tsx
@@ -0,0 +1,16 @@
+import { useTranslations } from 'next-intl';
+import type { Cycle } from '@/lib/api';
+import { formatShortDate } from '@/utils/dates';
+
+// The days a cycle ran. One that was finished before its planned end date ended on
+// the day it was finished, so the range shows that day and names the planned one.
+export default function CycleRange({ cycle }: { cycle: Cycle }) {
+ const t = useTranslations('cycles');
+
+ return (
+ <>
+ {formatShortDate(cycle.startDate)} – {formatShortDate(cycle.completedAt ?? cycle.endDate)}
+ {cycle.completedAt && ` · ${t('finishedEarly', { date: formatShortDate(cycle.endDate) })}`}
+ </>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/DeleteCycleDialog.tsx b/apps/web/src/features/cycles/components/DeleteCycleDialog.tsx
new file mode 100644
index 00000000..79ea872a
--- /dev/null
+++ b/apps/web/src/features/cycles/components/DeleteCycleDialog.tsx
@@ -0,0 +1,39 @@
+import { useTranslations } from 'next-intl';
+import type { Cycle } from '@/lib/api';
+import { useDeleteCycle } from '@/services/cycles.service';
+import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';
+
+// Confirm deleting a cycle. The issues it holds are not deleted with it — they stay
+// in the project without a cycle.
+export default function DeleteCycleDialog({
+ cycle,
+ projectKey,
+ onClose,
+ onDeleted,
+}: {
+ cycle: Cycle;
+ projectKey: string;
+ onClose: () => void;
+ onDeleted: () => void;
+}) {
+ const t = useTranslations('cycles.delete');
+ const tCommon = useTranslations('common');
+ const del = useDeleteCycle(projectKey);
+
+ return (
+ <ConfirmDialog
+ title={t('title')}
+ confirmLabel={tCommon('delete')}
+ onConfirm={async () => {
+ await del.mutateAsync(cycle.id);
+ onClose();
+ onDeleted();
+ }}
+ onClose={onClose}
+ >
+ <p className="text-sm text-muted-foreground">
+ {t('description', { cycle: cycle.name, count: cycle.progress.total })}
+ </p>
+ </ConfirmDialog>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/FinishCycleDialog.tsx b/apps/web/src/features/cycles/components/FinishCycleDialog.tsx
new file mode 100644
index 00000000..11f5f837
--- /dev/null
+++ b/apps/web/src/features/cycles/components/FinishCycleDialog.tsx
@@ -0,0 +1,44 @@
+import { useTranslations } from 'next-intl';
+import type { Cycle } from '@/lib/api';
+import { formatShortDate } from '@/utils/dates';
+import { unfinishedCount } from '@/utils/progress';
+import { useFinishCycle } from '@/services/cycles.service';
+import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';
+
+// Confirm closing a running cycle ahead of its planned end date. The issues stay on
+// it, so the caller offers the transfer dialog once this one is through.
+export default function FinishCycleDialog({
+ cycle,
+ projectKey,
+ onClose,
+ onFinished,
+}: {
+ cycle: Cycle;
+ projectKey: string;
+ onClose: () => void;
+ onFinished: () => void;
+}) {
+ const t = useTranslations('cycles.finish');
+ const finish = useFinishCycle(projectKey);
+
+ return (
+ <ConfirmDialog
+ title={t('title')}
+ confirmLabel={t('submit')}
+ onConfirm={async () => {
+ await finish.mutateAsync(cycle.id);
+ onClose();
+ onFinished();
+ }}
+ onClose={onClose}
+ >
+ <p className="text-sm text-muted-foreground">
+ {t('description', {
+ cycle: cycle.name,
+ date: formatShortDate(cycle.endDate),
+ count: unfinishedCount(cycle.progress),
+ })}
+ </p>
+ </ConfirmDialog>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/StartNextCycleDialog.tsx b/apps/web/src/features/cycles/components/StartNextCycleDialog.tsx
new file mode 100644
index 00000000..e9e7d978
--- /dev/null
+++ b/apps/web/src/features/cycles/components/StartNextCycleDialog.tsx
@@ -0,0 +1,46 @@
+import { toast } from 'sonner';
+import { useTranslations } from 'next-intl';
+import type { Cycle } from '@/lib/api';
+import { formatShortDate } from '@/utils/dates';
+import { unfinishedCount } from '@/utils/progress';
+import { useStartNextCycle } from '@/services/cycles.service';
+import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';
+
+// Confirm finishing the running cycle and starting the next one today. The unfinished
+// issues come along; the next cycle keeps its planned end date, so it runs longer.
+export default function StartNextCycleDialog({
+ cycle,
+ next,
+ projectKey,
+ onClose,
+}: {
+ cycle: Cycle;
+ next: Cycle;
+ projectKey: string;
+ onClose: () => void;
+}) {
+ const t = useTranslations('cycles.startNext');
+ const startNext = useStartNextCycle(projectKey);
+
+ return (
+ <ConfirmDialog
+ title={t('title')}
+ confirmLabel={t('submit')}
+ onConfirm={async () => {
+ const { moved } = await startNext.mutateAsync(cycle.id);
+ toast.success(t('started', { cycle: next.name, count: moved }));
+ onClose();
+ }}
+ onClose={onClose}
+ >
+ <p className="text-sm text-muted-foreground">
+ {t('description', {
+ cycle: cycle.name,
+ next: next.name,
+ date: formatShortDate(next.endDate),
+ count: unfinishedCount(cycle.progress),
+ })}
+ </p>
+ </ConfirmDialog>
+ );
+}
diff --git a/apps/web/src/features/cycles/components/detail/CycleHeader.tsx b/apps/web/src/features/cycles/components/detail/CycleHeader.tsx
index bff31bb0..bdb66cef 100644
--- a/apps/web/src/features/cycles/components/detail/CycleHeader.tsx
+++ b/apps/web/src/features/cycles/components/detail/CycleHeader.tsx
@@ -1,18 +1,22 @@
'use client';
+import { useState } from 'react';
import { useTranslations } from 'next-intl';
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';
+import CycleRange from '../CycleRange';
+import TransferIssuesDialog from '../TransferIssuesDialog';
// 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.
+// much of it is done. Editing happens in the overflow menu dialog, and the transfer
+// dialog is held here, the way the cycles table holds it.
export default function CycleHeader({ cycle, projectKey }: { cycle: Cycle; projectKey: string }) {
const t = useTranslations('cycles');
const status = CYCLE_STATUS_META[cycle.status];
+ const [transferring, setTransferring] = useState(false);
return (
<div className="flex flex-wrap items-center justify-between gap-x-2 gap-y-1.5 border-b px-6 py-2.5">
@@ -23,7 +27,7 @@ export default function CycleHeader({ cycle, projectKey }: { cycle: Cycle; proje
{t(`status.${cycle.status}`)}
</span>
<span className="text-xs text-muted-foreground">
- {formatShortDate(cycle.startDate)} – {formatShortDate(cycle.endDate)}
+ <CycleRange cycle={cycle} />
</span>
{cycle.goal && (
<span className="max-w-md truncate text-xs text-muted-foreground">{cycle.goal}</span>
@@ -31,8 +35,20 @@ export default function CycleHeader({ cycle, projectKey }: { cycle: Cycle; proje
</div>
<div className="flex items-center gap-3">
<ProgressBar progress={cycle.progress} />
- <CycleActions cycle={cycle} projectKey={projectKey} />
+ <CycleActions
+ cycle={cycle}
+ projectKey={projectKey}
+ onTransfer={() => setTransferring(true)}
+ />
</div>
+
+ {transferring && (
+ <TransferIssuesDialog
+ cycle={cycle}
+ projectKey={projectKey}
+ onClose={() => setTransferring(false)}
+ />
+ )}
</div>
);
}
diff --git a/apps/web/src/features/cycles/components/list/CycleInfoPopover.tsx b/apps/web/src/features/cycles/components/list/CycleInfoPopover.tsx
index d7f4f17d..77bcfb56 100644
--- a/apps/web/src/features/cycles/components/list/CycleInfoPopover.tsx
+++ b/apps/web/src/features/cycles/components/list/CycleInfoPopover.tsx
@@ -4,12 +4,12 @@ import Link from 'next/link';
import { useTranslations } from 'next-intl';
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 CycleRange from '../CycleRange';
import { cycleLength } from '../../utils/cycleDates';
// The cycle's name in the timeline's label column, opening what does not fit on the
@@ -49,8 +49,7 @@ export default function CycleInfoPopover({
</span>
</div>
<p className="text-xs text-muted-foreground">
- {formatShortDate(cycle.startDate)} – {formatShortDate(cycle.endDate)} ·{' '}
- {cycleLength(cycle)}d
+ <CycleRange cycle={cycle} /> · {cycleLength(cycle)}d
</p>
</div>
diff --git a/apps/web/src/features/cycles/components/list/CycleTableArchive.tsx b/apps/web/src/features/cycles/components/list/CycleTableArchive.tsx
index 917d5f29..68c1aae9 100644
--- a/apps/web/src/features/cycles/components/list/CycleTableArchive.tsx
+++ b/apps/web/src/features/cycles/components/list/CycleTableArchive.tsx
@@ -2,6 +2,7 @@
import { useState } from 'react';
import { useTranslations } from 'next-intl';
+import type { Cycle } from '@/lib/api';
import ShowMoreButton from '@/components/common/ShowMoreButton';
import { CYCLE_STATUS_META } from '@/utils/cycleMeta';
import type { CompletedCycles } from '../../hooks/useCompletedCycles';
@@ -17,10 +18,12 @@ export default function CycleTableArchive({
completed,
projectKey,
gridTemplate,
+ onTransfer,
}: {
completed: CompletedCycles;
projectKey: string;
gridTemplate: string;
+ onTransfer: (cycle: Cycle) => void;
}) {
const t = useTranslations('cycles');
const [collapsed, setCollapsed] = useState(true);
@@ -43,6 +46,7 @@ export default function CycleTableArchive({
cycle={cycle}
projectKey={projectKey}
gridTemplate={gridTemplate}
+ onTransfer={onTransfer}
/>
))}
{completed.hasMore && (
diff --git a/apps/web/src/features/cycles/components/list/CycleTableRow.tsx b/apps/web/src/features/cycles/components/list/CycleTableRow.tsx
index dbe07a67..4ba9bed1 100644
--- a/apps/web/src/features/cycles/components/list/CycleTableRow.tsx
+++ b/apps/web/src/features/cycles/components/list/CycleTableRow.tsx
@@ -2,9 +2,9 @@ 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 CycleRange from '../CycleRange';
import { cycleLength, daysLeft } from '../../utils/cycleDates';
// One cycle as a table row. The whole row navigates to the cycle; the name is also
@@ -13,10 +13,12 @@ export default function CycleTableRow({
cycle,
projectKey,
gridTemplate,
+ onTransfer,
}: {
cycle: Cycle;
projectKey: string;
gridTemplate: string;
+ onTransfer: (cycle: Cycle) => void;
}) {
const router = useRouter();
const href = cyclePath(projectKey, cycle.id);
@@ -39,7 +41,7 @@ export default function CycleTableRow({
</div>
<span className="text-xs text-muted-foreground">
- {formatShortDate(cycle.startDate)} – {formatShortDate(cycle.endDate)}
+ <CycleRange cycle={cycle} />
{cycle.status === 'active' && ` · ${daysLeft(cycle)}d left`}
</span>
@@ -50,7 +52,7 @@ export default function CycleTableRow({
<ProgressBar progress={cycle.progress} />
<div onClick={(e) => e.stopPropagation()} className="flex justify-end">
- <CycleActions cycle={cycle} projectKey={projectKey} />
+ <CycleActions cycle={cycle} projectKey={projectKey} onTransfer={onTransfer} />
</div>
</div>
);
diff --git a/apps/web/src/features/cycles/components/list/CyclesTable.tsx b/apps/web/src/features/cycles/components/list/CyclesTable.tsx
index 941f571a..f2c24b09 100644
--- a/apps/web/src/features/cycles/components/list/CyclesTable.tsx
+++ b/apps/web/src/features/cycles/components/list/CyclesTable.tsx
@@ -1,11 +1,12 @@
'use client';
-import { Fragment } from 'react';
+import { Fragment, useState } from 'react';
import { useTranslations } from 'next-intl';
import type { Cycle } from '@/lib/api';
import { usePersistedSet } from '@/hooks/usePersistedSet';
import { groupCycles } from '../../utils/cycleGroups';
import type { CompletedCycles } from '../../hooks/useCompletedCycles';
+import TransferIssuesDialog from '../TransferIssuesDialog';
import CycleTableSection from './CycleTableSection';
import CycleTableRow from './CycleTableRow';
import CycleTableArchive from './CycleTableArchive';
@@ -17,6 +18,10 @@ 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.
+//
+// The transfer dialog is held here rather than in the row that asked for it: a cycle
+// finished from its menu moves to another group, and the row it was on is gone by
+// the time the dialog would open.
export default function CyclesTable({
cycles,
completed,
@@ -28,6 +33,7 @@ export default function CyclesTable({
}) {
const t = useTranslations('cycles');
const collapsed = usePersistedSet(`cycles-collapsed:${projectKey}`);
+ const [transferring, setTransferring] = useState<Cycle | null>(null);
return (
<div className="flex-1 overflow-auto">
@@ -62,6 +68,7 @@ export default function CyclesTable({
cycle={cycle}
projectKey={projectKey}
gridTemplate={GRID}
+ onTransfer={setTransferring}
/>
))}
</Fragment>
@@ -69,9 +76,22 @@ export default function CyclesTable({
})}
{completed.total > 0 && (
- <CycleTableArchive completed={completed} projectKey={projectKey} gridTemplate={GRID} />
+ <CycleTableArchive
+ completed={completed}
+ projectKey={projectKey}
+ gridTemplate={GRID}
+ onTransfer={setTransferring}
+ />
)}
</div>
+
+ {transferring && (
+ <TransferIssuesDialog
+ cycle={transferring}
+ projectKey={projectKey}
+ onClose={() => setTransferring(null)}
+ />
+ )}
</div>
);
}
diff --git a/apps/web/src/features/cycles/utils/cycleDefaults.ts b/apps/web/src/features/cycles/utils/cycleDefaults.ts
index 38256746..a5a60282 100644
--- a/apps/web/src/features/cycles/utils/cycleDefaults.ts
+++ b/apps/web/src/features/cycles/utils/cycleDefaults.ts
@@ -1,5 +1,6 @@
import type { Cycle } from '@/lib/api';
-import { addDays, daysBetween, parseDate, toDateStr } from '@/utils/dates';
+import { addDays, daysBetween, toDateStr } from '@/utils/dates';
+import { occupiedUntil } from './cycleRanges';
// The lengths offered as one click each, in days. Two weeks is what a new cycle
// opens with.
@@ -40,7 +41,8 @@ function nextMonday(from: Date): Date {
// mid-week.
export function cycleDefaults(cycles: Cycle[], fallbackName: (n: number) => string): CycleDefaults {
const today = new Date();
- const previousEnd = parseDate(cycles[cycles.length - 1]?.endDate ?? null);
+ const last = cycles[cycles.length - 1];
+ const previousEnd = last ? occupiedUntil(last) : null;
const start =
previousEnd && daysBetween(today, previousEnd) >= 0
? addDays(previousEnd, 1)
diff --git a/apps/web/src/features/cycles/utils/cycleRanges.ts b/apps/web/src/features/cycles/utils/cycleRanges.ts
index f67a154a..c8d6b4db 100644
--- a/apps/web/src/features/cycles/utils/cycleRanges.ts
+++ b/apps/web/src/features/cycles/utils/cycleRanges.ts
@@ -12,12 +12,21 @@ function others(cycles: Cycle[], editedId: number | undefined): Cycle[] {
return editedId === undefined ? cycles : cycles.filter((c) => c.id !== editedId);
}
+// The last day a cycle keeps another one out of, mirroring the API: one finished
+// early gave up the rest of its planned range, and shares the day it was finished
+// with whatever starts next. completedAt is a timestamp, and the API reads its day
+// in UTC, the zone the cycle dates themselves are compared in.
+export function occupiedUntil(cycle: Cycle): Date | null {
+ const finished = parseDate(cycle.completedAt?.slice(0, 10) ?? null);
+ return finished ? addDays(finished, -1) : parseDate(cycle.endDate);
+}
+
// 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 }] : [];
+ const to = occupiedUntil(c);
+ return from && to && to >= from ? [{ from, to }] : [];
});
}
diff --git a/apps/web/src/lib/api.ts b/apps/web/src/lib/api.ts
index 55f5af75..5c50d9e1 100644
--- a/apps/web/src/lib/api.ts
+++ b/apps/web/src/lib/api.ts
@@ -2006,7 +2006,8 @@ export interface InitiativeOption {
}
// 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.
+// today, unless the cycle was finished ahead of them; progress follows from the
+// linked issues' states.
export type CycleStatus = 'upcoming' | 'active' | 'completed';
// A cycle as a picker option, for planning an issue into one.
@@ -2030,6 +2031,9 @@ export interface Cycle {
goal: string;
startDate: string;
endDate: string;
+ // When the cycle was finished ahead of its planned end date, or null. endDate
+ // keeps the date it was planned to run until either way.
+ completedAt: string | null;
status: CycleStatus;
createdAt: string;
updatedAt: string;
@@ -2727,6 +2731,9 @@ export const api = {
method: 'POST',
body: JSON.stringify({ targetCycleId }),
}),
+ finishCycle: (id: number) => request<Cycle>(`/cycles/${id}/finish`, { method: 'POST' }),
+ startNextCycle: (id: number) =>
+ request<{ cycle: Cycle; moved: number }>(`/cycles/${id}/start-next`, { method: 'POST' }),
listViews: (projectKey: string) => request<View[]>(`/projects/${projectKey}/views`),
createView: (projectKey: string, input: NewViewInput) =>
diff --git a/apps/web/src/services/cycles.service.ts b/apps/web/src/services/cycles.service.ts
index d11299dc..1de7ed84 100644
--- a/apps/web/src/services/cycles.service.ts
+++ b/apps/web/src/services/cycles.service.ts
@@ -97,6 +97,27 @@ export function useDeleteCycle(projectKey: string) {
});
}
+// Finishing a cycle takes it out of the planned list and the pickers, and starting
+// the next one also moves issues between cycles.
+export function useFinishCycle(projectKey: string) {
+ const qc = useQueryClient();
+ return useMutation({
+ mutationFn: (id: number) => api.finishCycle(id),
+ onSuccess: () => invalidateCycles(qc, projectKey),
+ });
+}
+
+export function useStartNextCycle(projectKey: string) {
+ const qc = useQueryClient();
+ return useMutation({
+ mutationFn: (id: number) => api.startNextCycle(id),
+ onSuccess: () => {
+ invalidateCycles(qc, projectKey);
+ invalidateCycleIssues(qc, projectKey);
+ },
+ });
+}
+
export function useTransferCycleIssues(projectKey: string) {
const qc = useQueryClient();
return useMutation({
diff --git a/apps/web/src/utils/progress.ts b/apps/web/src/utils/progress.ts
index ffeb00b6..14920aa3 100644
--- a/apps/web/src/utils/progress.ts
+++ b/apps/web/src/utils/progress.ts
@@ -1,10 +1,16 @@
+// The issue counts a progress bar reads, as CycleProgress and InitiativeProgress
+// both carry them.
+type Progress = { completed: number; canceled: number; total: number };
+
// 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 {
+export function progressPercent(progress: Progress): number {
const denom = progress.total - progress.canceled;
return denom > 0 ? Math.round((progress.completed / denom) * 100) : 0;
}
+
+// The issues that are neither completed nor canceled — the ones a cycle transfer
+// moves and a cycle finish leaves behind.
+export function unfinishedCount(progress: Progress): number {
+ return progress.total - progress.completed - progress.canceled;
+}
diff --git a/packages/db/drizzle/0100_modern_sabretooth.sql b/packages/db/drizzle/0100_modern_sabretooth.sql
new file mode 100644
index 00000000..c9374bc5
--- /dev/null
+++ b/packages/db/drizzle/0100_modern_sabretooth.sql
@@ -0,0 +1 @@
+ALTER TABLE "cycle" ADD COLUMN "completed_at" timestamp with time zone;
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0100_snapshot.json b/packages/db/drizzle/meta/0100_snapshot.json
new file mode 100644
index 00000000..3003bcd7
--- /dev/null
+++ b/packages/db/drizzle/meta/0100_snapshot.json
@@ -0,0 +1,6869 @@
+{
+ "id": "4b03e395-b417-4c5a-ab55-3ba80a45a5e5",
+ "prevId": "1c0dbeab-4f85-4b52-a455-3fe3d061bb39",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "account_userId_idx": {
+ "name": "account_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.apikey": {
+ "name": "apikey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'default'"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start": {
+ "name": "start",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prefix": {
+ "name": "prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refill_interval": {
+ "name": "refill_interval",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refill_amount": {
+ "name": "refill_amount",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_refill_at": {
+ "name": "last_refill_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "rate_limit_enabled": {
+ "name": "rate_limit_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "rate_limit_time_window": {
+ "name": "rate_limit_time_window",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 1000
+ },
+ "rate_limit_max": {
+ "name": "rate_limit_max",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 100
+ },
+ "request_count": {
+ "name": "request_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "remaining": {
+ "name": "remaining",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_request": {
+ "name": "last_request",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "apikey_configId_idx": {
+ "name": "apikey_configId_idx",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_referenceId_idx": {
+ "name": "apikey_referenceId_idx",
+ "columns": [
+ {
+ "expression": "reference_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_key_idx": {
+ "name": "apikey_key_idx",
+ "columns": [
+ {
+ "expression": "key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.passkey": {
+ "name": "passkey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "public_key": {
+ "name": "public_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "counter": {
+ "name": "counter",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_type": {
+ "name": "device_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "backed_up": {
+ "name": "backed_up",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transports": {
+ "name": "transports",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "aaguid": {
+ "name": "aaguid",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "passkey_userId_idx": {
+ "name": "passkey_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "passkey_credentialID_idx": {
+ "name": "passkey_credentialID_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "passkey_user_id_user_id_fk": {
+ "name": "passkey_user_id_user_id_fk",
+ "tableFrom": "passkey",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "session_userId_idx": {
+ "name": "session_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "username": {
+ "name": "username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "display_username": {
+ "name": "display_username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'user'"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ },
+ "user_username_unique": {
+ "name": "user_username_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "username"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verification": {
+ "name": "verification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verification_identifier_idx": {
+ "name": "verification_identifier_idx",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_event": {
+ "name": "agent_chat_event",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_chat_event_message_idx": {
+ "name": "agent_chat_event_message_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_chat_event_message_id_agent_chat_message_id_fk": {
+ "name": "agent_chat_event_message_id_agent_chat_message_id_fk",
+ "tableFrom": "agent_chat_event",
+ "tableTo": "agent_chat_message",
+ "columnsFrom": [
+ "message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_message": {
+ "name": "agent_chat_message",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_chat_message_thread_idx": {
+ "name": "agent_chat_message_thread_idx",
+ "columns": [
+ {
+ "expression": "thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_chat_message_due_idx": {
+ "name": "agent_chat_message_due_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"agent_chat_message\".\"status\" IN ('pending', 'streaming')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_chat_message_thread_id_agent_chat_thread_id_fk": {
+ "name": "agent_chat_message_thread_id_agent_chat_thread_id_fk",
+ "tableFrom": "agent_chat_message",
+ "tableTo": "agent_chat_thread",
+ "columnsFrom": [
+ "thread_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_chat_message_agent_id_ai_agent_id_fk": {
+ "name": "agent_chat_message_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_chat_message",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_chat_message_role_check": {
+ "name": "agent_chat_message_role_check",
+ "value": "\"agent_chat_message\".\"role\" IN ('user', 'assistant')"
+ },
+ "agent_chat_message_status_check": {
+ "name": "agent_chat_message_status_check",
+ "value": "\"agent_chat_message\".\"status\" IN ('pending', 'streaming', 'success', 'failed', 'canceled')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_thread": {
+ "name": "agent_chat_thread",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_chat_thread_agent_user_idx": {
+ "name": "agent_chat_thread_agent_user_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_chat_thread_agent_id_ai_agent_id_fk": {
+ "name": "agent_chat_thread_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_chat_thread",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_chat_thread_user_id_user_id_fk": {
+ "name": "agent_chat_thread_user_id_user_id_fk",
+ "tableFrom": "agent_chat_thread",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_field_trigger": {
+ "name": "agent_field_trigger",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "delay_sec": {
+ "name": "delay_sec",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 120
+ }
+ },
+ "indexes": {
+ "agent_field_trigger_field_idx": {
+ "name": "agent_field_trigger_field_idx",
+ "columns": [
+ {
+ "expression": "field_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_field_trigger_agent_id_ai_agent_id_fk": {
+ "name": "agent_field_trigger_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_field_trigger",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_field_trigger_field_id_custom_field_id_fk": {
+ "name": "agent_field_trigger_field_id_custom_field_id_fk",
+ "tableFrom": "agent_field_trigger",
+ "tableTo": "custom_field",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_field_trigger_agent_id_field_id_pk": {
+ "name": "agent_field_trigger_agent_id_field_id_pk",
+ "columns": [
+ "agent_id",
+ "field_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_field_trigger_delay_check": {
+ "name": "agent_field_trigger_delay_check",
+ "value": "\"agent_field_trigger\".\"delay_sec\" >= 0 AND \"agent_field_trigger\".\"delay_sec\" <= 86400"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_run": {
+ "name": "agent_run",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "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', 'canceled')"
+ },
+ "agent_run_trigger_check": {
+ "name": "agent_run_trigger_check",
+ "value": "\"agent_run\".\"trigger\" IN ('mention', 'delegation', 'field', '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
+ },
+ "delegation_delay_sec": {
+ "name": "delegation_delay_sec",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 120
+ },
+ "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
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "runner_scope": {
+ "name": "runner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'project'"
+ },
+ "last_seen_at": {
+ "name": "last_seen_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": {
+ "ai_agent_project_username_uq": {
+ "name": "ai_agent_project_username_uq",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(\"username\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ai_agent_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"
+ },
+ "ai_agent_owner_user_id_user_id_fk": {
+ "name": "ai_agent_owner_user_id_user_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "ai_agent_user_id_unique": {
+ "name": "ai_agent_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "ai_agent_kind_check": {
+ "name": "ai_agent_kind_check",
+ "value": "\"ai_agent\".\"kind\" IN ('external', 'internal')"
+ },
+ "ai_agent_runner_scope_check": {
+ "name": "ai_agent_runner_scope_check",
+ "value": "\"ai_agent\".\"runner_scope\" IN ('owner', 'project')"
+ },
+ "ai_agent_delegation_delay_check": {
+ "name": "ai_agent_delegation_delay_check",
+ "value": "\"ai_agent\".\"delegation_delay_sec\" >= 0 AND \"ai_agent\".\"delegation_delay_sec\" <= 86400"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.app_secret": {
+ "name": "app_secret",
+ "schema": "",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "ciphertext": {
+ "name": "ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "iv": {
+ "name": "iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_tag": {
+ "name": "auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redacted": {
+ "name": "redacted",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.app_setting": {
+ "name": "app_setting",
+ "schema": "",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.custom_field": {
+ "name": "custom_field",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_type_id": {
+ "name": "issue_type_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_type": {
+ "name": "field_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "member_scope": {
+ "name": "member_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "show_in_body": {
+ "name": "show_in_body",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "custom_field_project_id_project_id_fk": {
+ "name": "custom_field_project_id_project_id_fk",
+ "tableFrom": "custom_field",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "custom_field_issue_type_id_issue_type_id_fk": {
+ "name": "custom_field_issue_type_id_issue_type_id_fk",
+ "tableFrom": "custom_field",
+ "tableTo": "issue_type",
+ "columnsFrom": [
+ "issue_type_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "custom_field_field_type_check": {
+ "name": "custom_field_field_type_check",
+ "value": "\"custom_field\".\"field_type\" IN ('text', 'markdown', 'url', 'number', 'boolean', 'date', 'datetime', 'datetime_range', 'select', 'multi_select', 'member')"
+ },
+ "custom_field_member_scope_check": {
+ "name": "custom_field_member_scope_check",
+ "value": "(\"custom_field\".\"field_type\" = 'member') = (\"custom_field\".\"member_scope\" IS NOT NULL) AND (\"custom_field\".\"member_scope\" IS NULL OR \"custom_field\".\"member_scope\" IN ('all', 'humans', 'agents'))"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.custom_field_option": {
+ "name": "custom_field_option",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#6b7280'"
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "custom_field_option_field_id_custom_field_id_fk": {
+ "name": "custom_field_option_field_id_custom_field_id_fk",
+ "tableFrom": "custom_field_option",
+ "tableTo": "custom_field",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "custom_field_option_field_id_value_unique": {
+ "name": "custom_field_option_field_id_value_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "field_id",
+ "value"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cycle": {
+ "name": "cycle",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "start_date": {
+ "name": "start_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "end_date": {
+ "name": "end_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "cycle_project_idx": {
+ "name": "cycle_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "start_date",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cycle_project_id_project_id_fk": {
+ "name": "cycle_project_id_project_id_fk",
+ "tableFrom": "cycle",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "cycle_dates_check": {
+ "name": "cycle_dates_check",
+ "value": "\"cycle\".\"end_date\" >= \"cycle\".\"start_date\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.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
+ },
+ "reply_to_id": {
+ "name": "reply_to_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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_reply_idx": {
+ "name": "issue_activity_reply_idx",
+ "columns": [
+ {
+ "expression": "reply_to_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_activity_initiative_idx": {
+ "name": "issue_activity_initiative_idx",
+ "columns": [
+ {
+ "expression": "initiative_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_activity_issue_id_issue_id_fk": {
+ "name": "issue_activity_issue_id_issue_id_fk",
+ "tableFrom": "issue_activity",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_activity_initiative_id_initiative_id_fk": {
+ "name": "issue_activity_initiative_id_initiative_id_fk",
+ "tableFrom": "issue_activity",
+ "tableTo": "initiative",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_activity_reply_to_id_issue_activity_id_fk": {
+ "name": "issue_activity_reply_to_id_issue_activity_id_fk",
+ "tableFrom": "issue_activity",
+ "tableTo": "issue_activity",
+ "columnsFrom": [
+ "reply_to_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_activity_actor_user_id_user_id_fk": {
+ "name": "issue_activity_actor_user_id_user_id_fk",
+ "tableFrom": "issue_activity",
+ "tableTo": "user",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "issue_activity_kind_check": {
+ "name": "issue_activity_kind_check",
+ "value": "\"issue_activity\".\"kind\" IN ('comment', 'activity')"
+ },
+ "issue_activity_owner_check": {
+ "name": "issue_activity_owner_check",
+ "value": "(\"issue_activity\".\"issue_id\" IS NOT NULL) <> (\"issue_activity\".\"initiative_id\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.issue_attachment": {
+ "name": "issue_attachment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content_type": {
+ "name": "content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_attachment_issue_idx": {
+ "name": "issue_attachment_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_attachment_issue_id_issue_id_fk": {
+ "name": "issue_attachment_issue_id_issue_id_fk",
+ "tableFrom": "issue_attachment",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_attachment_public_id_unique": {
+ "name": "issue_attachment_public_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "public_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_checklist": {
+ "name": "issue_checklist",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_checklist_issue_idx": {
+ "name": "issue_checklist_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_checklist_issue_id_issue_id_fk": {
+ "name": "issue_checklist_issue_id_issue_id_fk",
+ "tableFrom": "issue_checklist",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_checklist_item": {
+ "name": "issue_checklist_item",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "checklist_id": {
+ "name": "checklist_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "done": {
+ "name": "done",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_checklist_item_checklist_idx": {
+ "name": "issue_checklist_item_checklist_idx",
+ "columns": [
+ {
+ "expression": "checklist_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_checklist_item_checklist_id_issue_checklist_id_fk": {
+ "name": "issue_checklist_item_checklist_id_issue_checklist_id_fk",
+ "tableFrom": "issue_checklist_item",
+ "tableTo": "issue_checklist",
+ "columnsFrom": [
+ "checklist_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_cycle": {
+ "name": "issue_cycle",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cycle_id": {
+ "name": "cycle_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "entered_at": {
+ "name": "entered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "left_at": {
+ "name": "left_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "issue_cycle_issue_idx": {
+ "name": "issue_cycle_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "entered_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_cycle_cycle_idx": {
+ "name": "issue_cycle_cycle_idx",
+ "columns": [
+ {
+ "expression": "cycle_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_cycle_open_idx": {
+ "name": "issue_cycle_open_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "cycle_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"issue_cycle\".\"left_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_cycle_issue_id_issue_id_fk": {
+ "name": "issue_cycle_issue_id_issue_id_fk",
+ "tableFrom": "issue_cycle",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_cycle_cycle_id_cycle_id_fk": {
+ "name": "issue_cycle_cycle_id_cycle_id_fk",
+ "tableFrom": "issue_cycle",
+ "tableTo": "cycle",
+ "columnsFrom": [
+ "cycle_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_field_option": {
+ "name": "issue_field_option",
+ "schema": "",
+ "columns": {
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "option_id": {
+ "name": "option_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_field_option_issue_id_issue_id_fk": {
+ "name": "issue_field_option_issue_id_issue_id_fk",
+ "tableFrom": "issue_field_option",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_field_option_field_id_custom_field_id_fk": {
+ "name": "issue_field_option_field_id_custom_field_id_fk",
+ "tableFrom": "issue_field_option",
+ "tableTo": "custom_field",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_field_option_option_id_custom_field_option_id_fk": {
+ "name": "issue_field_option_option_id_custom_field_option_id_fk",
+ "tableFrom": "issue_field_option",
+ "tableTo": "custom_field_option",
+ "columnsFrom": [
+ "option_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "issue_field_option_issue_id_field_id_option_id_pk": {
+ "name": "issue_field_option_issue_id_field_id_option_id_pk",
+ "columns": [
+ "issue_id",
+ "field_id",
+ "option_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_field_value": {
+ "name": "issue_field_value",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value_text": {
+ "name": "value_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_number": {
+ "name": "value_number",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_bool": {
+ "name": "value_bool",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_date": {
+ "name": "value_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_datetime": {
+ "name": "value_datetime",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_datetime_end": {
+ "name": "value_datetime_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_user_id": {
+ "name": "value_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_field_value_issue_id_issue_id_fk": {
+ "name": "issue_field_value_issue_id_issue_id_fk",
+ "tableFrom": "issue_field_value",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_field_value_field_id_custom_field_id_fk": {
+ "name": "issue_field_value_field_id_custom_field_id_fk",
+ "tableFrom": "issue_field_value",
+ "tableTo": "custom_field",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_field_value_value_user_id_user_id_fk": {
+ "name": "issue_field_value_value_user_id_user_id_fk",
+ "tableFrom": "issue_field_value",
+ "tableTo": "user",
+ "columnsFrom": [
+ "value_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_field_value_issue_id_field_id_unique": {
+ "name": "issue_field_value_issue_id_field_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "issue_id",
+ "field_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_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
+ },
+ "subtasks_enabled": {
+ "name": "subtasks_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "checklists_enabled": {
+ "name": "checklists_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "issue_stats_enabled": {
+ "name": "issue_stats_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "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
+ },
+ "wip_limit": {
+ "name": "wip_limit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wip_mode": {
+ "name": "wip_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'soft'"
+ },
+ "auto_assign_user_id": {
+ "name": "auto_assign_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_column_project_id_project_id_fk": {
+ "name": "project_column_project_id_project_id_fk",
+ "tableFrom": "project_column",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_column_auto_assign_user_id_user_id_fk": {
+ "name": "project_column_auto_assign_user_id_user_id_fk",
+ "tableFrom": "project_column",
+ "tableTo": "user",
+ "columnsFrom": [
+ "auto_assign_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_column_project_id_position_unique": {
+ "name": "project_column_project_id_position_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "position"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "project_column_state_type_check": {
+ "name": "project_column_state_type_check",
+ "value": "\"project_column\".\"state_type\" IN ('backlog', 'unstarted', 'started', 'completed', 'canceled')"
+ },
+ "project_column_wip_mode_check": {
+ "name": "project_column_wip_mode_check",
+ "value": "\"project_column\".\"wip_mode\" IN ('soft', 'hard')"
+ },
+ "project_column_wip_limit_check": {
+ "name": "project_column_wip_limit_check",
+ "value": "\"project_column\".\"wip_limit\" IS NULL OR \"project_column\".\"wip_limit\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_dashboard": {
+ "name": "project_dashboard",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "layout": {
+ "name": "layout",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_dashboard_project_idx": {
+ "name": "project_dashboard_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_dashboard_project_id_project_id_fk": {
+ "name": "project_dashboard_project_id_project_id_fk",
+ "tableFrom": "project_dashboard",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_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.project_view_favorite": {
+ "name": "project_view_favorite",
+ "schema": "",
+ "columns": {
+ "view_id": {
+ "name": "view_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_view_favorite_view_id_project_view_id_fk": {
+ "name": "project_view_favorite_view_id_project_view_id_fk",
+ "tableFrom": "project_view_favorite",
+ "tableTo": "project_view",
+ "columnsFrom": [
+ "view_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_view_favorite_user_id_user_id_fk": {
+ "name": "project_view_favorite_user_id_user_id_fk",
+ "tableFrom": "project_view_favorite",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_view_favorite_view_id_user_id_pk": {
+ "name": "project_view_favorite_view_id_user_id_pk",
+ "columns": [
+ "view_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.revision": {
+ "name": "revision",
+ "schema": "",
+ "columns": {
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rev": {
+ "name": "rev",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {
+ "revision_project_idx": {
+ "name": "revision_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_notification_preference": {
+ "name": "user_notification_preference",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_events": {
+ "name": "email_events",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "telegram_events": {
+ "name": "telegram_events",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_notification_preference_user_id_user_id_fk": {
+ "name": "user_notification_preference_user_id_user_id_fk",
+ "tableFrom": "user_notification_preference",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_notification_preference_project_id_project_id_fk": {
+ "name": "user_notification_preference_project_id_project_id_fk",
+ "tableFrom": "user_notification_preference",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_notification_pref_user_project_unique": {
+ "name": "user_notification_pref_user_project_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_preference": {
+ "name": "user_preference",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "timezone": {
+ "name": "timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'UTC'"
+ },
+ "locale": {
+ "name": "locale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'en'"
+ },
+ "theme": {
+ "name": "theme",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'system'"
+ },
+ "issue_open_mode": {
+ "name": "issue_open_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'panel'"
+ },
+ "start_page": {
+ "name": "start_page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'work-items'"
+ },
+ "show_chat_by_default": {
+ "name": "show_chat_by_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "issue_stats_open": {
+ "name": "issue_stats_open",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "issue_stats_view": {
+ "name": "issue_stats_view",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'compact'"
+ },
+ "issue_activity_view": {
+ "name": "issue_activity_view",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'flat'"
+ },
+ "auto_watch": {
+ "name": "auto_watch",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "hotkeys": {
+ "name": "hotkeys",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_project_id": {
+ "name": "last_project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_preference_user_id_user_id_fk": {
+ "name": "user_preference_user_id_user_id_fk",
+ "tableFrom": "user_preference",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_preference_last_project_id_project_id_fk": {
+ "name": "user_preference_last_project_id_project_id_fk",
+ "tableFrom": "user_preference",
+ "tableTo": "project",
+ "columnsFrom": [
+ "last_project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "user_preference_theme_check": {
+ "name": "user_preference_theme_check",
+ "value": "\"user_preference\".\"theme\" IN ('light', 'dark', 'system')"
+ },
+ "user_preference_issue_open_mode_check": {
+ "name": "user_preference_issue_open_mode_check",
+ "value": "\"user_preference\".\"issue_open_mode\" IN ('panel', 'page')"
+ },
+ "user_preference_start_page_check": {
+ "name": "user_preference_start_page_check",
+ "value": "\"user_preference\".\"start_page\" IN ('inbox', 'dashboard', 'work-items', 'initiatives')"
+ },
+ "user_preference_issue_stats_view_check": {
+ "name": "user_preference_issue_stats_view_check",
+ "value": "\"user_preference\".\"issue_stats_view\" IN ('compact', 'timeline')"
+ },
+ "user_preference_issue_activity_view_check": {
+ "name": "user_preference_issue_activity_view_check",
+ "value": "\"user_preference\".\"issue_activity_view\" IN ('flat', 'grouped')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_telegram_account": {
+ "name": "user_telegram_account",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "username": {
+ "name": "username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "link_code": {
+ "name": "link_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "link_code_expires_at": {
+ "name": "link_code_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "linked_at": {
+ "name": "linked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_telegram_account_chat_id_unique": {
+ "name": "user_telegram_account_chat_id_unique",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"user_telegram_account\".\"chat_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_telegram_account_link_code_unique": {
+ "name": "user_telegram_account_link_code_unique",
+ "columns": [
+ {
+ "expression": "link_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"user_telegram_account\".\"link_code\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_telegram_account_user_id_user_id_fk": {
+ "name": "user_telegram_account_user_id_user_id_fk",
+ "tableFrom": "user_telegram_account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.webhook": {
+ "name": "webhook",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "secret": {
+ "name": "secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "events": {
+ "name": "events",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "consecutive_failures": {
+ "name": "consecutive_failures",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "webhook_project_idx": {
+ "name": "webhook_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "webhook_project_id_project_id_fk": {
+ "name": "webhook_project_id_project_id_fk",
+ "tableFrom": "webhook",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.webhook_delivery": {
+ "name": "webhook_delivery",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "webhook_id": {
+ "name": "webhook_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_id": {
+ "name": "event_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_status": {
+ "name": "response_status",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_body": {
+ "name": "response_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "webhook_delivery_due_idx": {
+ "name": "webhook_delivery_due_idx",
+ "columns": [
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"webhook_delivery\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "webhook_delivery_webhook_idx": {
+ "name": "webhook_delivery_webhook_idx",
+ "columns": [
+ {
+ "expression": "webhook_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "webhook_delivery_webhook_id_webhook_id_fk": {
+ "name": "webhook_delivery_webhook_id_webhook_id_fk",
+ "tableFrom": "webhook_delivery",
+ "tableTo": "webhook",
+ "columnsFrom": [
+ "webhook_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "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 b3e124fb..b24ff136 100644
--- a/packages/db/drizzle/meta/_journal.json
+++ b/packages/db/drizzle/meta/_journal.json
@@ -701,6 +701,13 @@
"when": 1787563975233,
"tag": "0099_opposite_charles_xavier",
"breakpoints": true
+ },
+ {
+ "idx": 100,
+ "version": "7",
+ "when": 1787566900135,
+ "tag": "0100_modern_sabretooth",
+ "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 01795f37..8ae0b8fd 100644
--- a/packages/db/src/schema/app.ts
+++ b/packages/db/src/schema/app.ts
@@ -956,8 +956,10 @@ export const initiativeLabel = pgTable(
// 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.
+// cycle never has to be started or closed by hand. completed_at is the one override:
+// a cycle finished ahead of its dates counts as completed from that moment on.
+// 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',
{
@@ -970,6 +972,10 @@ export const cycle = pgTable(
goal: text('goal').notNull().default(''),
startDate: date('start_date').notNull(),
endDate: date('end_date').notNull(),
+ // When the cycle was finished before its planned end date. NULL while it still
+ // runs on its dates; once set it is never cleared, and end_date keeps the date
+ // the cycle was planned to run until.
+ completedAt: timestamp('completed_at', { withTimezone: true }),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
},