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: start an agent schedule when an issue enters a state (#499)

Croff1ce0a058b295
diff --git a/apps/api/src/modules/agents/core/__tests__/integration/run-limits.test.ts b/apps/api/src/modules/agents/core/__tests__/integration/run-limits.test.ts
index edf060fc..03d15a8e 100644
--- a/apps/api/src/modules/agents/core/__tests__/integration/run-limits.test.ts
+++ b/apps/api/src/modules/agents/core/__tests__/integration/run-limits.test.ts
@@ -16,7 +16,8 @@ import { processAgentRuns } from '../../run-poller';
// Leaves one run of the team in flight and a second one due, which is the pair the
// ceiling is read against. Claiming the first stamps it without running it, so it holds
-// a slot for as long as its lease.
+// a slot for as long as its lease. The two work on different issues: a second run on
+// the same issue would wait for the first whatever the ceiling.
async function setup() {
const owner = await signUpTestUser({ name: 'Owner' });
const asOwner = authedApi(owner.cookie);
@@ -26,27 +27,24 @@ async function setup() {
const agent = (
await createAgent(asOwner, 'MKT', { name: 'Bot', username: 'bot', kind: 'internal' })
).data!.agent;
- const issue = (
- await asOwner.projects({ projectKey: 'MKT' }).issues.post({ columnId, title: 'Task' })
- ).data!;
const projectId = agent.projects[0].id;
- const enqueue = (prompt: string) =>
- enqueueAgentRun({
+ const enqueue = async (title: string) => {
+ const issue = (await asOwner.projects({ projectKey: 'MKT' }).issues.post({ columnId, title }))
+ .data!;
+ await enqueueAgentRun({
agentId: agent.id,
projectId,
issueId: issue.id,
sourceActivityId: null,
- prompt,
+ prompt: title,
});
+ return issue.id;
+ };
await enqueue('first');
await claimDueRuns();
- await enqueue('second');
- const [, second] = await db
- .select()
- .from(agentRun)
- .where(eq(agentRun.issueId, issue.id))
- .orderBy(agentRun.id);
+ const issueId = await enqueue('second');
+ const [second] = await db.select().from(agentRun).where(eq(agentRun.issueId, issueId));
return { second };
}
diff --git a/apps/api/src/modules/agents/core/__tests__/integration/run-queue.test.ts b/apps/api/src/modules/agents/core/__tests__/integration/run-queue.test.ts
index c9bc338a..e0cbdd67 100644
--- a/apps/api/src/modules/agents/core/__tests__/integration/run-queue.test.ts
+++ b/apps/api/src/modules/agents/core/__tests__/integration/run-queue.test.ts
@@ -79,6 +79,36 @@ describe('agent_run queue store', () => {
expect(second.find((r) => r.id === runId)).toBeUndefined();
});
+ it('runs the runs of one agent on one issue one at a time, oldest first', async () => {
+ const { asOwner, columnId } = await setup();
+ const { agent, issue, runId } = await enqueueRun(asOwner, columnId);
+ const run = {
+ agentId: agent.id,
+ projectId: agent.projects[0].id,
+ sourceActivityId: null,
+ prompt: 'and this',
+ };
+ await enqueueAgentRun({ ...run, issueId: issue.id });
+ const other = (
+ await asOwner.projects({ projectKey: 'MKT' }).issues.post({ columnId, title: 'Other' })
+ ).data!;
+ await enqueueAgentRun({ ...run, issueId: other.id });
+ const [second, onOther] = await db
+ .select()
+ .from(agentRun)
+ .where(eq(agentRun.agentId, agent.id))
+ .orderBy(agentRun.id)
+ .then((rows) => rows.slice(1));
+
+ // The older run of the issue and the run of the other issue go together.
+ expect((await claimDueRuns()).map((r) => r.id).sort()).toEqual([runId, onOther.id].sort());
+ // The newer run of the issue waits while the older one is in flight.
+ expect(await claimDueRuns()).toEqual([]);
+
+ await markRunSuccess(runId, 'done', null);
+ expect((await claimDueRuns()).map((r) => r.id)).toEqual([second.id]);
+ });
+
it('counts the in-flight runs a run waits behind', async () => {
const { asOwner, columnId } = await setup();
const { agent, issue, runId } = await enqueueRun(asOwner, columnId);
diff --git a/apps/api/src/modules/agents/core/__tests__/unit/framing.test.ts b/apps/api/src/modules/agents/core/__tests__/unit/framing.test.ts
index fb68bf15..ca63b461 100644
--- a/apps/api/src/modules/agents/core/__tests__/unit/framing.test.ts
+++ b/apps/api/src/modules/agents/core/__tests__/unit/framing.test.ts
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'bun:test';
-import { projectPreamble } from '../../prompt/framing';
+import { framePrompt, projectPreamble, type RunForPrompt } from '../../prompt/framing';
import { PROJECT_DESCRIPTION_LIMIT } from '#modules/projects/model';
describe('projectPreamble', () => {
@@ -20,3 +20,37 @@ describe('projectPreamble', () => {
expect(text).not.toContain('x'.repeat(PROJECT_DESCRIPTION_LIMIT + 1));
});
});
+
+const run: RunForPrompt = {
+ id: 1,
+ trigger: 'field',
+ prompt: 'Work item MKT-7: "Checkout" now has you as its "Reviewer". Review it.',
+ issueId: 7,
+ issueIdentifier: 'MKT-7',
+ issueTitle: 'Checkout',
+ assigneeName: null,
+ assigneeUsername: 'ann',
+ requesterName: null,
+ requesterUsername: null,
+ agentUserId: 'agent-user',
+ agentUsername: 'bot',
+ threadContext: null,
+ sourceActivityId: null,
+};
+
+describe('framePrompt', () => {
+ it('frames a field run as work on the issue, not as an answer to a comment', () => {
+ const text = framePrompt(run);
+ expect(text.startsWith(run.prompt)).toBe(true);
+ expect(text).toContain('issueId 7');
+ expect(text).toContain('@ann');
+ expect(text).not.toContain('comment on issue');
+ });
+
+ it('frames a status run the same way, with the task its prompt carries', () => {
+ const prompt = 'Work item MKT-7: "Checkout" entered the "Analysis" status.\n\nWrite the spec.';
+ const text = framePrompt({ ...run, trigger: 'status', prompt });
+ expect(text.startsWith(prompt)).toBe(true);
+ expect(text).toContain('carry out the task above');
+ });
+});
diff --git a/apps/api/src/modules/agents/core/prompt/framing.ts b/apps/api/src/modules/agents/core/prompt/framing.ts
index 8d10ea40..3505574e 100644
--- a/apps/api/src/modules/agents/core/prompt/framing.ts
+++ b/apps/api/src/modules/agents/core/prompt/framing.ts
@@ -59,38 +59,56 @@ export function framePrompt(run: RunForPrompt): string {
if (run.trigger === 'schedule' || run.trigger === 'manual') {
return `Carry out the following task:\n\n${run.prompt}`;
}
+ if (run.trigger === 'status' || run.trigger === 'field') return frameIssueTask(run);
const ref = run.issueIdentifier ?? `#${run.issueId}`;
const titled = run.issueTitle ? `${ref} "${run.issueTitle}"` : ref;
return run.trigger === 'delegation' ? frameDelegation(run, titled) : frameMention(run, titled);
}
function frameDelegation(run: RunForPrompt, titled: string): string {
- const lines = [
+ return [
`Issue ${titled} of your project has been delegated to you. Carry it out.`,
'Read the issue for context, then do the work it needs with your tools. Add a',
'question comment only when you genuinely cannot proceed without a human answer.',
- ];
+ ...assigneeLines(run),
+ '',
+ 'When you are done, add a comment to the issue with the add_comment tool',
+ `(issueId ${run.issueId}) describing what you did, and set the issue's status with`,
+ 'the update_issue tool. Do not mention yourself.',
+ ].join('\n');
+}
+
+// The run's prompt already names the issue and what put the agent on it: the member field
+// it was set into, or the column the issue entered followed by the schedule's task.
+// Moving the issue on is left to that task: a status schedule is often one step of
+// several, each started by the column before it.
+function frameIssueTask(run: RunForPrompt): string {
+ return [
+ run.prompt,
+ '',
+ 'Read the issue for context, then carry out the task above with your tools. Add a',
+ 'question comment only when you genuinely cannot proceed without a human answer.',
+ ...assigneeLines(run),
+ '',
+ 'When you are done, add a comment to the issue with the add_comment tool',
+ `(issueId ${run.issueId}) describing what you did. Do not mention yourself.`,
+ ].join('\n');
+}
+
+function assigneeLines(run: RunForPrompt): string[] {
if (run.assigneeUsername) {
- lines.push(
+ return [
'',
'Whenever you comment on this issue, tag the responsible assignee',
`@${run.assigneeUsername} so they are notified.`,
- );
- } else {
- lines.push(
- '',
- 'This issue has no assignee. Before you comment, call get_project and read',
- "the members' descriptions; tag the one member whose role best fits this work. If",
- 'none clearly fits, tag a project owner. Tag exactly one person.',
- );
+ ];
}
- lines.push(
+ return [
'',
- 'When you are done, add a comment to the issue with the add_comment tool',
- `(issueId ${run.issueId}) describing what you did, and set the issue's status with`,
- 'the update_issue tool. Do not mention yourself.',
- );
- return lines.join('\n');
+ 'This issue has no assignee. Before you comment, call get_project and read',
+ "the members' descriptions; tag the one member whose role best fits this work. If",
+ 'none clearly fits, tag a project owner. Tag exactly one person.',
+ ];
}
function frameMention(run: RunForPrompt, titled: string): string {
diff --git a/apps/api/src/modules/agents/core/run-activity.ts b/apps/api/src/modules/agents/core/run-activity.ts
index 89beb5f8..470273a6 100644
--- a/apps/api/src/modules/agents/core/run-activity.ts
+++ b/apps/api/src/modules/agents/core/run-activity.ts
@@ -1,16 +1,32 @@
import { recordActivity, textSide } from '#modules/issues/activity';
+import { getIssue, updateIssue } from '#modules/issues/service';
+import type { AgentRunTrigger } from '../model';
+import { isProjectAgent } from './service';
-// Records that an agent took a queued run of the issue. Only the first claim is
-// logged: a re-claim after an expired lease is the same task handed out again.
-export async function recordAgentRunStarted(run: {
+// What happens on the issue when an agent takes a queued run of it. Only the first
+// claim counts: a re-claim after an expired lease is the same task handed out again.
+// A status run first makes the agent the issue's delegate, so the issue shows which
+// agent works on it.
+export async function agentRunStarted(run: {
issueId: number | null;
attempts: number;
agentUserId: string;
+ trigger: AgentRunTrigger;
}): Promise<void> {
if (run.issueId == null || run.attempts > 1) return;
+ if (run.trigger === 'status') await delegateToAgent(run.issueId, run.agentUserId);
await recordActivity(run.issueId, [{ action: 'agent_started' }], run.agentUserId);
}
+// The agent sets itself, so the delegation does not queue a second run. An agent that
+// has left the project since its run was queued cannot be the delegate.
+async function delegateToAgent(issueId: number, agentUserId: string): Promise<void> {
+ const row = await getIssue(issueId);
+ if (!row || row.delegateUserId === agentUserId) return;
+ if (!(await isProjectAgent(row.projectId, agentUserId))) return;
+ await updateIssue(issueId, { delegateUserId: agentUserId }, agentUserId);
+}
+
// Records how the agent's run of the issue ended.
export async function recordAgentRunFinished(
run: { issueId: number | null; agentUserId: string },
diff --git a/apps/api/src/modules/agents/core/run-poller.ts b/apps/api/src/modules/agents/core/run-poller.ts
index 5f31cf05..d9556749 100644
--- a/apps/api/src/modules/agents/core/run-poller.ts
+++ b/apps/api/src/modules/agents/core/run-poller.ts
@@ -2,9 +2,8 @@ import { db, teamWorkspaceId } from '@repo/db';
import { getProjectTeamId } from '#modules/projects/service';
import { intEnv } from '#shared/lib';
import { getLimits } from '#shared/limits';
-import { equalJitterBackoffMs } from './helpers/backoff';
import { framePrompt, peopleContext, runModePreamble } from './prompt/framing';
-import { recordAgentRunFinished, recordAgentRunStarted } from './run-activity';
+import { agentRunStarted, recordAgentRunFinished } from './run-activity';
import {
agentRunConfig,
claimDueRuns,
@@ -12,6 +11,7 @@ import {
deferRun,
markRunFailed,
markRunSuccess,
+ runRetryDelayMs,
scheduleRunRetry,
type ClaimedRun,
} from './run-queue';
@@ -25,8 +25,6 @@ import { runThreadId } from './runtime/thread-ids';
// How long a run waits when its workspace has no free slot.
const DEFERRED_RETRY_SECONDS = 30;
-const RETRY_BASE_MS = 30_000;
-const RETRY_CAP_MS = 30 * 60_000;
export async function processAgentRuns(): Promise<void> {
const runs = await claimDueRuns();
@@ -43,8 +41,8 @@ async function processRun(run: ClaimedRun): Promise<void> {
// The issue's timeline entries are written here, where the agent's work actually
// starts and ends. A failure that will be retried is not the end of the run, so only
// the last attempt logs one.
- await recordAgentRunStarted(run);
try {
+ await agentRunStarted(run);
const result = await runAgent(run.agentId, run.projectId, framePrompt(run), {
callerUserId: run.agentUserId,
threadId: runThreadId(run),
@@ -58,11 +56,7 @@ async function processRun(run: ClaimedRun): Promise<void> {
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
if (run.attempts < agentRunConfig.maxAttempts()) {
- await scheduleRunRetry(
- run.id,
- equalJitterBackoffMs(run.attempts, RETRY_BASE_MS, RETRY_CAP_MS),
- message,
- );
+ await scheduleRunRetry(run.id, runRetryDelayMs(run.attempts), message);
return;
}
await recordAgentRunFinished(run, 'failed');
diff --git a/apps/api/src/modules/agents/core/run-queue.ts b/apps/api/src/modules/agents/core/run-queue.ts
index 1061a24c..c6106b98 100644
--- a/apps/api/src/modules/agents/core/run-queue.ts
+++ b/apps/api/src/modules/agents/core/run-queue.ts
@@ -2,6 +2,7 @@ import { db, agentRun, issue, project, team } from '@repo/db';
import { and, desc, eq, gt, inArray, isNotNull, lt, sql } from 'drizzle-orm';
import { intEnv, iso } from '#shared/lib';
import type { AgentRunTrigger } from '../model';
+import { equalJitterBackoffMs } from './helpers/backoff';
// The agent_run outbox: data access for triggered runs and run history. The api's
// run poller claims pending rows, runs them, and records the outcome.
@@ -16,6 +17,27 @@ export const agentRunConfig = {
leaseSeconds: () => intEnv('AGENT_RUN_LEASE_SECONDS', 300),
};
+const RETRY_BASE_MS = 30_000;
+const RETRY_CAP_MS = 30 * 60_000;
+
+// How long a run waits before its next attempt after the given one failed.
+export function runRetryDelayMs(attempts: number): number {
+ return equalJitterBackoffMs(attempts, RETRY_BASE_MS, RETRY_CAP_MS);
+}
+
+// The condition a candidate run `q` of a claim meets when it is its turn. The runs of
+// one agent on one issue share the agent's conversation thread and act on the same
+// issue, so they go one at a time, oldest first: a run waits while another of them
+// holds a slot (claimed and inside its lease, or waiting out a retry), and while an
+// older one is due, which the same claim takes instead.
+export const issueRunTurn = sql`NOT EXISTS (
+ SELECT 1 FROM agent_run o
+ WHERE o.agent_id = q.agent_id AND o.issue_id = q.issue_id AND o.id <> q.id
+ AND o.status = 'pending'
+ AND ((o.started_at IS NOT NULL AND o.next_attempt_at > now())
+ OR (o.next_attempt_at <= now() AND o.id < q.id))
+)`;
+
// Runs of this workspace's agents that hold a slot and were queued before this one. A claim
// stamps started_at and pushes next_attempt_at forward, so a pending run that is
// stamped and still inside that window is one of them — as is a run waiting out its
@@ -68,7 +90,7 @@ export async function enqueueAgentRun(input: {
export interface ClaimedRun {
id: number;
agentId: number;
- // Null for a scheduled or manual run, which works on no single issue.
+ // Null for a cron schedule's run or a manual one, which works on no single issue.
issueId: number | null;
scheduleId: number | null;
trigger: AgentRunTrigger;
@@ -119,6 +141,7 @@ export async function claimDueRuns(): Promise<ClaimedRun[]> {
SELECT id FROM agent_run q
WHERE q.status = 'pending' AND q.next_attempt_at <= now()
AND (SELECT kind FROM ai_agent a WHERE a.id = q.agent_id) = 'internal'
+ AND ${issueRunTurn}
ORDER BY q.next_attempt_at, q.id
FOR UPDATE SKIP LOCKED
LIMIT ${batchSize}
diff --git a/apps/api/src/modules/agents/model.ts b/apps/api/src/modules/agents/model.ts
index 49c57fcd..d7e9f949 100644
--- a/apps/api/src/modules/agents/model.ts
+++ b/apps/api/src/modules/agents/model.ts
@@ -23,6 +23,7 @@ export const agentRunTrigger = t.Union([
t.Literal('field'),
t.Literal('schedule'),
t.Literal('manual'),
+ t.Literal('status'),
]);
export type AgentRunTrigger = typeof agentRunTrigger.static;
diff --git a/apps/api/src/modules/agents/runner/service.ts b/apps/api/src/modules/agents/runner/service.ts
index 847a33dc..213f5eec 100644
--- a/apps/api/src/modules/agents/runner/service.ts
+++ b/apps/api/src/modules/agents/runner/service.ts
@@ -1,8 +1,14 @@
import { db, aiAgent, agentRun, project, projectMember } from '@repo/db';
import { and, eq, sql } from 'drizzle-orm';
import { type ContextUsage } from '../chat-usage';
-import { agentRunConfig, loadThreadContext } from '../core/run-queue';
-import { recordAgentRunFinished, recordAgentRunStarted } from '../core/run-activity';
+import {
+ agentRunConfig,
+ issueRunTurn,
+ loadThreadContext,
+ runRetryDelayMs,
+ scheduleRunRetry,
+} from '../core/run-queue';
+import { agentRunStarted, recordAgentRunFinished } from '../core/run-activity';
import type { AgentKind } from '../core/service';
import type { AgentRunTrigger } from '../model';
import {
@@ -142,6 +148,7 @@ export async function claimRunnerRun(agent: RunnerAgent): Promise<RunnerRun | nu
WHERE r.id = (
SELECT id FROM agent_run q
WHERE q.agent_id = ${agentId} AND q.status = 'pending' AND q.next_attempt_at <= now()
+ AND ${issueRunTurn}
ORDER BY q.next_attempt_at, q.id
FOR UPDATE SKIP LOCKED
LIMIT 1
@@ -181,7 +188,15 @@ export async function claimRunnerRun(agent: RunnerAgent): Promise<RunnerRun | nu
agentUsername: agent.username,
threadContext,
};
- await recordAgentRunStarted(forPrompt);
+ // A start that fails is a failed attempt: the run comes back after the retry delay,
+ // with the error on it, rather than being handed out half started.
+ try {
+ await agentRunStarted(forPrompt);
+ } catch (error) {
+ const message = error instanceof Error ? error.message : String(error);
+ await scheduleRunRetry(row.id, runRetryDelayMs(row.attempts), message);
+ return null;
+ }
return {
id: row.id,
trigger: row.trigger,
diff --git a/apps/api/src/modules/agents/schedules/__tests__/integration/agent-schedules.test.ts b/apps/api/src/modules/agents/schedules/__tests__/integration/agent-schedules.test.ts
index f63d9f2b..6048c5a8 100644
--- a/apps/api/src/modules/agents/schedules/__tests__/integration/agent-schedules.test.ts
+++ b/apps/api/src/modules/agents/schedules/__tests__/integration/agent-schedules.test.ts
@@ -110,7 +110,7 @@ describe('agent schedules', () => {
lastRunAt: null,
lastRunStatus: null,
});
- expect(new Date(created.data!.nextRunAt).getTime()).toBeGreaterThan(Date.now());
+ expect(new Date(created.data!.nextRunAt!).getTime()).toBeGreaterThan(Date.now());
const list = await schedules(asOwner).get();
expect(list.status).toBe(200);
@@ -234,13 +234,13 @@ describe('agent schedules', () => {
const paused = await schedules(asOwner)({ scheduleId }).patch({ status: 'paused' });
expect(paused.status).toBe(200);
expect(paused.data).toMatchObject({ status: 'paused' });
- expect(new Date(paused.data!.nextRunAt).getTime()).toBe(
- new Date(created.data!.nextRunAt).getTime(),
+ expect(new Date(paused.data!.nextRunAt!).getTime()).toBe(
+ new Date(created.data!.nextRunAt!).getTime(),
);
const resumed = await schedules(asOwner)({ scheduleId }).patch({ status: 'active' });
expect(resumed.data).toMatchObject({ status: 'active' });
- expect(new Date(resumed.data!.nextRunAt).getTime()).toBeGreaterThan(Date.now());
+ expect(new Date(resumed.data!.nextRunAt!).getTime()).toBeGreaterThan(Date.now());
});
it('recomputes the next run when the cron changes', async () => {
@@ -256,7 +256,7 @@ describe('agent schedules', () => {
cron: '30 9 * * *',
prompt: 'Triage and label the new issues.',
});
- expect(new Date(updated.data!.nextRunAt).getUTCMinutes()).toBe(30);
+ expect(new Date(updated.data!.nextRunAt!).getUTCMinutes()).toBe(30);
});
it('queues a manual run and reports it in the run history', async () => {
diff --git a/apps/api/src/modules/agents/schedules/__tests__/integration/status-schedules.test.ts b/apps/api/src/modules/agents/schedules/__tests__/integration/status-schedules.test.ts
new file mode 100644
index 00000000..e652ce8e
--- /dev/null
+++ b/apps/api/src/modules/agents/schedules/__tests__/integration/status-schedules.test.ts
@@ -0,0 +1,289 @@
+import { describe, it, expect, beforeEach } from 'bun:test';
+import { db, agentRun, issue as issueTable } from '@repo/db';
+import { eq } from 'drizzle-orm';
+import { apiKeyApi, authedApi, type Api } from '#tests/helpers/app';
+import { signUpTestUser } from '#tests/helpers/auth';
+import { resetDb } from '#tests/helpers/db';
+import { createAgent } from '#tests/helpers/agents';
+import { claimDueRuns, deferRun } from '#modules/agents/core/run-queue';
+
+// A status schedule queues a run on an issue each time one enters its column, held back
+// by the schedule's delay. The poller is not exercised, so the runs stay pending.
+
+const schedules = (api: Api) => api.projects({ projectKey: 'MKT' })['agent-schedules'];
+
+async function setup() {
+ const owner = await signUpTestUser({ name: 'Owner' });
+ const asOwner = authedApi(owner.cookie);
+ await asOwner.projects.post({ key: 'MKT', name: 'Marketing' });
+ const columns = (await asOwner.projects({ projectKey: 'MKT' }).get()).data!.columns;
+ const backlog = columns.find((c) => c.stateType === 'backlog')!;
+ const started = columns.find((c) => c.stateType === 'started')!;
+ const agent = (
+ await createAgent(asOwner, 'MKT', {
+ name: 'Product Bot',
+ username: 'product',
+ kind: 'internal',
+ })
+ ).data!.agent;
+ return { asOwner, backlog, started, agent };
+}
+
+function statusSchedule(
+ api: Api,
+ agentId: number,
+ columnId: number,
+ opts: { prompt?: string; delaySec?: number } = {},
+) {
+ return schedules(api).post({
+ agentId,
+ name: 'Analysis',
+ type: 'status',
+ columnId,
+ ...opts,
+ });
+}
+
+function createIssue(api: Api, columnId: number, title = 'Checkout flow') {
+ return api.projects({ projectKey: 'MKT' }).issues.post({ columnId, title });
+}
+
+async function runsOf(api: Api, scheduleId: number) {
+ return (await schedules(api)({ scheduleId }).runs.get()).data!;
+}
+
+describe('status agent schedules', () => {
+ beforeEach(async () => {
+ await resetDb();
+ });
+
+ it('creates a status schedule with no cron and no task', async () => {
+ const { asOwner, started, agent } = await setup();
+ const created = await statusSchedule(asOwner, agent.id, started.id, { delaySec: 300 });
+ expect(created.status).toBe(201);
+ expect(created.data).toMatchObject({
+ type: 'status',
+ prompt: '',
+ cron: null,
+ nextRunAt: null,
+ columnId: started.id,
+ delaySec: 300,
+ status: 'active',
+ });
+ });
+
+ it('refuses the fields of the other type and a missing required one', async () => {
+ const { asOwner, started, agent } = await setup();
+ await asOwner.projects.post({ key: 'OPS', name: 'Ops' });
+ const opsColumn = (await asOwner.projects({ projectKey: 'OPS' }).get()).data!.columns[0];
+
+ const withCron = await schedules(asOwner).post({
+ agentId: agent.id,
+ name: 'Analysis',
+ type: 'status',
+ columnId: started.id,
+ cron: '0 9 * * *',
+ });
+ expect(withCron.status).toBe(400);
+ const noColumn = await schedules(asOwner).post({
+ agentId: agent.id,
+ name: 'Analysis',
+ type: 'status',
+ });
+ expect(noColumn.status).toBe(400);
+ expect((await statusSchedule(asOwner, agent.id, opsColumn.id)).status).toBe(400);
+
+ const cronWithColumn = await schedules(asOwner).post({
+ agentId: agent.id,
+ name: 'Daily',
+ prompt: 'Triage.',
+ cron: '0 9 * * *',
+ columnId: started.id,
+ });
+ expect(cronWithColumn.status).toBe(400);
+ const cronNoTask = await schedules(asOwner).post({
+ agentId: agent.id,
+ name: 'Daily',
+ cron: '0 9 * * *',
+ });
+ expect(cronNoTask.status).toBe(400);
+
+ const created = await statusSchedule(asOwner, agent.id, started.id);
+ const patched = await schedules(asOwner)({ scheduleId: created.data!.id }).patch({
+ cron: '0 9 * * *',
+ });
+ expect(patched.status).toBe(400);
+ });
+
+ it('queues a run on an issue moved into the column, held back by the delay', async () => {
+ const { asOwner, backlog, started, agent } = await setup();
+ const schedule = (
+ await statusSchedule(asOwner, agent.id, started.id, {
+ prompt: 'Write the acceptance criteria.',
+ delaySec: 300,
+ })
+ ).data!;
+ const issue = (await createIssue(asOwner, backlog.id)).data!;
+ expect(await runsOf(asOwner, schedule.id)).toEqual([]);
+
+ await asOwner.issues({ issueId: issue.id }).patch({ columnId: started.id });
+
+ const runs = await runsOf(asOwner, schedule.id);
+ expect(runs).toHaveLength(1);
+ expect(runs[0]).toMatchObject({ status: 'pending', trigger: 'status' });
+ expect(runs[0].prompt).toContain(`${issue.identifier}: "Checkout flow"`);
+ expect(runs[0].prompt).toContain(`"${started.name}"`);
+ expect(runs[0].prompt).toContain('Write the acceptance criteria.');
+
+ const agentRuns = await asOwner
+ .teams({ teamId: agent.teamId })
+ ['ai-agents']({ agentId: agent.id })
+ .runs.get();
+ const run = agentRuns.data!.items[0];
+ expect(run).toMatchObject({ trigger: 'status', issueId: issue.id });
+ expect(new Date(run.nextAttemptAt).getTime() - Date.now()).toBeGreaterThan(290_000);
+
+ const listed = (await schedules(asOwner).get()).data!.items[0];
+ expect(listed.lastRunAt).not.toBeNull();
+ expect(listed.pendingRuns).toBe(1);
+ });
+
+ it('queues a run on an issue created in the column', async () => {
+ const { asOwner, started, agent } = await setup();
+ const schedule = (await statusSchedule(asOwner, agent.id, started.id)).data!;
+
+ await createIssue(asOwner, started.id);
+
+ const runs = await runsOf(asOwner, schedule.id);
+ expect(runs).toHaveLength(1);
+ expect(runs[0].prompt).toContain('Review it and take the appropriate next step.');
+ });
+
+ it('ends a waiting run when the issue leaves the column, and queues a new one on return', async () => {
+ const { asOwner, backlog, started, agent } = await setup();
+ const schedule = (await statusSchedule(asOwner, agent.id, started.id, { delaySec: 300 })).data!;
+ const issue = (await createIssue(asOwner, backlog.id)).data!;
+
+ await asOwner.issues({ issueId: issue.id }).patch({ columnId: started.id });
+ await asOwner.issues({ issueId: issue.id }).patch({ columnId: backlog.id });
+ expect((await runsOf(asOwner, schedule.id)).map((r) => r.status)).toEqual(['canceled']);
+
+ await asOwner.issues({ issueId: issue.id }).patch({ columnId: started.id });
+ expect((await runsOf(asOwner, schedule.id)).map((r) => r.status)).toEqual([
+ 'pending',
+ 'canceled',
+ ]);
+ });
+
+ it('ends a run deferred for want of a slot when the issue leaves the column', async () => {
+ const { asOwner, backlog, started, agent } = await setup();
+ const schedule = (await statusSchedule(asOwner, agent.id, started.id)).data!;
+ const issue = (await createIssue(asOwner, started.id)).data!;
+ const [claimed] = await claimDueRuns();
+ await deferRun(claimed.id, 30);
+
+ await asOwner.issues({ issueId: issue.id }).patch({ columnId: backlog.id });
+
+ expect((await runsOf(asOwner, schedule.id)).map((r) => r.status)).toEqual(['canceled']);
+ });
+
+ it('does not run while paused', async () => {
+ const { asOwner, started, agent } = await setup();
+ const schedule = (await statusSchedule(asOwner, agent.id, started.id)).data!;
+ await schedules(asOwner)({ scheduleId: schedule.id }).patch({ status: 'paused' });
+
+ await createIssue(asOwner, started.id);
+
+ expect(await runsOf(asOwner, schedule.id)).toEqual([]);
+ });
+
+ it('does not start on a move the agent made itself', async () => {
+ const { asOwner, backlog, started } = await setup();
+ const created = await createAgent(asOwner, 'MKT', {
+ name: 'Runner Bot',
+ username: 'runner',
+ kind: 'external',
+ });
+ const asAgent = apiKeyApi(created.data!.apiKey!);
+ const schedule = (await statusSchedule(asOwner, created.data!.agent.id, started.id)).data!;
+ const issue = (await createIssue(asOwner, backlog.id)).data!;
+
+ const moved = await asAgent.issues({ issueId: issue.id }).patch({ columnId: started.id });
+ expect(moved.status).toBe(200);
+
+ expect(await runsOf(asOwner, schedule.id)).toEqual([]);
+ });
+
+ it('makes the agent the delegate of the issue when it takes the run', async () => {
+ const { asOwner, started } = await setup();
+ const created = await createAgent(asOwner, 'MKT', {
+ name: 'Runner Bot',
+ username: 'runner',
+ kind: 'external',
+ triggerOnAssign: true,
+ });
+ const agent = created.data!.agent;
+ const asRunner = apiKeyApi(created.data!.apiKey!);
+ await statusSchedule(asOwner, agent.id, started.id);
+ const issue = (await createIssue(asOwner, started.id)).data!;
+ expect(issue.delegateUserId).toBeNull();
+
+ const claimed = await asRunner['agent-runs'].claim.post();
+ expect(claimed.data!.run).toMatchObject({ trigger: 'status', issueId: issue.id });
+
+ const after = (await asOwner.issues({ issueId: issue.id }).get()).data!;
+ expect(after.delegateUserId).toBe(agent.userId);
+ // The agent delegated to itself, which queues no delegation run.
+ expect((await asRunner['agent-runs'].claim.post()).data!.run).toBeNull();
+ });
+
+ it('retries a run whose start failed, and hands it out without the delegation', async () => {
+ const { asOwner, started } = await setup();
+ const created = await createAgent(asOwner, 'MKT', {
+ name: 'Runner Bot',
+ username: 'runner',
+ kind: 'external',
+ });
+ const asRunner = apiKeyApi(created.data!.apiKey!);
+ await statusSchedule(asOwner, created.data!.agent.id, started.id);
+ const issue = (await createIssue(asOwner, started.id)).data!;
+ // Dates no update of the issue accepts, as an import can leave them.
+ await db
+ .update(issueTable)
+ .set({ startDate: '2026-05-10', dueDate: '2026-05-01' })
+ .where(eq(issueTable.id, issue.id));
+
+ expect((await asRunner['agent-runs'].claim.post()).data!.run).toBeNull();
+ const [failed] = await db.select().from(agentRun).where(eq(agentRun.issueId, issue.id));
+ expect(failed.lastError).toContain('Due date');
+ expect(failed.nextAttemptAt.getTime()).toBeGreaterThan(Date.now());
+
+ await db.update(agentRun).set({ nextAttemptAt: new Date() }).where(eq(agentRun.id, failed.id));
+ const retried = (await asRunner['agent-runs'].claim.post()).data!.run;
+ expect(retried).toMatchObject({ id: failed.id, attempts: 2 });
+ const after = (await asOwner.issues({ issueId: issue.id }).get()).data!;
+ expect(after.delegateUserId).toBeNull();
+ });
+
+ it('refuses to run a status schedule now', async () => {
+ const { asOwner, started, agent } = await setup();
+ const schedule = (await statusSchedule(asOwner, agent.id, started.id)).data!;
+ const res = await schedules(asOwner)({ scheduleId: schedule.id }).run.post();
+ expect(res.status).toBe(400);
+ });
+
+ it('keeps the column while a run is unfinished, and deletes the schedule with it after', async () => {
+ const { asOwner, backlog, started, agent } = await setup();
+ const schedule = (await statusSchedule(asOwner, agent.id, started.id)).data!;
+ await createIssue(asOwner, started.id);
+ const column = asOwner.projects({ projectKey: 'MKT' }).columns({ columnId: started.id });
+
+ const refused = await column.delete({ mode: 'move', targetColumnId: backlog.id });
+ expect(refused.status).toBe(409);
+
+ await schedules(asOwner)({ scheduleId: schedule.id }).runs.cancel.post();
+ const deleted = await column.delete({ mode: 'move', targetColumnId: backlog.id });
+ expect(deleted.status).toBe(204);
+ expect((await schedules(asOwner).get()).data!.items).toEqual([]);
+ });
+});
diff --git a/apps/api/src/modules/agents/schedules/index.ts b/apps/api/src/modules/agents/schedules/index.ts
index 030a5c9c..07578d5e 100644
--- a/apps/api/src/modules/agents/schedules/index.ts
+++ b/apps/api/src/modules/agents/schedules/index.ts
@@ -21,7 +21,6 @@ import {
updateScheduleBody,
} from './model';
import {
- assertScheduleInterval,
cancelPendingScheduleRuns,
createAgentSchedule,
deleteAgentSchedule,
@@ -29,15 +28,12 @@ import {
getAgentSchedule,
listAgentSchedules,
listScheduleRuns,
+ newScheduleTrigger,
+ requiredText,
+ scheduleTriggerFields,
updateAgentSchedule,
} from './service';
-function requiredText(value: string, field: string): string {
- const trimmed = value.trim();
- if (!trimmed) throw new HttpError(400, `${field} is required`);
- return trimmed;
-}
-
export const agentScheduleRoutes = new Elysia({
name: 'agent-schedules',
detail: { tags: ['Agent Schedules'] },
@@ -55,8 +51,8 @@ export const agentScheduleRoutes = new Elysia({
detail: {
summary: 'List agent schedules',
description:
- "One page of the project's agent schedules with their cron, next run, and last " +
- 'run, newest first.',
+ "One page of the project's agent schedules with their cron or column, next run, " +
+ 'and last run, newest first.',
...mcpTool('list_agent_schedules'),
},
},
@@ -64,8 +60,8 @@ export const agentScheduleRoutes = new Elysia({
.post(
'/projects/:projectKey/agent-schedules',
async ({ project, body, set, user }) => {
- const cron = body.cron.trim();
- await assertScheduleInterval(project.teamId, cron);
+ const type = body.type ?? 'cron';
+ const trigger = await newScheduleTrigger(project, type, body);
let row;
try {
row = await createAgentSchedule({
@@ -73,10 +69,9 @@ export const agentScheduleRoutes = new Elysia({
agentId: body.agentId,
actorUserId: requireUser(user).id,
name: requiredText(body.name, 'Name'),
- prompt: requiredText(body.prompt, 'Task'),
- cron,
+ type,
status: body.status ?? 'active',
- nextRunAt: nextCronRun(cron),
+ ...trigger,
});
} catch (err) {
rethrowDuplicate(err, 'schedule');
@@ -91,7 +86,9 @@ export const agentScheduleRoutes = new Elysia({
response: { 201: AgentScheduleResponse, ...commonErrors, ...errors(409) },
detail: {
summary: 'Create an agent schedule',
- description: 'Create a schedule that sends a task to an agent on a cron.',
+ description:
+ 'Create a schedule that sends a task to an agent on a cron, or on an issue each ' +
+ 'time one enters a column.',
...mcpTool('create_agent_schedule'),
},
},
@@ -99,15 +96,14 @@ export const agentScheduleRoutes = new Elysia({
.patch(
'/projects/:projectKey/agent-schedules/:scheduleId',
async ({ project, params, body, user }) => {
- const cron = body.cron?.trim();
- if (cron !== undefined) await assertScheduleInterval(project.teamId, cron);
const current = await getAgentSchedule(project.id, params.scheduleId, requireUser(user).id);
if (!current) throw new HttpError(404, 'Schedule not found');
- // Recompute the next run when the cron changes, or when resuming a paused schedule.
+ const trigger = await scheduleTriggerFields(project, current.type, body);
+ // A resumed cron schedule runs next from now, not from when it was paused.
const resuming = body.status === 'active' && current.status === 'paused';
- let nextRunAt: Date | undefined;
- if (cron !== undefined) nextRunAt = nextCronRun(cron);
- else if (resuming) nextRunAt = nextCronRun(current.cron);
+ if (resuming && trigger.nextRunAt === undefined && current.cron !== null) {
+ trigger.nextRunAt = nextCronRun(current.cron);
+ }
let row;
try {
row = await updateAgentSchedule(
@@ -116,9 +112,7 @@ export const agentScheduleRoutes = new Elysia({
{
...(body.agentId !== undefined ? { agentId: body.agentId } : {}),
...(body.name !== undefined ? { name: requiredText(body.name, 'Name') } : {}),
- ...(body.prompt !== undefined ? { prompt: requiredText(body.prompt, 'Task') } : {}),
- ...(cron !== undefined ? { cron } : {}),
- ...(nextRunAt !== undefined ? { nextRunAt } : {}),
+ ...trigger,
...(body.status !== undefined ? { status: body.status } : {}),
},
requireUser(user).id,
@@ -136,7 +130,9 @@ export const agentScheduleRoutes = new Elysia({
response: { 200: AgentScheduleResponse, ...commonErrors, ...errors(409) },
detail: {
summary: 'Update an agent schedule',
- description: "Update a schedule's agent, task, cron, or status.",
+ description:
+ "Update a schedule's agent, task, cron or column, or status. Its type stays the one " +
+ 'it was created with.',
...mcpTool('update_agent_schedule'),
},
},
@@ -180,7 +176,8 @@ export const agentScheduleRoutes = new Elysia({
summary: 'Run an agent schedule now',
description:
'Queue a run of the schedule now and return its run id. It runs in the background; ' +
- 'read the result with list_agent_schedule_runs.',
+ "read the result with list_agent_schedule_runs. A 'status' schedule is refused: its " +
+ 'runs work on the issue that entered the column.',
...mcpTool('run_agent_schedule'),
},
},
diff --git a/apps/api/src/modules/agents/schedules/model.ts b/apps/api/src/modules/agents/schedules/model.ts
index b1a2b111..0c09ad6b 100644
--- a/apps/api/src/modules/agents/schedules/model.ts
+++ b/apps/api/src/modules/agents/schedules/model.ts
@@ -15,26 +15,56 @@ export const scheduleRunParams = t.Object({
});
export const scheduleStatus = t.UnionEnum(['active', 'paused'], {
- description: "'active' runs on the cron, 'paused' does not run until it is set back to 'active'.",
+ description: "'active' runs, 'paused' does not run until it is set back to 'active'.",
+});
+
+export const scheduleType = t.UnionEnum(['cron', 'status'], {
+ description:
+ "'cron' runs the task on a cron. 'status' runs on an issue each time one enters a " +
+ 'column: moved there, or created in it.',
});
export const createScheduleBody = t.Object({
agentId: t.Number({ description: 'Internal agent id from list_ai_agents that runs the task.' }),
name: t.String({ minLength: 1, maxLength: 120, description: 'Display name of the schedule.' }),
- prompt: t.String({
- minLength: 1,
- maxLength: 20_000,
- description: 'Task sent to the agent on every run.',
- }),
- cron: t.String({
- minLength: 1,
- maxLength: 120,
- description: "Five-field cron expression in UTC, e.g. '0 9 * * 1' for Mondays at 09:00.",
- }),
+ type: t.Optional(scheduleType),
+ prompt: t.Optional(
+ t.String({
+ maxLength: 20_000,
+ description:
+ "Task sent to the agent on every run. Required for a 'cron' schedule. Optional for " +
+ "a 'status' one, whose run already names the issue and the column it entered.",
+ }),
+ ),
+ cron: t.Optional(
+ t.String({
+ minLength: 1,
+ maxLength: 120,
+ description:
+ "Five-field cron expression in UTC, e.g. '0 9 * * 1' for Mondays at 09:00. " +
+ "Required for a 'cron' schedule, refused on a 'status' one.",
+ }),
+ ),
+ columnId: t.Optional(
+ t.Number({
+ description:
+ "Column id from get_project whose incoming issues start a run. Required for a 'status' " +
+ "schedule, refused on a 'cron' one.",
+ }),
+ ),
+ delaySec: t.Optional(
+ t.Integer({
+ minimum: 0,
+ maximum: 86400,
+ description:
+ "Seconds a 'status' run waits before the agent may pick it up; 0 by default. An issue " +
+ "that leaves the column in that time ends the run. Refused on a 'cron' schedule.",
+ }),
+ ),
status: t.Optional(scheduleStatus),
});
-export const updateScheduleBody = t.Partial(createScheduleBody);
+export const updateScheduleBody = t.Partial(t.Omit(createScheduleBody, ['type']));
// A schedule DTO (AgentScheduleRow from the service).
export const AgentScheduleResponse = t.Object({
@@ -42,11 +72,14 @@ export const AgentScheduleResponse = t.Object({
agentId: t.Number(),
agentName: t.String(),
name: t.String(),
+ type: scheduleType,
prompt: t.String(),
- cron: t.String(),
+ cron: t.Nullable(t.String()),
timezone: t.Literal('UTC'),
+ columnId: t.Nullable(t.Number()),
+ delaySec: t.Number(),
status: scheduleStatus,
- nextRunAt: t.String(),
+ nextRunAt: t.Nullable(t.String()),
lastRunAt: t.Nullable(t.String()),
lastRunStatus: t.Nullable(t.String()),
pendingRuns: t.Number({ description: 'Runs of this schedule that have not started yet.' }),
diff --git a/apps/api/src/modules/agents/schedules/service.ts b/apps/api/src/modules/agents/schedules/service.ts
index ed159737..8515549d 100644
--- a/apps/api/src/modules/agents/schedules/service.ts
+++ b/apps/api/src/modules/agents/schedules/service.ts
@@ -1,24 +1,30 @@
-import { db, agentRun, agentSchedule, aiAgent, user } from '@repo/db';
+import { db, agentRun, agentSchedule, aiAgent, projectColumn, user } from '@repo/db';
import { and, desc, eq, isNull, sql } from 'drizzle-orm';
import { HttpError, iso, rethrowDuplicate } from '#shared/lib';
import { getTeamLimits } from '#shared/limits';
-import { minCronIntervalSeconds } from './cron';
+import { minCronIntervalSeconds, nextCronRun } from './cron';
import { agentWorksInProject, canTriggerAgent, isTriggerableBy } from '../core/service';
import { contextTokensOf } from '../core/run-queue';
import { deleteThreadsWhere } from '../core/runtime/memory';
export type AgentScheduleStatus = 'active' | 'paused';
+export type AgentScheduleType = 'cron' | 'status';
export interface AgentScheduleRow {
id: number;
agentId: number;
agentName: string;
name: string;
+ type: AgentScheduleType;
prompt: string;
- cron: string;
+ // Set on a 'cron' schedule only, as is nextRunAt.
+ cron: string | null;
timezone: 'UTC';
+ // Set on a 'status' schedule only, as is a delay above 0.
+ columnId: number | null;
+ delaySec: number;
status: AgentScheduleStatus;
- nextRunAt: string;
+ nextRunAt: string | null;
lastRunAt: string | null;
lastRunStatus: string | null;
// Runs that have not been picked up yet — the ones cancelPendingScheduleRuns ends.
@@ -35,9 +41,12 @@ const columns = {
agentId: agentSchedule.agentId,
agentName: user.name,
name: agentSchedule.name,
+ type: agentSchedule.type,
prompt: agentSchedule.prompt,
cron: agentSchedule.cron,
timezone: agentSchedule.timezone,
+ columnId: agentSchedule.columnId,
+ delaySec: agentSchedule.delaySec,
status: agentSchedule.status,
nextRunAt: agentSchedule.nextRunAt,
lastRunAt: agentSchedule.lastRunAt,
@@ -72,9 +81,10 @@ function mapSchedule(row: SelectedSchedule, actorUserId: string): AgentScheduleR
const { kind, runnerScope, ownerUserId, ...schedule } = row;
return {
...schedule,
+ type: schedule.type as AgentScheduleType,
timezone: 'UTC',
status: schedule.status as AgentScheduleStatus,
- nextRunAt: iso(schedule.nextRunAt),
+ nextRunAt: schedule.nextRunAt ? iso(schedule.nextRunAt) : null,
lastRunAt: schedule.lastRunAt ? iso(schedule.lastRunAt) : null,
canTrigger: isTriggerableBy({ kind, runnerScope, ownerUserId }, actorUserId),
createdAt: iso(schedule.createdAt),
@@ -138,7 +148,7 @@ async function assertTriggerable(agentId: number, actorUserId: string): Promise<
}
// Refuses a cron that fires more often than the workspace's floor allows.
-export async function assertScheduleInterval(teamId: number, cron: string): Promise<void> {
+async function assertScheduleInterval(teamId: number, cron: string): Promise<void> {
const { minScheduleIntervalSeconds } = await getTeamLimits(teamId);
if (minScheduleIntervalSeconds === 0) return;
if (minCronIntervalSeconds(cron) < minScheduleIntervalSeconds) {
@@ -147,16 +157,101 @@ export async function assertScheduleInterval(teamId: number, cron: string): Prom
}
}
-export async function createAgentSchedule(input: {
- projectId: number;
- agentId: number;
- actorUserId: string;
- name: string;
+// What starts the schedule's runs, as its columns store it.
+interface ScheduleTrigger {
prompt: string;
- cron: string;
- status: AgentScheduleStatus;
- nextRunAt: Date;
-}): Promise<AgentScheduleRow | null> {
+ cron: string | null;
+ nextRunAt: Date | null;
+ columnId: number | null;
+ delaySec: number;
+}
+
+interface ScheduleTriggerInput {
+ prompt?: string;
+ cron?: string;
+ columnId?: number;
+ delaySec?: number;
+}
+
+export function requiredText(value: string, field: string): string {
+ const trimmed = value.trim();
+ if (!trimmed) throw new HttpError(400, `${field} is required`);
+ return trimmed;
+}
+
+async function assertProjectColumn(projectId: number, columnId: number): Promise<void> {
+ const [row] = await db
+ .select({ id: projectColumn.id })
+ .from(projectColumn)
+ .where(and(eq(projectColumn.id, columnId), eq(projectColumn.projectId, projectId)));
+ if (!row) throw new HttpError(400, 'Select a column of this project');
+}
+
+// Checks the fields of the given type that a write sets, and returns them as stored. A
+// field of the other type is refused rather than ignored, so a caller that mixes the two
+// up learns it.
+export async function scheduleTriggerFields(
+ project: { id: number; teamId: number },
+ type: AgentScheduleType,
+ input: ScheduleTriggerInput,
+): Promise<Partial<ScheduleTrigger>> {
+ if (type === 'cron') {
+ if (input.columnId !== undefined || input.delaySec !== undefined) {
+ throw new HttpError(400, 'A cron schedule takes no column and no delay');
+ }
+ const out: Partial<ScheduleTrigger> = {};
+ if (input.prompt !== undefined) out.prompt = requiredText(input.prompt, 'Task');
+ if (input.cron !== undefined) {
+ const cron = input.cron.trim();
+ await assertScheduleInterval(project.teamId, cron);
+ out.cron = cron;
+ out.nextRunAt = nextCronRun(cron);
+ }
+ return out;
+ }
+ if (input.cron !== undefined) throw new HttpError(400, 'A status schedule takes no cron');
+ const out: Partial<ScheduleTrigger> = {};
+ if (input.prompt !== undefined) out.prompt = input.prompt.trim();
+ if (input.columnId !== undefined) {
+ await assertProjectColumn(project.id, input.columnId);
+ out.columnId = input.columnId;
+ }
+ if (input.delaySec !== undefined) out.delaySec = input.delaySec;
+ return out;
+}
+
+// The trigger of a new schedule: the fields its type requires, with the rest left empty.
+export async function newScheduleTrigger(
+ project: { id: number; teamId: number },
+ type: AgentScheduleType,
+ input: ScheduleTriggerInput,
+): Promise<ScheduleTrigger> {
+ if (type === 'cron') {
+ if (input.prompt === undefined) throw new HttpError(400, 'Task is required');
+ if (input.cron === undefined) throw new HttpError(400, 'Cron is required');
+ } else if (input.columnId === undefined) {
+ throw new HttpError(400, 'Column is required');
+ }
+ const fields = await scheduleTriggerFields(project, type, input);
+ return {
+ prompt: fields.prompt ?? '',
+ cron: fields.cron ?? null,
+ nextRunAt: fields.nextRunAt ?? null,
+ columnId: fields.columnId ?? null,
+ delaySec: fields.delaySec ?? 0,
+ };
+}
+
+export async function createAgentSchedule(
+ input: {
+ projectId: number;
+ agentId: number;
+ actorUserId: string;
+ name: string;
+ type: AgentScheduleType;
+ status: AgentScheduleStatus;
+ } & ScheduleTrigger,
+): Promise<AgentScheduleRow | null> {
if (!(await agentWorksInProject(input.agentId, input.projectId))) return null;
await assertTriggerable(input.agentId, input.actorUserId);
const [row] = await db
@@ -165,9 +260,12 @@ export async function createAgentSchedule(input: {
agentId: input.agentId,
projectId: input.projectId,
name: input.name,
+ type: input.type,
prompt: input.prompt,
cron: input.cron,
timezone: 'UTC',
+ columnId: input.columnId,
+ delaySec: input.delaySec,
status: input.status,
nextRunAt: input.nextRunAt,
})
@@ -179,13 +277,10 @@ export async function createAgentSchedule(input: {
export async function updateAgentSchedule(
projectId: number,
scheduleId: number,
- patch: {
+ patch: Partial<ScheduleTrigger> & {
agentId?: number;
name?: string;
- prompt?: string;
- cron?: string;
status?: AgentScheduleStatus;
- nextRunAt?: Date;
},
actorUserId: string,
): Promise<AgentScheduleRow | null> {
@@ -224,6 +319,9 @@ export async function enqueueManualScheduleRun(
): Promise<number | null> {
const schedule = await getAgentSchedule(projectId, scheduleId, actorUserId);
if (!schedule) return null;
+ if (schedule.type === 'status') {
+ throw new HttpError(400, 'A status schedule runs when an issue enters its column');
+ }
await assertTriggerable(schedule.agentId, actorUserId);
const [run] = await db
.insert(agentRun)
diff --git a/apps/api/src/modules/agents/schedules/status-runs.ts b/apps/api/src/modules/agents/schedules/status-runs.ts
new file mode 100644
index 00000000..516db729
--- /dev/null
+++ b/apps/api/src/modules/agents/schedules/status-runs.ts
@@ -0,0 +1,110 @@
+import { db, agentRun, agentSchedule, aiAgent, issue, project, projectColumn } from '@repo/db';
+import { and, eq, inArray, ne, sql } from 'drizzle-orm';
+
+// The runs of 'status' schedules. Every write that puts issues into a column calls
+// queueStatusRuns, next to recordStatusChange.
+
+// Ends the status runs of the given issues that belong to another column and have not
+// started, so an issue moved on before its run starts does not start it. A run deferred
+// for want of a free slot has not started either: deferRun sets its attempts back to 0.
+// Then queues a run of every active status schedule of the column on each issue. An
+// agent that moved the issue itself does not start its own schedule.
+export async function queueStatusRuns(
+ issueIds: number[],
+ columnId: number,
+ actorUserId: string | null | undefined,
+): Promise<void> {
+ if (issueIds.length === 0) return;
+ await db
+ .update(agentRun)
+ .set({ status: 'canceled', finishedAt: new Date() })
+ .where(
+ and(
+ inArray(agentRun.issueId, issueIds),
+ eq(agentRun.trigger, 'status'),
+ eq(agentRun.status, 'pending'),
+ eq(agentRun.attempts, 0),
+ sql`${agentRun.scheduleId} IN (
+ select ${agentSchedule.id} from ${agentSchedule}
+ where ${agentSchedule.columnId} <> ${columnId}
+ )`,
+ ),
+ );
+
+ const schedules = await db
+ .select({
+ id: agentSchedule.id,
+ agentId: agentSchedule.agentId,
+ prompt: agentSchedule.prompt,
+ delaySec: agentSchedule.delaySec,
+ columnName: projectColumn.name,
+ })
+ .from(agentSchedule)
+ .innerJoin(aiAgent, eq(aiAgent.id, agentSchedule.agentId))
+ .innerJoin(projectColumn, eq(projectColumn.id, agentSchedule.columnId))
+ .where(
+ and(
+ eq(agentSchedule.columnId, columnId),
+ eq(agentSchedule.status, 'active'),
+ actorUserId ? ne(aiAgent.userId, actorUserId) : undefined,
+ ),
+ );
+ if (schedules.length === 0) return;
+
+ const issues = await db
+ .select({
+ id: issue.id,
+ projectId: issue.projectId,
+ title: issue.title,
+ identifier: sql<string>`${project.key} || '-' || ${issue.sequenceNumber}`,
+ })
+ .from(issue)
+ .innerJoin(project, eq(project.id, issue.projectId))
+ .where(inArray(issue.id, issueIds));
+ if (issues.length === 0) return;
+
+ await db.insert(agentRun).values(
+ schedules.flatMap((schedule) =>
+ issues.map((row) => ({
+ agentId: schedule.agentId,
+ projectId: row.projectId,
+ issueId: row.id,
+ scheduleId: schedule.id,
+ trigger: 'status',
+ prompt: statusRunPrompt(row, schedule.columnName, schedule.prompt),
+ nextAttemptAt: sql`now() + make_interval(secs => ${schedule.delaySec})`,
+ })),
+ ),
+ );
+ await db
+ .update(agentSchedule)
+ .set({ lastRunAt: new Date() })
+ .where(
+ inArray(
+ agentSchedule.id,
+ schedules.map((schedule) => schedule.id),
+ ),
+ );
+}
+
+function statusRunPrompt(
+ row: { identifier: string; title: string },
+ columnName: string,
+ task: string,
+): string {
+ const lead = `Work item ${row.identifier}: "${row.title}" entered the "${columnName}" status.`;
+ return task ? `${lead}\n\n${task}` : `${lead} Review it and take the appropriate next step.`;
+}
+
+// Whether a status schedule of the column has a run that has not finished: one waiting
+// out its delay or one being executed. Deleting the column deletes the schedule and
+// its runs with it.
+export async function hasUnfinishedStatusRuns(columnId: number): Promise<boolean> {
+ const [row] = await db
+ .select({ id: agentRun.id })
+ .from(agentRun)
+ .innerJoin(agentSchedule, eq(agentSchedule.id, agentRun.scheduleId))
+ .where(and(eq(agentSchedule.columnId, columnId), eq(agentRun.status, 'pending')))
+ .limit(1);
+ return row != null;
+}
diff --git a/apps/api/src/modules/analytics/model.ts b/apps/api/src/modules/analytics/model.ts
index f0f37f9e..423b3f19 100644
--- a/apps/api/src/modules/analytics/model.ts
+++ b/apps/api/src/modules/analytics/model.ts
@@ -1,5 +1,6 @@
import { t } from 'elysia';
import { ActivityPayloadResponse } from '#shared/activity';
+import { agentRunTrigger } from '#modules/agents/model';
export const StatsDto = t.Object({
open: t.Number(),
@@ -77,13 +78,7 @@ export const ActivityPage = t.Object({
const AgentRunFeedItem = t.Object({
id: t.Number(),
status: t.String(),
- trigger: t.Union([
- t.Literal('mention'),
- t.Literal('delegation'),
- t.Literal('field'),
- t.Literal('schedule'),
- t.Literal('manual'),
- ]),
+ trigger: agentRunTrigger,
agentId: t.Number(),
agentName: t.String(),
issueId: t.Nullable(t.Number()),
diff --git a/apps/api/src/modules/analytics/service.ts b/apps/api/src/modules/analytics/service.ts
index abe23c54..ac4832eb 100644
--- a/apps/api/src/modules/analytics/service.ts
+++ b/apps/api/src/modules/analytics/service.ts
@@ -15,6 +15,7 @@ import {
} from '@repo/db';
import { and, desc, eq, inArray, isNull, isNotNull, sql } from 'drizzle-orm';
import { HttpError, iso } from '#shared/lib';
+import type { AgentRunTrigger } from '#modules/agents/model';
// Read-only project metrics for the dashboards feature. Every figure is derived
// from the existing issue / project_column / issue_activity / issue_status tables —
@@ -611,7 +612,7 @@ export async function listActivity(
export interface AgentRunFeedItem {
id: number;
status: string;
- trigger: 'mention' | 'delegation' | 'field' | 'schedule' | 'manual';
+ trigger: AgentRunTrigger;
agentId: number;
agentName: string;
issueId: number | null;
diff --git a/apps/api/src/modules/columns/index.ts b/apps/api/src/modules/columns/index.ts
index 3590c323..c2a30c6c 100644
--- a/apps/api/src/modules/columns/index.ts
+++ b/apps/api/src/modules/columns/index.ts
@@ -5,7 +5,7 @@ import { authContext } from '#shared/auth-context';
import { guards } from '#shared/guards';
import { requireUser } from '#shared/access';
import { HttpError } from '#shared/lib';
-import { commonErrors } from '#shared/responses';
+import { commonErrors, errors } from '#shared/responses';
import {
ColumnListResponse,
ColumnResponse,
@@ -92,12 +92,14 @@ export const columnRoutes = new Elysia({ name: 'columns', detail: { tags: ['Colu
body: deleteColumnBody,
params: columnParams,
permission: ['states', 'delete'],
- response: { 204: t.Void(), ...commonErrors },
+ response: { 204: t.Void(), ...commonErrors, ...errors(409) },
detail: {
summary: 'Delete a column',
description:
"Delete a column. Body mode 'move' reassigns its issues to targetColumnId, " +
- "'delete' removes them. Backlog columns cannot be deleted.",
+ "'delete' removes them. Backlog columns cannot be deleted, nor a column whose " +
+ 'agent schedules have runs that have not finished. The schedules of a deleted ' +
+ 'column are deleted with it.',
...mcpTool('delete_column'),
},
},
diff --git a/apps/api/src/modules/columns/service.ts b/apps/api/src/modules/columns/service.ts
index 594baba6..6a29c9cc 100644
--- a/apps/api/src/modules/columns/service.ts
+++ b/apps/api/src/modules/columns/service.ts
@@ -7,6 +7,7 @@ import { getIssues } from '#modules/issues/service';
import { emitIssueEvents, issuePayloads } from '#modules/issues/webhook-payload';
import { emitWebhookEvents, subscribedWebhooks } from '#modules/webhooks/emit';
import { recordStatusChange } from '#modules/issues/status-history';
+import { hasUnfinishedStatusRuns, queueStatusRuns } from '#modules/agents/schedules/status-runs';
export interface ColumnRow {
id: number;
@@ -222,6 +223,12 @@ export async function deleteColumn(
if (!column || column.projectId !== projectId)
throw new HttpError(404, `Column ${columnId} not found`);
if (column.stateType === 'backlog') throw new HttpError(400, 'Backlog columns cannot be deleted');
+ if (await hasUnfinishedStatusRuns(columnId)) {
+ throw new HttpError(
+ 409,
+ 'Agent schedules of this column have runs in progress. End them or wait for them to finish first',
+ );
+ }
let target: ColumnRow | null = null;
if (opts.mode === 'move') {
@@ -269,6 +276,7 @@ export async function deleteColumn(
const moved = () => getIssues(movedIssueIds);
await emitIssueEvents(projectId, 'issue.updated', moved, actorUserId);
await emitIssueEvents(projectId, 'issue.state_changed', moved, actorUserId);
+ await queueStatusRuns(movedIssueIds, target.id, actorUserId);
} else {
await emitWebhookEvents(projectId, 'issue.deleted', async () => deletedPayloads, actorUserId);
}
diff --git a/apps/api/src/modules/issues/move.ts b/apps/api/src/modules/issues/move.ts
index 2219a8a7..b2c4e385 100644
--- a/apps/api/src/modules/issues/move.ts
+++ b/apps/api/src/modules/issues/move.ts
@@ -26,6 +26,7 @@ import { recordActivity, textSide } from './activity';
import { recordStatusChange } from './status-history';
import { recordCycleChange } from './cycle-history';
import { emitIssueEvent } from './webhook-payload';
+import { queueStatusRuns } from '#modules/agents/schedules/status-runs';
// Moves an issue, with its subtasks, to another project of the same team. Column,
// type, labels and custom fields belong to one project, so they are matched by name
@@ -232,6 +233,7 @@ export async function moveIssue(
if (p.id === issueId && p.parentId !== null)
await recordParentChange(p.id, p.parentId, null, actorUserId);
await emitIssueEvent('issue.updated', after, actorUserId);
+ await queueStatusRuns([p.id], p.newColumnId, actorUserId);
}
return (await getIssue(issueId))!;
}
diff --git a/apps/api/src/modules/issues/service.ts b/apps/api/src/modules/issues/service.ts
index af6709bd..dbbd831a 100644
--- a/apps/api/src/modules/issues/service.ts
+++ b/apps/api/src/modules/issues/service.ts
@@ -70,6 +70,7 @@ import { getInitiativeProjectId } from '#modules/initiatives/service';
import { cycleStatus, getCycleRef, type CycleStatus } from '#modules/cycles/service';
import { getMembership } from '#modules/members/service';
import { enqueueAgentRun } from '#modules/agents/core/run-queue';
+import { queueStatusRuns } from '#modules/agents/schedules/status-runs';
import { applySubtaskAutomation } from './automation';
import { assertWipLimit, columnAutoAssignee, wipLimitBreach } from '#modules/columns/service';
@@ -927,6 +928,7 @@ export async function createIssue(
// An issue created already delegated to an agent enqueues a run, the same as
// delegating one later does.
await enqueueDelegateRun(created, actorUserId);
+ await queueStatusRuns([issueId], input.columnId, actorUserId);
// An issue created already assigned to a member notifies them, the same as
// assigning one later does.
if (created.assigneeUserId) {
@@ -1106,6 +1108,7 @@ export async function updateIssue(
if (before.delegateUserId !== after.delegateUserId) await enqueueDelegateRun(after, actor);
if (before.columnId !== after.columnId) {
await emitIssueEvent('issue.state_changed', after, actor);
+ await queueStatusRuns([id], after.columnId, actorId(actor));
await applySubtaskAutomation(after, actor);
}
}
diff --git a/apps/api/src/modules/projects/__tests__/integration/projects.test.ts b/apps/api/src/modules/projects/__tests__/integration/projects.test.ts
index 984e3e48..a6c98791 100644
--- a/apps/api/src/modules/projects/__tests__/integration/projects.test.ts
+++ b/apps/api/src/modules/projects/__tests__/integration/projects.test.ts
@@ -533,6 +533,41 @@ describe('projects', () => {
expect(filters.conditions[0].values).toEqual([dstReview.id]);
});
+ it("points a copied status schedule at the copy's own column", async () => {
+ const { api } = await signUpClient();
+ await api.projects.post({ key: 'SRC', name: 'Source' });
+ const agent = (
+ await createAgent(api, 'SRC', { name: 'Bot', username: 'bot', kind: 'internal' })
+ ).data!.agent;
+ const started = (await viewOf(api, 'SRC')).data!.columns.find(
+ (c) => c.stateType === 'started',
+ )!;
+ await api.projects({ projectKey: 'SRC' })['agent-schedules'].post({
+ agentId: agent.id,
+ name: 'Analysis',
+ type: 'status',
+ columnId: started.id,
+ delaySec: 60,
+ });
+
+ await api.projects({ projectKey: 'SRC' }).copy.post({
+ key: 'DST',
+ name: 'Destination',
+ include: { schedules: true },
+ });
+
+ const dstStarted = (await viewOf(api, 'DST')).data!.columns.find(
+ (c) => c.name === started.name,
+ )!;
+ const copied = await api.projects({ projectKey: 'DST' })['agent-schedules'].get();
+ expect(copied.data!.items).toHaveLength(1);
+ expect(copied.data!.items[0]).toMatchObject({
+ type: 'status',
+ columnId: dstStarted.id,
+ delaySec: 60,
+ });
+ });
+
it("draws on the target team's roles, which the source team's do not reach", async () => {
const { api } = await signUpClient();
await api.projects.post({ key: 'SRC', name: 'Source' });
diff --git a/apps/api/src/modules/projects/copy.ts b/apps/api/src/modules/projects/copy.ts
index e119b691..bf5087f3 100644
--- a/apps/api/src/modules/projects/copy.ts
+++ b/apps/api/src/modules/projects/copy.ts
@@ -98,7 +98,8 @@ const DEFAULT_INCLUDE: CopyProjectInclude = {
// Resolves the selection and force-enables the dependencies each entity needs to be
// copied correctly. Views/actions remap the ids of states, types, labels and fields,
-// so those must be copied too; a schedule cannot exist without its agent.
+// so those must be copied too; a schedule cannot exist without its agent, and a status
+// schedule without its state.
function normalizeInclude(raw?: Partial<CopyProjectInclude>): CopyProjectInclude {
const inc: CopyProjectInclude = raw ? { ...ALL_FALSE, ...raw } : { ...DEFAULT_INCLUDE };
if (inc.customFields) inc.issueTypes = true;
@@ -113,7 +114,10 @@ function normalizeInclude(raw?: Partial<CopyProjectInclude>): CopyProjectInclude
inc.issueTypes = true;
inc.labels = true;
}
- if (inc.schedules) inc.agents = true;
+ if (inc.schedules) {
+ inc.agents = true;
+ inc.states = true;
+ }
return inc;
}
@@ -675,10 +679,13 @@ export async function copyProject(
agentId: s.agentId,
actorUserId: ownerId,
name: s.name,
+ type: s.type,
prompt: s.prompt,
cron: s.cron,
+ nextRunAt: s.cron === null ? null : nextCronRun(s.cron),
+ columnId: s.columnId === null ? null : maps.column.get(s.columnId)!,
+ delaySec: s.delaySec,
status: s.status,
- nextRunAt: nextCronRun(s.cron),
});
}
}
diff --git a/apps/web/messages/ar/dashboards.json b/apps/web/messages/ar/dashboards.json
index 2e050f4f..6757ffb5 100644
--- a/apps/web/messages/ar/dashboards.json
+++ b/apps/web/messages/ar/dashboards.json
@@ -198,7 +198,8 @@
"delegation": "شُغّل عند تفويض",
"field": "شُغّل عند تعيينه في حقل",
"manual": "شُغّل يدويًا",
- "schedule": "شُغّل حسب الجدولة"
+ "schedule": "شُغّل حسب الجدولة",
+ "status": "شُغّل عند تغيير حالة"
}
},
"agentHealth": {
diff --git a/apps/web/messages/ar/settings.json b/apps/web/messages/ar/settings.json
index 5205ac13..c4af815e 100644
--- a/apps/web/messages/ar/settings.json
+++ b/apps/web/messages/ar/settings.json
@@ -12,6 +12,21 @@
"task": "المهمة",
"taskPlaceholder": "راجع المهام المفتوحة وحدّث اللي محتاج انتباه.",
"taskHint": "الوكيل بيستلم المهمة دي في كل تشغيل.",
+ "type": "التشغيل",
+ "typeCron": "حسب جدولة",
+ "typeStatus": "لما مهمة تدخل حالة",
+ "taskOptional": "المهمة (اختياري)",
+ "statusTaskPlaceholder": "اكتب معايير القبول في وصف المهمة.",
+ "statusTaskHint": "الوكيل بيستلم المهمة والحالة اللي دخلتها. ضيف المطلوب يعمله بيها.",
+ "column": "الحالة",
+ "selectColumn": "اختيار حالة",
+ "delay": "استنى قبل ما تبدأ",
+ "minutes": "دقيقة",
+ "statusHint": "بيشتغل على كل مهمة بتتنقل للحالة دي أو بتتعمل فيها. لو المهمة خرجت من الحالة وقت الانتظار، التشغيل بيتلغي.",
+ "entersColumn": "المهمة بتدخل {column}",
+ "startsAfter": "بيبدأ بعد {minutes} دقيقة",
+ "startsAtOnce": "بيبدأ على طول",
+ "nextRunOnStatus": "لما مهمة تدخل الحالة",
"externalAgentHint": "الوكيل ده بيشتغل على منفّذ (runner) خاص بيه. المهمة المجدولة بتستنى في الطابور لحد ما المنفّذ ده يبقى شغال.",
"scheduleUtc": "الجدولة (UTC)",
"schedule": "الجدولة",
diff --git a/apps/web/messages/en/dashboards.json b/apps/web/messages/en/dashboards.json
index 69b52976..f27247f0 100644
--- a/apps/web/messages/en/dashboards.json
+++ b/apps/web/messages/en/dashboards.json
@@ -198,7 +198,8 @@
"delegation": "ran on delegation of",
"field": "ran on a field of",
"manual": "ran manually",
- "schedule": "ran on schedule"
+ "schedule": "ran on schedule",
+ "status": "ran on state change of"
}
},
"agentHealth": {
diff --git a/apps/web/messages/en/settings.json b/apps/web/messages/en/settings.json
index c199a8a1..aab32fd0 100644
--- a/apps/web/messages/en/settings.json
+++ b/apps/web/messages/en/settings.json
@@ -12,6 +12,21 @@
"task": "Task",
"taskPlaceholder": "Review open tasks and update anything that needs attention.",
"taskHint": "The agent receives this task on every run.",
+ "type": "Runs",
+ "typeCron": "On a schedule",
+ "typeStatus": "When an issue enters a state",
+ "taskOptional": "Task (optional)",
+ "statusTaskPlaceholder": "Write the acceptance criteria into the issue description.",
+ "statusTaskHint": "The agent gets the issue and the state it entered. Add what to do with it.",
+ "column": "State",
+ "selectColumn": "Select a state",
+ "delay": "Wait before starting",
+ "minutes": "min",
+ "statusHint": "Starts on each issue moved to this state or created in it. An issue that leaves the state during the wait cancels its run.",
+ "entersColumn": "Issue enters {column}",
+ "startsAfter": "Starts after {minutes} min",
+ "startsAtOnce": "Starts at once",
+ "nextRunOnStatus": "When an issue enters the state",
"externalAgentHint": "This agent runs on its own runner. A scheduled task waits in the queue until that runner is online.",
"scheduleUtc": "Schedule (UTC)",
"schedule": "Schedule",
diff --git a/apps/web/messages/es-ES/dashboards.json b/apps/web/messages/es-ES/dashboards.json
index 94a7e9e4..508abf5d 100644
--- a/apps/web/messages/es-ES/dashboards.json
+++ b/apps/web/messages/es-ES/dashboards.json
@@ -198,7 +198,8 @@
"delegation": "se ha ejecutado por una delegación de",
"field": "se ha ejecutado por un campo de",
"manual": "se ha ejecutado manualmente",
- "schedule": "se ha ejecutado por programado"
+ "schedule": "se ha ejecutado por programado",
+ "status": "se ha ejecutado por un cambio de estado de"
}
},
"agentHealth": {
diff --git a/apps/web/messages/es-ES/settings.json b/apps/web/messages/es-ES/settings.json
index b45c2279..f5bd95b9 100644
--- a/apps/web/messages/es-ES/settings.json
+++ b/apps/web/messages/es-ES/settings.json
@@ -12,6 +12,21 @@
"task": "Tarea",
"taskPlaceholder": "Revisa las tareas abiertas y actualiza todo lo que necesite atención.",
"taskHint": "El agente recibe esta tarea en cada ejecución.",
+ "type": "Se ejecuta",
+ "typeCron": "Según una programación",
+ "typeStatus": "Cuando un ticket entra en un estado",
+ "taskOptional": "Tarea (opcional)",
+ "statusTaskPlaceholder": "Escribe los criterios de aceptación en la descripción del ticket.",
+ "statusTaskHint": "El agente recibe el ticket y el estado en el que entró. Añade qué hacer con él.",
+ "column": "Estado",
+ "selectColumn": "Seleccionar un estado",
+ "delay": "Esperar antes de empezar",
+ "minutes": "min",
+ "statusHint": "Se inicia con cada ticket movido a este estado o creado en él. Si el ticket sale del estado durante la espera, se cancela su ejecución.",
+ "entersColumn": "El ticket entra en {column}",
+ "startsAfter": "Empieza tras {minutes} min",
+ "startsAtOnce": "Empieza al momento",
+ "nextRunOnStatus": "Cuando un ticket entra en el estado",
"externalAgentHint": "Este agente funciona en su propio ejecutor. Una tarea programada espera en la cola hasta que ese ejecutor esté en línea.",
"scheduleUtc": "Programación (UTC)",
"schedule": "Programación",
diff --git a/apps/web/messages/fr/dashboards.json b/apps/web/messages/fr/dashboards.json
index e2afa772..a89ecaa2 100644
--- a/apps/web/messages/fr/dashboards.json
+++ b/apps/web/messages/fr/dashboards.json
@@ -198,7 +198,8 @@
"delegation": "lancée sur délégation de",
"field": "lancée sur un champ de",
"manual": "lancée manuellement",
- "schedule": "lancée par planification"
+ "schedule": "lancée par planification",
+ "status": "lancée sur changement d'état de"
}
},
"agentHealth": {
diff --git a/apps/web/messages/fr/settings.json b/apps/web/messages/fr/settings.json
index b84fd638..c028aec4 100644
--- a/apps/web/messages/fr/settings.json
+++ b/apps/web/messages/fr/settings.json
@@ -12,6 +12,21 @@
"task": "Tâche",
"taskPlaceholder": "Passer en revue les tâches ouvertes et mettre à jour ce qui nécessite de l'attention.",
"taskHint": "L'agent reçoit cette tâche à chaque exécution.",
+ "type": "Exécution",
+ "typeCron": "Selon une planification",
+ "typeStatus": "Quand un ticket entre dans un état",
+ "taskOptional": "Tâche (facultatif)",
+ "statusTaskPlaceholder": "Rédige les critères d'acceptation dans la description du ticket.",
+ "statusTaskHint": "L'agent reçoit le ticket et l'état dans lequel il est entré. Ajoute ce qu'il doit en faire.",
+ "column": "État",
+ "selectColumn": "Sélectionner un état",
+ "delay": "Attendre avant de démarrer",
+ "minutes": "min",
+ "statusHint": "Démarre pour chaque ticket déplacé dans cet état ou créé dans celui-ci. Si le ticket quitte l'état pendant l'attente, son exécution est annulée.",
+ "entersColumn": "Le ticket entre dans {column}",
+ "startsAfter": "Démarre après {minutes} min",
+ "startsAtOnce": "Démarre tout de suite",
+ "nextRunOnStatus": "Quand un ticket entre dans l'état",
"externalAgentHint": "Cet agent s'exécute sur son propre runner. Une tâche planifiée attend dans la file jusqu'à ce que ce runner soit en ligne.",
"scheduleUtc": "Planification (UTC)",
"schedule": "Planification",
diff --git a/apps/web/messages/id/dashboards.json b/apps/web/messages/id/dashboards.json
index 234e5406..945ccfe7 100644
--- a/apps/web/messages/id/dashboards.json
+++ b/apps/web/messages/id/dashboards.json
@@ -198,7 +198,8 @@
"delegation": "berjalan saat pendelegasian",
"field": "berjalan pada bidang",
"manual": "dijalankan secara manual",
- "schedule": "berjalan sesuai jadwal"
+ "schedule": "berjalan sesuai jadwal",
+ "status": "berjalan saat perubahan status"
}
},
"agentHealth": {
diff --git a/apps/web/messages/id/settings.json b/apps/web/messages/id/settings.json
index 83734582..31714475 100644
--- a/apps/web/messages/id/settings.json
+++ b/apps/web/messages/id/settings.json
@@ -12,6 +12,21 @@
"task": "Tugas",
"taskPlaceholder": "Tinjau tugas yang terbuka dan perbarui apa pun yang perlu diperhatikan.",
"taskHint": "Agen menerima tugas ini setiap kali dijalankan.",
+ "type": "Berjalan",
+ "typeCron": "Sesuai jadwal",
+ "typeStatus": "Saat issue masuk ke status",
+ "taskOptional": "Tugas (opsional)",
+ "statusTaskPlaceholder": "Tulis kriteria penerimaan di deskripsi issue.",
+ "statusTaskHint": "Agen menerima issue dan status yang dimasukinya. Tambahkan apa yang harus dilakukan.",
+ "column": "Status",
+ "selectColumn": "Pilih status",
+ "delay": "Tunggu sebelum memulai",
+ "minutes": "mnt",
+ "statusHint": "Berjalan untuk setiap issue yang dipindahkan ke status ini atau dibuat di dalamnya. Jika issue keluar dari status selama menunggu, jalannya dibatalkan.",
+ "entersColumn": "Issue masuk ke {column}",
+ "startsAfter": "Mulai setelah {minutes} mnt",
+ "startsAtOnce": "Langsung mulai",
+ "nextRunOnStatus": "Saat issue masuk ke status",
"externalAgentHint": "Agen ini berjalan di runner sendiri. Tugas terjadwal menunggu dalam antrean hingga runner tersebut online.",
"scheduleUtc": "Jadwal (UTC)",
"schedule": "Jadwal",
diff --git a/apps/web/messages/pt-BR/dashboards.json b/apps/web/messages/pt-BR/dashboards.json
index 61093581..5049a380 100644
--- a/apps/web/messages/pt-BR/dashboards.json
+++ b/apps/web/messages/pt-BR/dashboards.json
@@ -198,7 +198,8 @@
"delegation": "executou por delegação de",
"field": "executou por um campo de",
"manual": "executou manualmente",
- "schedule": "executou por agendamento"
+ "schedule": "executou por agendamento",
+ "status": "executou por mudança de estado de"
}
},
"agentHealth": {
diff --git a/apps/web/messages/pt-BR/settings.json b/apps/web/messages/pt-BR/settings.json
index 38087b5e..6fb30bf3 100644
--- a/apps/web/messages/pt-BR/settings.json
+++ b/apps/web/messages/pt-BR/settings.json
@@ -12,6 +12,21 @@
"task": "Tarefa",
"taskPlaceholder": "Revise as tarefas abertas e atualize o que precisar de atenção.",
"taskHint": "O agente recebe esta tarefa em cada execução.",
+ "type": "Execução",
+ "typeCron": "Por agendamento",
+ "typeStatus": "Quando uma issue entra em um estado",
+ "taskOptional": "Tarefa (opcional)",
+ "statusTaskPlaceholder": "Escreva os critérios de aceitação na descrição da issue.",
+ "statusTaskHint": "O agente recebe a issue e o estado em que ela entrou. Diga o que fazer com ela.",
+ "column": "Estado",
+ "selectColumn": "Selecionar um estado",
+ "delay": "Esperar antes de começar",
+ "minutes": "min",
+ "statusHint": "Inicia em cada issue movida para este estado ou criada nele. Se a issue sair do estado durante a espera, a execução é cancelada.",
+ "entersColumn": "Issue entra em {column}",
+ "startsAfter": "Começa após {minutes} min",
+ "startsAtOnce": "Começa na hora",
+ "nextRunOnStatus": "Quando uma issue entra no estado",
"externalAgentHint": "Este agente roda no seu próprio runner. Uma tarefa agendada espera na fila até o runner estar online.",
"scheduleUtc": "Horário (UTC)",
"schedule": "Horário",
diff --git a/apps/web/messages/ru/dashboards.json b/apps/web/messages/ru/dashboards.json
index bb920b77..b6602268 100644
--- a/apps/web/messages/ru/dashboards.json
+++ b/apps/web/messages/ru/dashboards.json
@@ -198,7 +198,8 @@
"delegation": "запущен делегированием",
"field": "запущен полем в",
"manual": "запущен вручную",
- "schedule": "запущен по расписанию"
+ "schedule": "запущен по расписанию",
+ "status": "запущен сменой статуса"
}
},
"agentHealth": {
diff --git a/apps/web/messages/ru/settings.json b/apps/web/messages/ru/settings.json
index c334f7a5..eea0fabd 100644
--- a/apps/web/messages/ru/settings.json
+++ b/apps/web/messages/ru/settings.json
@@ -12,6 +12,21 @@
"task": "Задача",
"taskPlaceholder": "Просмотрите открытые задачи и обновите то, что требует внимания.",
"taskHint": "Агент получает эту задачу на каждом запуске.",
+ "type": "Запуск",
+ "typeCron": "По расписанию",
+ "typeStatus": "Когда задача попадает в статус",
+ "taskOptional": "Задача (необязательно)",
+ "statusTaskPlaceholder": "Опиши критерии приёмки в описании задачи.",
+ "statusTaskHint": "Агент получает задачу и статус, в который она попала. Добавь, что с ней сделать.",
+ "column": "Статус",
+ "selectColumn": "Выберите статус",
+ "delay": "Пауза перед стартом",
+ "minutes": "мин",
+ "statusHint": "Запускается на каждой задаче, перенесённой в этот статус или созданной в нём. Если задача уйдёт из статуса во время паузы, запуск отменится.",
+ "entersColumn": "Задача попадает в {column}",
+ "startsAfter": "Старт через {minutes} мин",
+ "startsAtOnce": "Старт сразу",
+ "nextRunOnStatus": "Когда задача попадёт в статус",
"externalAgentHint": "Этот агент выполняется своим раннером. Задача по расписанию ждёт в очереди, пока раннер не в сети.",
"scheduleUtc": "Расписание (UTC)",
"schedule": "Расписание",
diff --git a/apps/web/messages/uk/dashboards.json b/apps/web/messages/uk/dashboards.json
index ea7f2960..6d8c2341 100644
--- a/apps/web/messages/uk/dashboards.json
+++ b/apps/web/messages/uk/dashboards.json
@@ -198,7 +198,8 @@
"delegation": "запущений делегуванням",
"field": "запущений полем у",
"manual": "запущений вручну",
- "schedule": "запущений за розкладом"
+ "schedule": "запущений за розкладом",
+ "status": "запущений зміною статусу"
}
},
"agentHealth": {
diff --git a/apps/web/messages/uk/settings.json b/apps/web/messages/uk/settings.json
index 4acfcd32..7f581222 100644
--- a/apps/web/messages/uk/settings.json
+++ b/apps/web/messages/uk/settings.json
@@ -12,6 +12,21 @@
"task": "Задача",
"taskPlaceholder": "Перегляньте відкриті задачі та оновіть те, що потребує уваги.",
"taskHint": "Агент отримує цю задачу на кожному запуску.",
+ "type": "Запуск",
+ "typeCron": "За розкладом",
+ "typeStatus": "Коли задача потрапляє в статус",
+ "taskOptional": "Задача (необов'язково)",
+ "statusTaskPlaceholder": "Опиши критерії приймання в описі задачі.",
+ "statusTaskHint": "Агент отримує задачу і статус, у який вона потрапила. Додай, що з нею зробити.",
+ "column": "Статус",
+ "selectColumn": "Виберіть статус",
+ "delay": "Пауза перед стартом",
+ "minutes": "хв",
+ "statusHint": "Запускається на кожній задачі, перенесеній у цей статус або створеній у ньому. Якщо задача вийде зі статусу під час паузи, запуск скасується.",
+ "entersColumn": "Задача потрапляє в {column}",
+ "startsAfter": "Старт через {minutes} хв",
+ "startsAtOnce": "Старт одразу",
+ "nextRunOnStatus": "Коли задача потрапить у статус",
"externalAgentHint": "Цей агент виконується власним раннером. Задача за розкладом чекає в черзі, поки раннер не в мережі.",
"scheduleUtc": "Розклад (UTC)",
"schedule": "Розклад",
diff --git a/apps/web/messages/zh-CN/dashboards.json b/apps/web/messages/zh-CN/dashboards.json
index 23d373ea..696254d8 100644
--- a/apps/web/messages/zh-CN/dashboards.json
+++ b/apps/web/messages/zh-CN/dashboards.json
@@ -198,7 +198,8 @@
"delegation": "因以下工作项的委派而运行:",
"field": "因以下工作项的字段而运行:",
"manual": "手动运行",
- "schedule": "按定时任务运行"
+ "schedule": "按定时任务运行",
+ "status": "因以下工作项的状态变更而运行:"
}
},
"agentHealth": {
diff --git a/apps/web/messages/zh-CN/settings.json b/apps/web/messages/zh-CN/settings.json
index b3ce57fe..16b134e4 100644
--- a/apps/web/messages/zh-CN/settings.json
+++ b/apps/web/messages/zh-CN/settings.json
@@ -12,6 +12,21 @@
"task": "任务",
"taskPlaceholder": "检查未关闭的工作项并更新需要处理的内容。",
"taskHint": "代理每次运行时都会收到此任务。",
+ "type": "运行方式",
+ "typeCron": "按定时",
+ "typeStatus": "工作项进入某状态时",
+ "taskOptional": "任务(可选)",
+ "statusTaskPlaceholder": "在工作项描述中写下验收标准。",
+ "statusTaskHint": "代理会收到该工作项及其进入的状态。可补充要对它做什么。",
+ "column": "状态",
+ "selectColumn": "选择状态",
+ "delay": "启动前等待",
+ "minutes": "分钟",
+ "statusHint": "每个移入该状态或在其中创建的工作项都会启动一次运行。若工作项在等待期间离开该状态,运行将被取消。",
+ "entersColumn": "工作项进入 {column}",
+ "startsAfter": "{minutes} 分钟后启动",
+ "startsAtOnce": "立即启动",
+ "nextRunOnStatus": "工作项进入该状态时",
"externalAgentHint": "该智能体由自己的运行器执行。计划任务会在队列中等待,直到运行器上线。",
"scheduleUtc": "运行时间(UTC)",
"schedule": "运行时间",
diff --git a/apps/web/src/components/layout/CopyProjectOptions.tsx b/apps/web/src/components/layout/CopyProjectOptions.tsx
index 418be161..336ec681 100644
--- a/apps/web/src/components/layout/CopyProjectOptions.tsx
+++ b/apps/web/src/components/layout/CopyProjectOptions.tsx
@@ -5,7 +5,8 @@ import { Checkbox } from '@/components/ui/checkbox';
export type CopyInclude = Record<CopyProjectIncludeKey, boolean>;
// What each entity needs copied alongside it. Mirrors the API's normalizeInclude: a
-// view/action remaps state/type/label/field ids, and a schedule belongs to an agent.
+// view/action remaps state/type/label/field ids, and a schedule belongs to an agent and
+// a status schedule to a state.
// Checking a child enables its requirements; unchecking a requirement disables the
// children that need it.
const REQUIRES: Record<CopyProjectIncludeKey, CopyProjectIncludeKey[]> = {
@@ -20,7 +21,7 @@ const REQUIRES: Record<CopyProjectIncludeKey, CopyProjectIncludeKey[]> = {
configuration: [],
webhooks: [],
agents: [],
- schedules: ['agents'],
+ schedules: ['agents', 'states'],
};
// The name of a group, and of each entity, are messages under `newProject`.
diff --git a/apps/web/src/features/settings/components/schedules/SettingsScheduleDialog.tsx b/apps/web/src/features/settings/components/schedules/SettingsScheduleDialog.tsx
index 9a69da23..73362a29 100644
--- a/apps/web/src/features/settings/components/schedules/SettingsScheduleDialog.tsx
+++ b/apps/web/src/features/settings/components/schedules/SettingsScheduleDialog.tsx
@@ -1,12 +1,14 @@
import { useState } from 'react';
-import { Terminal } from 'lucide-react';
import type { AiAgent } from '@/lib/api/endpoints/agents';
-import type { AgentSchedule, AgentScheduleInput } from '@/lib/api/endpoints/agentSchedules';
-import { AgentRunnerStatus } from '@/components/common/agent-chat/AgentRunnerStatus';
+import type { Column } from '@/lib/api/endpoints/columns';
+import type {
+ AgentSchedule,
+ AgentScheduleInput,
+ AgentScheduleType,
+} from '@/lib/api/endpoints/agentSchedules';
import Modal from '@/components/common/overlay/Modal';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
-import { Label } from '@/components/ui/label';
import {
Select,
SelectContent,
@@ -14,14 +16,20 @@ import {
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
-import { Textarea } from '@/components/ui/textarea';
+import { delaySecFromMinutes } from '@/utils/runDelay';
import { parseScheduleInput } from '../../utils/cronSchedule';
+import { SettingsScheduleField } from './SettingsScheduleField';
import { SettingsScheduleInput } from './SettingsScheduleInput';
+import { SettingsScheduleRunnerHint } from './SettingsScheduleRunnerHint';
+import { SettingsScheduleStatusFields } from './SettingsScheduleStatusFields';
+import { SettingsScheduleTaskField } from './SettingsScheduleTaskField';
+import { SettingsScheduleTypeField } from './SettingsScheduleTypeField';
import { useTranslations } from 'next-intl';
export function SettingsScheduleDialog({
projectKey,
agents,
+ columns,
initial,
saving,
onSave,
@@ -29,6 +37,7 @@ export function SettingsScheduleDialog({
}: {
projectKey: string;
agents: AiAgent[];
+ columns: Column[];
initial?: AgentSchedule;
saving: boolean;
onSave: (value: AgentScheduleInput) => Promise<void>;
@@ -39,28 +48,41 @@ export function SettingsScheduleDialog({
const tAgents = useTranslations('teams.agents');
const [agentId, setAgentId] = useState(String(initial?.agentId ?? agents[0]?.id ?? ''));
const [name, setName] = useState(initial?.name ?? '');
+ const [type, setType] = useState<AgentScheduleType>(initial?.type ?? 'cron');
const [prompt, setPrompt] = useState(initial?.prompt ?? '');
const [scheduleInput, setScheduleInput] = useState(initial?.cron ?? 'Every day at 9:00 AM');
+ const [columnId, setColumnId] = useState(String(initial?.columnId ?? columns[0]?.id ?? ''));
+ const [delayMin, setDelayMin] = useState(String(Math.round((initial?.delaySec ?? 0) / 60)));
const selectedAgent = agents.find((a) => String(a.id) === agentId) ?? null;
+ const isStatus = type === 'status';
const parsedSchedule = parseScheduleInput(scheduleInput);
const isValid =
Number(agentId) > 0 &&
name.trim().length > 0 &&
name.trim().length <= 120 &&
- prompt.trim().length > 0 &&
prompt.trim().length <= 20_000 &&
- scheduleInput.length <= 120 &&
- parsedSchedule.ok;
+ (isStatus
+ ? Number(columnId) > 0
+ : prompt.trim().length > 0 && scheduleInput.length <= 120 && parsedSchedule.ok);
async function submit() {
- if (!isValid || !parsedSchedule.ok) return;
- await onSave({
+ if (!isValid) return;
+ const value: AgentScheduleInput = {
agentId: Number(agentId),
name: name.trim(),
prompt: prompt.trim(),
- cron: parsedSchedule.cron,
status: initial?.status ?? 'active',
- });
+ ...(initial ? {} : { type }),
+ };
+ if (isStatus) {
+ await onSave({
+ ...value,
+ columnId: Number(columnId),
+ delaySec: delaySecFromMinutes(delayMin),
+ });
+ } else if (parsedSchedule.ok) {
+ await onSave({ ...value, cron: parsedSchedule.cron });
+ }
}
const actionLabel = initial ? t('save') : t('create');
@@ -82,7 +104,7 @@ export function SettingsScheduleDialog({
}}
>
<div className="grid gap-4 sm:grid-cols-2">
- <Field htmlFor="schedule-name" label={tCommon('name')}>
+ <SettingsScheduleField htmlFor="schedule-name" label={tCommon('name')}>
<Input
id="schedule-name"
autoFocus
@@ -92,8 +114,8 @@ export function SettingsScheduleDialog({
onChange={(event) => setName(event.target.value)}
placeholder={t('namePlaceholder')}
/>
- </Field>
- <Field htmlFor="schedule-agent" label={t('agent')}>
+ </SettingsScheduleField>
+ <SettingsScheduleField htmlFor="schedule-agent" label={t('agent')}>
<Select value={agentId} onValueChange={setAgentId}>
<SelectTrigger id="schedule-agent" className="w-full" aria-required="true">
<SelectValue placeholder={t('selectAgent')} />
@@ -109,40 +131,33 @@ export function SettingsScheduleDialog({
))}
</SelectContent>
</Select>
- </Field>
+ </SettingsScheduleField>
</div>
- {selectedAgent?.kind === 'external' && (
- <div className="flex items-start gap-2.5 rounded-md border border-border/60 bg-muted/30 px-3 py-2.5">
- <Terminal className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
- <div className="min-w-0 flex-1 space-y-1">
- <p className="text-xs text-muted-foreground">{t('externalAgentHint')}</p>
- <AgentRunnerStatus agent={selectedAgent} />
- </div>
- </div>
- )}
+ {selectedAgent?.kind === 'external' && <SettingsScheduleRunnerHint agent={selectedAgent} />}
- <Field htmlFor="schedule-task" label={t('task')}>
- <Textarea
- id="schedule-task"
- required
- maxLength={20_000}
- value={prompt}
- onChange={(event) => setPrompt(event.target.value)}
- placeholder={t('taskPlaceholder')}
- className="min-h-32 resize-y"
- />
- <p className="text-xs text-muted-foreground">{t('taskHint')}</p>
- </Field>
+ {!initial && <SettingsScheduleTypeField value={type} onChange={setType} />}
+
+ <SettingsScheduleTaskField optional={isStatus} value={prompt} onChange={setPrompt} />
<div className="border-t border-border/50 pt-4">
- <Field htmlFor="schedule-input" label={t('scheduleUtc')}>
- <SettingsScheduleInput
- id="schedule-input"
- value={scheduleInput}
- onChange={setScheduleInput}
+ {isStatus ? (
+ <SettingsScheduleStatusFields
+ columns={columns}
+ columnId={columnId}
+ onColumnChange={setColumnId}
+ delayMin={delayMin}
+ onDelayChange={setDelayMin}
/>
- </Field>
+ ) : (
+ <SettingsScheduleField htmlFor="schedule-input" label={t('scheduleUtc')}>
+ <SettingsScheduleInput
+ id="schedule-input"
+ value={scheduleInput}
+ onChange={setScheduleInput}
+ />
+ </SettingsScheduleField>
+ )}
</div>
<div className="flex justify-end gap-2 border-t border-border/50 pt-4">
@@ -157,20 +172,3 @@ export function SettingsScheduleDialog({
</Modal>
);
}
-
-function Field({
- htmlFor,
- label,
- children,
-}: {
- htmlFor: string;
- label: string;
- children: React.ReactNode;
-}) {
- return (
- <div className="space-y-1.5">
- <Label htmlFor={htmlFor}>{label}</Label>
- {children}
- </div>
- );
-}
diff --git a/apps/web/src/features/settings/components/schedules/SettingsScheduleField.tsx b/apps/web/src/features/settings/components/schedules/SettingsScheduleField.tsx
new file mode 100644
index 00000000..459c9b2a
--- /dev/null
+++ b/apps/web/src/features/settings/components/schedules/SettingsScheduleField.tsx
@@ -0,0 +1,18 @@
+import { Label } from '@/components/ui/label';
+
+export function SettingsScheduleField({
+ htmlFor,
+ label,
+ children,
+}: {
+ htmlFor: string;
+ label: string;
+ children: React.ReactNode;
+}) {
+ return (
+ <div className="space-y-1.5">
+ <Label htmlFor={htmlFor}>{label}</Label>
+ {children}
+ </div>
+ );
+}
diff --git a/apps/web/src/features/settings/components/schedules/SettingsScheduleRow.tsx b/apps/web/src/features/settings/components/schedules/SettingsScheduleRow.tsx
index 79d79eec..42142af9 100644
--- a/apps/web/src/features/settings/components/schedules/SettingsScheduleRow.tsx
+++ b/apps/web/src/features/settings/components/schedules/SettingsScheduleRow.tsx
@@ -26,11 +26,13 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip
import { cn } from '@/lib/utils';
import SettingsIconButton from '../SettingsIconButton';
import { useSettingsCan } from '../../context/settingsPermission';
-import { formatUtc, parseScheduleInput } from '../../utils/cronSchedule';
+import { formatUtc } from '../../utils/cronSchedule';
+import { SettingsScheduleWhen } from './SettingsScheduleWhen';
import { useTranslations } from 'next-intl';
export function SettingsScheduleRow({
schedule,
+ columnName,
running,
onToggle,
onRun,
@@ -40,6 +42,7 @@ export function SettingsScheduleRow({
onDelete,
}: {
schedule: AgentSchedule;
+ columnName: string | null;
running: boolean;
onToggle: () => void;
onRun: () => void;
@@ -50,8 +53,6 @@ export function SettingsScheduleRow({
}) {
const t = useTranslations('settings.schedules');
const can = useSettingsCan();
- const parsedSchedule = parseScheduleInput(schedule.cron);
- const scheduleDescription = parsedSchedule.ok ? parsedSchedule.description : schedule.cron;
return (
<TableRow className="group/item cursor-pointer" onClick={onHistory}>
<TableCell className="px-3 py-4 align-top whitespace-normal">
@@ -60,28 +61,30 @@ export function SettingsScheduleRow({
className={cn('mt-[7px] size-2 shrink-0 rounded-full', statusDotClass(schedule.status))}
title={schedule.status === 'active' ? t('statusActive') : t('statusPaused')}
/>
- <Popover>
- <Tooltip>
- <TooltipTrigger asChild>
- <PopoverTrigger asChild>
- <Button
- type="button"
- variant="ghost"
- size="icon"
- className="size-7 shrink-0 text-muted-foreground hover:text-foreground"
- onClick={(e) => e.stopPropagation()}
- >
- <MessageSquareText className="size-4" />
- </Button>
- </PopoverTrigger>
- </TooltipTrigger>
- <TooltipContent>{t('viewTask')}</TooltipContent>
- </Tooltip>
- <PopoverContent align="start" className="w-80">
- <p className="text-xs font-medium text-muted-foreground">{t('task')}</p>
- <p className="mt-1.5 text-sm whitespace-pre-wrap">{schedule.prompt}</p>
- </PopoverContent>
- </Popover>
+ {schedule.prompt && (
+ <Popover>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <PopoverTrigger asChild>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="size-7 shrink-0 text-muted-foreground hover:text-foreground"
+ onClick={(e) => e.stopPropagation()}
+ >
+ <MessageSquareText className="size-4" />
+ </Button>
+ </PopoverTrigger>
+ </TooltipTrigger>
+ <TooltipContent>{t('viewTask')}</TooltipContent>
+ </Tooltip>
+ <PopoverContent align="start" className="w-80">
+ <p className="text-xs font-medium text-muted-foreground">{t('task')}</p>
+ <p className="mt-1.5 text-sm whitespace-pre-wrap">{schedule.prompt}</p>
+ </PopoverContent>
+ </Popover>
+ )}
<div className="flex min-w-0 flex-col gap-0.5 pt-1">
<span className="truncate text-sm font-medium">{schedule.name}</span>
<span className="flex min-w-0 items-center gap-1 text-xs text-muted-foreground">
@@ -92,13 +95,16 @@ export function SettingsScheduleRow({
</div>
</TableCell>
<TableCell className="px-3 py-4 align-top whitespace-normal">
- <p className="text-sm" title={schedule.cron}>
- {scheduleDescription}
- </p>
- <p className="mt-1 text-xs text-muted-foreground">UTC</p>
+ <SettingsScheduleWhen schedule={schedule} columnName={columnName} />
</TableCell>
<TableCell className="px-3 py-4 align-top text-sm whitespace-nowrap tabular-nums">
- {formatUtc(schedule.nextRunAt)}
+ {schedule.nextRunAt ? (
+ formatUtc(schedule.nextRunAt)
+ ) : (
+ <span className="text-xs whitespace-normal text-muted-foreground">
+ {t('nextRunOnStatus')}
+ </span>
+ )}
</TableCell>
<TableCell className="px-3 py-4 align-top whitespace-normal">
{schedule.lastRunStatus ? (
@@ -153,7 +159,7 @@ export function SettingsScheduleRow({
<TooltipContent>{t('moreActions')}</TooltipContent>
</Tooltip>
<DropdownMenuContent align="end">
- {can('edit') && (
+ {can('edit') && schedule.type === 'cron' && (
<DropdownMenuItem
className="min-h-11 sm:min-h-8"
disabled={running}
diff --git a/apps/web/src/features/settings/components/schedules/SettingsScheduleRunnerHint.tsx b/apps/web/src/features/settings/components/schedules/SettingsScheduleRunnerHint.tsx
new file mode 100644
index 00000000..ebc3b5ee
--- /dev/null
+++ b/apps/web/src/features/settings/components/schedules/SettingsScheduleRunnerHint.tsx
@@ -0,0 +1,17 @@
+import { Terminal } from 'lucide-react';
+import type { AiAgent } from '@/lib/api/endpoints/agents';
+import { AgentRunnerStatus } from '@/components/common/agent-chat/AgentRunnerStatus';
+import { useTranslations } from 'next-intl';
+
+export function SettingsScheduleRunnerHint({ agent }: { agent: AiAgent }) {
+ const t = useTranslations('settings.schedules');
+ return (
+ <div className="flex items-start gap-2.5 rounded-md border border-border/60 bg-muted/30 px-3 py-2.5">
+ <Terminal className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
+ <div className="min-w-0 flex-1 space-y-1">
+ <p className="text-xs text-muted-foreground">{t('externalAgentHint')}</p>
+ <AgentRunnerStatus agent={agent} />
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/settings/components/schedules/SettingsScheduleRunsSheet.tsx b/apps/web/src/features/settings/components/schedules/SettingsScheduleRunsSheet.tsx
index cc0f2043..24491501 100644
--- a/apps/web/src/features/settings/components/schedules/SettingsScheduleRunsSheet.tsx
+++ b/apps/web/src/features/settings/components/schedules/SettingsScheduleRunsSheet.tsx
@@ -21,10 +21,12 @@ import { useTranslations } from 'next-intl';
export function SettingsScheduleRunsSheet({
projectKey,
schedule,
+ columnName,
onClose,
}: {
projectKey: string;
schedule: AgentSchedule | null;
+ columnName: string | null;
onClose: () => void;
}) {
const t = useTranslations('settings.schedules');
@@ -33,8 +35,14 @@ export function SettingsScheduleRunsSheet({
const cancelRuns = useCancelAgentScheduleRuns(projectKey);
const canCancel = can('edit') && schedule?.canTrigger === true;
const runs = query.data ?? [];
- const parsed = schedule ? parseScheduleInput(schedule.cron) : null;
- const cron = parsed?.ok ? parsed.description : (schedule?.cron ?? '');
+ const parsed = schedule?.cron ? parseScheduleInput(schedule.cron) : null;
+ const when = parsed?.ok
+ ? parsed.description
+ : (schedule?.cron ?? t('entersColumn', { column: columnName ?? '' }));
+ const delayMin = Math.round((schedule?.delaySec ?? 0) / 60);
+ let nextRun = t('startsAtOnce');
+ if (schedule?.nextRunAt) nextRun = `${t('nextRun')}: ${formatUtc(schedule.nextRunAt)}`;
+ else if (delayMin > 0) nextRun = t('startsAfter', { minutes: delayMin });
function cancel(runId?: number) {
if (schedule) cancelRuns.mutate({ scheduleId: schedule.id, runId });
@@ -72,11 +80,9 @@ export function SettingsScheduleRunsSheet({
<SheetTitle className="truncate text-base">{schedule?.name}</SheetTitle>
</div>
<SheetDescription className="flex flex-wrap items-center gap-x-2 text-xs">
- <span>{cron}</span>
+ <span>{when}</span>
<span>·</span>
- <span className="tabular-nums">
- {t('nextRun')}: {schedule ? formatUtc(schedule.nextRunAt) : ''}
- </span>
+ <span className="tabular-nums">{nextRun}</span>
</SheetDescription>
</SheetHeader>
<div className="min-h-0 flex-1 overflow-y-auto">
diff --git a/apps/web/src/features/settings/components/schedules/SettingsScheduleStatusFields.tsx b/apps/web/src/features/settings/components/schedules/SettingsScheduleStatusFields.tsx
new file mode 100644
index 00000000..fe69e9e3
--- /dev/null
+++ b/apps/web/src/features/settings/components/schedules/SettingsScheduleStatusFields.tsx
@@ -0,0 +1,64 @@
+import type { Column } from '@/lib/api/endpoints/columns';
+import { colorDot } from '@/components/common/fields/colorDot';
+import { Input } from '@/components/ui/input';
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from '@/components/ui/select';
+import { SettingsScheduleField } from './SettingsScheduleField';
+import { useTranslations } from 'next-intl';
+
+export function SettingsScheduleStatusFields({
+ columns,
+ columnId,
+ onColumnChange,
+ delayMin,
+ onDelayChange,
+}: {
+ columns: Column[];
+ columnId: string;
+ onColumnChange: (value: string) => void;
+ delayMin: string;
+ onDelayChange: (value: string) => void;
+}) {
+ const t = useTranslations('settings.schedules');
+ return (
+ <div className="space-y-1.5">
+ <div className="grid gap-4 sm:grid-cols-2">
+ <SettingsScheduleField htmlFor="schedule-column" label={t('column')}>
+ <Select value={columnId} onValueChange={onColumnChange}>
+ <SelectTrigger id="schedule-column" className="w-full" aria-required="true">
+ <SelectValue placeholder={t('selectColumn')} />
+ </SelectTrigger>
+ <SelectContent>
+ {columns.map((column) => (
+ <SelectItem key={column.id} value={String(column.id)}>
+ {colorDot(column.color)}
+ {column.name}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </SettingsScheduleField>
+ <SettingsScheduleField htmlFor="schedule-delay" label={t('delay')}>
+ <div className="flex items-center gap-2">
+ <Input
+ id="schedule-delay"
+ type="number"
+ step="1"
+ min="0"
+ max="1440"
+ value={delayMin}
+ onChange={(event) => onDelayChange(event.target.value)}
+ />
+ <span className="text-xs text-muted-foreground">{t('minutes')}</span>
+ </div>
+ </SettingsScheduleField>
+ </div>
+ <p className="text-xs text-muted-foreground">{t('statusHint')}</p>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/settings/components/schedules/SettingsScheduleTaskField.tsx b/apps/web/src/features/settings/components/schedules/SettingsScheduleTaskField.tsx
new file mode 100644
index 00000000..78cb0d07
--- /dev/null
+++ b/apps/web/src/features/settings/components/schedules/SettingsScheduleTaskField.tsx
@@ -0,0 +1,33 @@
+import { Textarea } from '@/components/ui/textarea';
+import { SettingsScheduleField } from './SettingsScheduleField';
+import { useTranslations } from 'next-intl';
+
+// A status schedule's run already names the issue and the column it entered, so its
+// task is optional.
+export function SettingsScheduleTaskField({
+ optional,
+ value,
+ onChange,
+}: {
+ optional: boolean;
+ value: string;
+ onChange: (value: string) => void;
+}) {
+ const t = useTranslations('settings.schedules');
+ return (
+ <SettingsScheduleField htmlFor="schedule-task" label={optional ? t('taskOptional') : t('task')}>
+ <Textarea
+ id="schedule-task"
+ required={!optional}
+ maxLength={20_000}
+ value={value}
+ onChange={(event) => onChange(event.target.value)}
+ placeholder={optional ? t('statusTaskPlaceholder') : t('taskPlaceholder')}
+ className="min-h-32 resize-y"
+ />
+ <p className="text-xs text-muted-foreground">
+ {optional ? t('statusTaskHint') : t('taskHint')}
+ </p>
+ </SettingsScheduleField>
+ );
+}
diff --git a/apps/web/src/features/settings/components/schedules/SettingsScheduleTypeField.tsx b/apps/web/src/features/settings/components/schedules/SettingsScheduleTypeField.tsx
new file mode 100644
index 00000000..306a661d
--- /dev/null
+++ b/apps/web/src/features/settings/components/schedules/SettingsScheduleTypeField.tsx
@@ -0,0 +1,33 @@
+import type { AgentScheduleType } from '@/lib/api/endpoints/agentSchedules';
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from '@/components/ui/select';
+import { SettingsScheduleField } from './SettingsScheduleField';
+import { useTranslations } from 'next-intl';
+
+export function SettingsScheduleTypeField({
+ value,
+ onChange,
+}: {
+ value: AgentScheduleType;
+ onChange: (value: AgentScheduleType) => void;
+}) {
+ const t = useTranslations('settings.schedules');
+ return (
+ <SettingsScheduleField htmlFor="schedule-type" label={t('type')}>
+ <Select value={value} onValueChange={(next) => onChange(next as AgentScheduleType)}>
+ <SelectTrigger id="schedule-type" className="w-full">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="cron">{t('typeCron')}</SelectItem>
+ <SelectItem value="status">{t('typeStatus')}</SelectItem>
+ </SelectContent>
+ </Select>
+ </SettingsScheduleField>
+ );
+}
diff --git a/apps/web/src/features/settings/components/schedules/SettingsScheduleWhen.tsx b/apps/web/src/features/settings/components/schedules/SettingsScheduleWhen.tsx
new file mode 100644
index 00000000..1c71f8cc
--- /dev/null
+++ b/apps/web/src/features/settings/components/schedules/SettingsScheduleWhen.tsx
@@ -0,0 +1,34 @@
+import type { AgentSchedule } from '@/lib/api/endpoints/agentSchedules';
+import { parseScheduleInput } from '../../utils/cronSchedule';
+import { useTranslations } from 'next-intl';
+
+// When a schedule runs: its cron in words, or the column whose incoming issues start it.
+export function SettingsScheduleWhen({
+ schedule,
+ columnName,
+}: {
+ schedule: AgentSchedule;
+ columnName: string | null;
+}) {
+ const t = useTranslations('settings.schedules');
+ if (schedule.cron === null) {
+ const minutes = Math.round(schedule.delaySec / 60);
+ return (
+ <>
+ <p className="text-sm">{t('entersColumn', { column: columnName ?? '' })}</p>
+ <p className="mt-1 text-xs text-muted-foreground">
+ {minutes > 0 ? t('startsAfter', { minutes }) : t('startsAtOnce')}
+ </p>
+ </>
+ );
+ }
+ const parsed = parseScheduleInput(schedule.cron);
+ return (
+ <>
+ <p className="text-sm" title={schedule.cron}>
+ {parsed.ok ? parsed.description : schedule.cron}
+ </p>
+ <p className="mt-1 text-xs text-muted-foreground">UTC</p>
+ </>
+ );
+}
diff --git a/apps/web/src/features/settings/components/schedules/SettingsSchedules.tsx b/apps/web/src/features/settings/components/schedules/SettingsSchedules.tsx
index e04be017..2758848f 100644
--- a/apps/web/src/features/settings/components/schedules/SettingsSchedules.tsx
+++ b/apps/web/src/features/settings/components/schedules/SettingsSchedules.tsx
@@ -110,6 +110,7 @@ export default function SettingsSchedules({
<div className="space-y-4">
<SettingsSchedulesTable
schedules={schedules}
+ columns={project.columns}
runningId={runSchedule.isPending ? (runSchedule.variables ?? null) : null}
onToggle={(schedule) =>
updateSchedule.mutate({
@@ -132,6 +133,7 @@ export default function SettingsSchedules({
key={editingSchedule?.id ?? 'new'}
projectKey={projectKey}
agents={agents}
+ columns={project.columns}
initial={editingSchedule}
saving={saving}
onSave={saveSchedule}
@@ -157,6 +159,7 @@ export default function SettingsSchedules({
<SettingsScheduleRunsSheet
projectKey={projectKey}
schedule={history}
+ columnName={project.columns.find((column) => column.id === history?.columnId)?.name ?? null}
onClose={() => setHistory(null)}
/>
</>
diff --git a/apps/web/src/features/settings/components/schedules/SettingsSchedulesTable.tsx b/apps/web/src/features/settings/components/schedules/SettingsSchedulesTable.tsx
index 785995a1..3c9a987a 100644
--- a/apps/web/src/features/settings/components/schedules/SettingsSchedulesTable.tsx
+++ b/apps/web/src/features/settings/components/schedules/SettingsSchedulesTable.tsx
@@ -1,10 +1,12 @@
import type { AgentSchedule } from '@/lib/api/endpoints/agentSchedules';
+import type { Column } from '@/lib/api/endpoints/columns';
import { Table, TableBody, TableHead, TableHeader, TableRow } from '@/components/ui/table';
import { SettingsScheduleRow } from './SettingsScheduleRow';
import { useTranslations } from 'next-intl';
interface SettingsSchedulesTableProps {
schedules: AgentSchedule[];
+ columns: Column[];
runningId: number | null;
onToggle: (schedule: AgentSchedule) => void;
onRun: (scheduleId: number) => void;
@@ -16,6 +18,7 @@ interface SettingsSchedulesTableProps {
export function SettingsSchedulesTable({
schedules,
+ columns,
runningId,
onToggle,
onRun,
@@ -57,6 +60,7 @@ export function SettingsSchedulesTable({
<SettingsScheduleRow
key={schedule.id}
schedule={schedule}
+ columnName={columns.find((column) => column.id === schedule.columnId)?.name ?? null}
running={runningId === schedule.id}
onToggle={() => onToggle(schedule)}
onRun={() => onRun(schedule.id)}
diff --git a/apps/web/src/features/teams/utils/agentForm.ts b/apps/web/src/features/teams/utils/agentForm.ts
index 2d2bd932..bce9c2fe 100644
--- a/apps/web/src/features/teams/utils/agentForm.ts
+++ b/apps/web/src/features/teams/utils/agentForm.ts
@@ -1,5 +1,6 @@
import type { AgentTool, AiAgent, NewAiAgentInput, AiAgentPatch } from '@/lib/api/endpoints/agents';
import { transliterate } from '@/utils/projectKey';
+import { delaySecFromMinutes } from '@/utils/runDelay';
// The editable shape of an agent form. temperature/maxSteps are kept as strings so
// the inputs can be left blank; they are parsed to numbers (or null) on submit.
@@ -82,15 +83,6 @@ export function initialAgentValue(agent?: AiAgent): AgentFormValue {
};
}
-// The delay the server stores, for delegation and for a field trigger alike. A blank
-// or unparseable input means no delay; the value is clamped to the server's 0..24h
-// range.
-export function delaySecFromMinutes(minutes: string): number {
- const n = Math.round(Number(minutes.trim()));
- if (!Number.isFinite(n) || n <= 0) return 0;
- return Math.min(n, 1440) * 60;
-}
-
// Parses an optional number input: blank becomes null (clears the field), a valid
// number is passed through, anything unparseable is treated as blank.
function parseNum(s: string): number | null {
diff --git a/apps/web/src/lib/api/endpoints/agentSchedules.ts b/apps/web/src/lib/api/endpoints/agentSchedules.ts
index 8b31714b..65c777d6 100644
--- a/apps/web/src/lib/api/endpoints/agentSchedules.ts
+++ b/apps/web/src/lib/api/endpoints/agentSchedules.ts
@@ -2,16 +2,25 @@ import { request } from '@/lib/api/core/client';
import type { AgentRunStatus } from '@/lib/api/endpoints/agents';
import { pageQuery, type Page, type PageParams } from '@/lib/api/core/paging';
+// 'cron' runs on its cron; 'status' runs on an issue each time one enters its column.
+export type AgentScheduleType = 'cron' | 'status';
+
export interface AgentSchedule {
id: number;
agentId: number;
agentName: string;
name: string;
+ type: AgentScheduleType;
+ // Empty on a status schedule that sends no task of its own.
prompt: string;
- cron: string;
+ // Set on a cron schedule only, as is nextRunAt.
+ cron: string | null;
timezone: 'UTC';
+ // Set on a status schedule only.
+ columnId: number | null;
+ delaySec: number;
status: 'active' | 'paused';
- nextRunAt: string;
+ nextRunAt: string | null;
lastRunAt: string | null;
lastRunStatus: AgentRunStatus | null;
pendingRuns: number;
@@ -22,18 +31,22 @@ export interface AgentSchedule {
updatedAt: string;
}
+// `type` is set on a create only: a schedule keeps the type it was created with.
export interface AgentScheduleInput {
agentId: number;
name: string;
+ type?: AgentScheduleType;
prompt: string;
- cron: string;
+ cron?: string;
+ columnId?: number;
+ delaySec?: number;
status?: 'active' | 'paused';
}
export interface AgentScheduleRun {
id: number;
status: AgentRunStatus;
- trigger: 'schedule' | 'manual';
+ trigger: 'schedule' | 'manual' | 'status';
prompt: string;
attempts: number;
lastError: string | null;
diff --git a/apps/web/src/lib/api/endpoints/agents.ts b/apps/web/src/lib/api/endpoints/agents.ts
index 940c42d0..50525fb8 100644
--- a/apps/web/src/lib/api/endpoints/agents.ts
+++ b/apps/web/src/lib/api/endpoints/agents.ts
@@ -75,12 +75,14 @@ export interface AiAgent {
// pending run ended by hand.
export type AgentRunStatus = 'pending' | 'success' | 'failed' | 'canceled';
-// One row of an agent's autonomous run history. Issue-triggered runs reference an
-// issue; scheduled and manual runs do not.
+export type AgentRunTrigger = 'mention' | 'delegation' | 'field' | 'schedule' | 'manual' | 'status';
+
+// One row of an agent's autonomous run history. A run triggered on an issue references
+// it; a cron schedule's run and a manual one do not.
export interface AgentRun {
id: number;
status: AgentRunStatus;
- trigger: 'mention' | 'delegation' | 'field' | 'schedule' | 'manual';
+ trigger: AgentRunTrigger;
issueId: number | null;
issueIdentifier: string | null;
issueTitle: string | null;
diff --git a/apps/web/src/lib/api/endpoints/analytics.ts b/apps/web/src/lib/api/endpoints/analytics.ts
index 9904ea16..0f83c600 100644
--- a/apps/web/src/lib/api/endpoints/analytics.ts
+++ b/apps/web/src/lib/api/endpoints/analytics.ts
@@ -1,5 +1,5 @@
import type { BreakdownBy } from '@/utils/dashboardWidgets';
-import type { AgentRunStatus } from '@/lib/api/endpoints/agents';
+import type { AgentRunStatus, AgentRunTrigger } from '@/lib/api/endpoints/agents';
import { request } from '@/lib/api/core/client';
import type { ActivityPage, FeedCursor } from '@/lib/api/endpoints/activity';
@@ -75,7 +75,7 @@ export interface BurnupParams {
export interface AgentRunFeedItem {
id: number;
status: AgentRunStatus;
- trigger: 'mention' | 'delegation' | 'field' | 'schedule' | 'manual';
+ trigger: AgentRunTrigger;
agentId: number;
agentName: string;
issueId: number | null;
diff --git a/apps/web/src/utils/runDelay.ts b/apps/web/src/utils/runDelay.ts
new file mode 100644
index 00000000..1570de80
--- /dev/null
+++ b/apps/web/src/utils/runDelay.ts
@@ -0,0 +1,8 @@
+// The delay the server stores for a triggered agent run: delegation, a field trigger,
+// a status schedule. A blank or unparseable input means no delay; the value is clamped
+// to the server's 0..24h range.
+export function delaySecFromMinutes(minutes: string): number {
+ const n = Math.round(Number(minutes.trim()));
+ if (!Number.isFinite(n) || n <= 0) return 0;
+ return Math.min(n, 1440) * 60;
+}
diff --git a/apps/worker/src/schedules.ts b/apps/worker/src/schedules.ts
index fff679c5..8c31997d 100644
--- a/apps/worker/src/schedules.ts
+++ b/apps/worker/src/schedules.ts
@@ -21,7 +21,8 @@ export async function enqueueDueSchedules(): Promise<void> {
s.next_run_at AS "nextRunAt"
FROM agent_schedule s
JOIN project p ON p.id = s.project_id
- WHERE s.status = 'active' AND s.next_run_at <= now() AND p.archived_at IS NULL
+ WHERE s.type = 'cron' AND s.status = 'active' AND s.next_run_at <= now()
+ AND p.archived_at IS NULL
ORDER BY s.next_run_at, s.id
FOR UPDATE OF s SKIP LOCKED
LIMIT 50
diff --git a/packages/db/drizzle/0144_agent_schedule_status_trigger.sql b/packages/db/drizzle/0144_agent_schedule_status_trigger.sql
new file mode 100644
index 00000000..9e28fcb2
--- /dev/null
+++ b/packages/db/drizzle/0144_agent_schedule_status_trigger.sql
@@ -0,0 +1,12 @@
+ALTER TABLE "agent_run" DROP CONSTRAINT "agent_run_trigger_check";--> statement-breakpoint
+ALTER TABLE "agent_schedule" ALTER COLUMN "cron" DROP NOT NULL;--> statement-breakpoint
+ALTER TABLE "agent_schedule" ALTER COLUMN "next_run_at" DROP NOT NULL;--> statement-breakpoint
+ALTER TABLE "agent_schedule" ADD COLUMN "type" text DEFAULT 'cron' NOT NULL;--> statement-breakpoint
+ALTER TABLE "agent_schedule" ADD COLUMN "column_id" integer;--> statement-breakpoint
+ALTER TABLE "agent_schedule" ADD COLUMN "delay_sec" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
+ALTER TABLE "agent_schedule" ADD CONSTRAINT "agent_schedule_column_id_project_column_id_fk" FOREIGN KEY ("column_id") REFERENCES "public"."project_column"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+CREATE INDEX "agent_schedule_column_idx" ON "agent_schedule" USING btree ("column_id");--> statement-breakpoint
+ALTER TABLE "agent_run" ADD CONSTRAINT "agent_run_trigger_check" CHECK ("agent_run"."trigger" IN ('mention', 'delegation', 'field', 'schedule', 'manual', 'status'));--> statement-breakpoint
+ALTER TABLE "agent_schedule" ADD CONSTRAINT "agent_schedule_type_check" CHECK (("agent_schedule"."type" = 'cron' AND "agent_schedule"."cron" IS NOT NULL AND "agent_schedule"."next_run_at" IS NOT NULL AND "agent_schedule"."column_id" IS NULL)
+ OR ("agent_schedule"."type" = 'status' AND "agent_schedule"."column_id" IS NOT NULL AND "agent_schedule"."cron" IS NULL AND "agent_schedule"."next_run_at" IS NULL));--> statement-breakpoint
+ALTER TABLE "agent_schedule" ADD CONSTRAINT "agent_schedule_delay_check" CHECK ("agent_schedule"."delay_sec" >= 0 AND "agent_schedule"."delay_sec" <= 86400);
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0144_snapshot.json b/packages/db/drizzle/meta/0144_snapshot.json
new file mode 100644
index 00000000..1209c695
--- /dev/null
+++ b/packages/db/drizzle/meta/0144_snapshot.json
@@ -0,0 +1,11433 @@
+{
+ "id": "f923b8c7-66bf-4593-80f1-30707b3f141d",
+ "prevId": "c78e9e48-c24d-4b18-a209-781a53fca222",
+ "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.oauth_access_token": {
+ "name": "oauth_access_token",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "oauthAccessToken_clientId_idx": {
+ "name": "oauthAccessToken_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthAccessToken_userId_idx": {
+ "name": "oauthAccessToken_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_access_token_client_id_oauth_application_client_id_fk": {
+ "name": "oauth_access_token_client_id_oauth_application_client_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "oauth_application",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_access_token_user_id_user_id_fk": {
+ "name": "oauth_access_token_user_id_user_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_access_token_access_token_unique": {
+ "name": "oauth_access_token_access_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "access_token"
+ ]
+ },
+ "oauth_access_token_refresh_token_unique": {
+ "name": "oauth_access_token_refresh_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "refresh_token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oauth_application": {
+ "name": "oauth_application",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_secret": {
+ "name": "client_secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "redirect_urls": {
+ "name": "redirect_urls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "disabled": {
+ "name": "disabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "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
+ }
+ },
+ "indexes": {
+ "oauthApplication_userId_idx": {
+ "name": "oauthApplication_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_application_user_id_user_id_fk": {
+ "name": "oauth_application_user_id_user_id_fk",
+ "tableFrom": "oauth_application",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_application_client_id_unique": {
+ "name": "oauth_application_client_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "client_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oauth_consent": {
+ "name": "oauth_consent",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consent_given": {
+ "name": "consent_given",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "oauthConsent_clientId_idx": {
+ "name": "oauthConsent_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthConsent_userId_idx": {
+ "name": "oauthConsent_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_consent_client_id_oauth_application_client_id_fk": {
+ "name": "oauth_consent_client_id_oauth_application_client_id_fk",
+ "tableFrom": "oauth_consent",
+ "tableTo": "oauth_application",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_consent_user_id_user_id_fk": {
+ "name": "oauth_consent_user_id_user_id_fk",
+ "tableFrom": "oauth_consent",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.passkey": {
+ "name": "passkey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "public_key": {
+ "name": "public_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "counter": {
+ "name": "counter",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_type": {
+ "name": "device_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "backed_up": {
+ "name": "backed_up",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transports": {
+ "name": "transports",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "aaguid": {
+ "name": "aaguid",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "passkey_userId_idx": {
+ "name": "passkey_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "passkey_credentialID_idx": {
+ "name": "passkey_credentialID_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "passkey_user_id_user_id_fk": {
+ "name": "passkey_user_id_user_id_fk",
+ "tableFrom": "passkey",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "session_userId_idx": {
+ "name": "session_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "username": {
+ "name": "username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "display_username": {
+ "name": "display_username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'user'"
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ },
+ "user_username_unique": {
+ "name": "user_username_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "username"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verification": {
+ "name": "verification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verification_identifier_idx": {
+ "name": "verification_identifier_idx",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_event": {
+ "name": "agent_chat_event",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_chat_event_message_idx": {
+ "name": "agent_chat_event_message_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_chat_event_message_id_agent_chat_message_id_fk": {
+ "name": "agent_chat_event_message_id_agent_chat_message_id_fk",
+ "tableFrom": "agent_chat_event",
+ "tableTo": "agent_chat_message",
+ "columnsFrom": [
+ "message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_favorite": {
+ "name": "agent_chat_favorite",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "agent_chat_favorite_user_id_user_id_fk": {
+ "name": "agent_chat_favorite_user_id_user_id_fk",
+ "tableFrom": "agent_chat_favorite",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_chat_favorite_agent_id_ai_agent_id_fk": {
+ "name": "agent_chat_favorite_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_chat_favorite",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_chat_favorite_user_id_thread_id_pk": {
+ "name": "agent_chat_favorite_user_id_thread_id_pk",
+ "columns": [
+ "user_id",
+ "thread_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_message": {
+ "name": "agent_chat_message",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_chat_message_thread_idx": {
+ "name": "agent_chat_message_thread_idx",
+ "columns": [
+ {
+ "expression": "thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_chat_message_due_idx": {
+ "name": "agent_chat_message_due_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"agent_chat_message\".\"status\" IN ('pending', 'streaming')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_chat_message_thread_id_agent_chat_thread_id_fk": {
+ "name": "agent_chat_message_thread_id_agent_chat_thread_id_fk",
+ "tableFrom": "agent_chat_message",
+ "tableTo": "agent_chat_thread",
+ "columnsFrom": [
+ "thread_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_chat_message_agent_id_ai_agent_id_fk": {
+ "name": "agent_chat_message_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_chat_message",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_chat_message_role_check": {
+ "name": "agent_chat_message_role_check",
+ "value": "\"agent_chat_message\".\"role\" IN ('user', 'assistant')"
+ },
+ "agent_chat_message_status_check": {
+ "name": "agent_chat_message_status_check",
+ "value": "\"agent_chat_message\".\"status\" IN ('pending', 'streaming', 'success', 'failed', 'canceled')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_thread": {
+ "name": "agent_chat_thread",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_chat_thread_agent_user_idx": {
+ "name": "agent_chat_thread_agent_user_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_chat_thread_agent_id_ai_agent_id_fk": {
+ "name": "agent_chat_thread_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_chat_thread",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_chat_thread_user_id_user_id_fk": {
+ "name": "agent_chat_thread_user_id_user_id_fk",
+ "tableFrom": "agent_chat_thread",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_usage": {
+ "name": "agent_chat_usage",
+ "schema": "",
+ "columns": {
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "input_tokens": {
+ "name": "input_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output_tokens": {
+ "name": "output_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_chat_usage_agent_idx": {
+ "name": "agent_chat_usage_agent_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_chat_usage_agent_id_ai_agent_id_fk": {
+ "name": "agent_chat_usage_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_chat_usage",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_field_trigger": {
+ "name": "agent_field_trigger",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "delay_sec": {
+ "name": "delay_sec",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 120
+ }
+ },
+ "indexes": {
+ "agent_field_trigger_field_idx": {
+ "name": "agent_field_trigger_field_idx",
+ "columns": [
+ {
+ "expression": "field_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_field_trigger_agent_id_ai_agent_id_fk": {
+ "name": "agent_field_trigger_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_field_trigger",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_field_trigger_field_id_custom_field_id_fk": {
+ "name": "agent_field_trigger_field_id_custom_field_id_fk",
+ "tableFrom": "agent_field_trigger",
+ "tableTo": "custom_field",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_field_trigger_agent_id_field_id_pk": {
+ "name": "agent_field_trigger_agent_id_field_id_pk",
+ "columns": [
+ "agent_id",
+ "field_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_field_trigger_delay_check": {
+ "name": "agent_field_trigger_delay_check",
+ "value": "\"agent_field_trigger\".\"delay_sec\" >= 0 AND \"agent_field_trigger\".\"delay_sec\" <= 86400"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_run": {
+ "name": "agent_run",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schedule_id": {
+ "name": "schedule_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trigger": {
+ "name": "trigger",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'delegation'"
+ },
+ "scheduled_for": {
+ "name": "scheduled_for",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_activity_id": {
+ "name": "source_activity_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "input_tokens": {
+ "name": "input_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output_tokens": {
+ "name": "output_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_run_schedule_fire_uq": {
+ "name": "agent_run_schedule_fire_uq",
+ "columns": [
+ {
+ "expression": "schedule_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scheduled_for",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_run_due_idx": {
+ "name": "agent_run_due_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_run_schedule_idx": {
+ "name": "agent_run_schedule_idx",
+ "columns": [
+ {
+ "expression": "schedule_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_run_project_idx": {
+ "name": "agent_run_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_run_agent_id_ai_agent_id_fk": {
+ "name": "agent_run_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_run",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_run_project_id_project_id_fk": {
+ "name": "agent_run_project_id_project_id_fk",
+ "tableFrom": "agent_run",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_run_issue_id_issue_id_fk": {
+ "name": "agent_run_issue_id_issue_id_fk",
+ "tableFrom": "agent_run",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_run_schedule_id_agent_schedule_id_fk": {
+ "name": "agent_run_schedule_id_agent_schedule_id_fk",
+ "tableFrom": "agent_run",
+ "tableTo": "agent_schedule",
+ "columnsFrom": [
+ "schedule_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_run_source_activity_id_issue_activity_id_fk": {
+ "name": "agent_run_source_activity_id_issue_activity_id_fk",
+ "tableFrom": "agent_run",
+ "tableTo": "issue_activity",
+ "columnsFrom": [
+ "source_activity_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_run_status_check": {
+ "name": "agent_run_status_check",
+ "value": "\"agent_run\".\"status\" IN ('pending', 'success', 'failed', 'canceled')"
+ },
+ "agent_run_trigger_check": {
+ "name": "agent_run_trigger_check",
+ "value": "\"agent_run\".\"trigger\" IN ('mention', 'delegation', 'field', 'schedule', 'manual', 'status')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_schedule": {
+ "name": "agent_schedule",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cron'"
+ },
+ "cron": {
+ "name": "cron",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "timezone": {
+ "name": "timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "next_run_at": {
+ "name": "next_run_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "column_id": {
+ "name": "column_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "delay_sec": {
+ "name": "delay_sec",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "last_run_at": {
+ "name": "last_run_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_schedule_due_idx": {
+ "name": "agent_schedule_due_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_run_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_schedule_agent_idx": {
+ "name": "agent_schedule_agent_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_schedule_project_idx": {
+ "name": "agent_schedule_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_schedule_column_idx": {
+ "name": "agent_schedule_column_idx",
+ "columns": [
+ {
+ "expression": "column_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_schedule_agent_id_ai_agent_id_fk": {
+ "name": "agent_schedule_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_schedule",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_schedule_project_id_project_id_fk": {
+ "name": "agent_schedule_project_id_project_id_fk",
+ "tableFrom": "agent_schedule",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_schedule_column_id_project_column_id_fk": {
+ "name": "agent_schedule_column_id_project_column_id_fk",
+ "tableFrom": "agent_schedule",
+ "tableTo": "project_column",
+ "columnsFrom": [
+ "column_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_schedule_project_id_agent_id_name_unique": {
+ "name": "agent_schedule_project_id_agent_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "agent_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "agent_schedule_status_check": {
+ "name": "agent_schedule_status_check",
+ "value": "\"agent_schedule\".\"status\" IN ('active', 'paused')"
+ },
+ "agent_schedule_type_check": {
+ "name": "agent_schedule_type_check",
+ "value": "(\"agent_schedule\".\"type\" = 'cron' AND \"agent_schedule\".\"cron\" IS NOT NULL AND \"agent_schedule\".\"next_run_at\" IS NOT NULL AND \"agent_schedule\".\"column_id\" IS NULL)\n OR (\"agent_schedule\".\"type\" = 'status' AND \"agent_schedule\".\"column_id\" IS NOT NULL AND \"agent_schedule\".\"cron\" IS NULL AND \"agent_schedule\".\"next_run_at\" IS NULL)"
+ },
+ "agent_schedule_delay_check": {
+ "name": "agent_schedule_delay_check",
+ "value": "\"agent_schedule\".\"delay_sec\" >= 0 AND \"agent_schedule\".\"delay_sec\" <= 86400"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_skill": {
+ "name": "agent_skill",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "s3_prefix": {
+ "name": "s3_prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "files": {
+ "name": "files",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_skill_team_idx": {
+ "name": "agent_skill_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_skill_team_id_team_id_fk": {
+ "name": "agent_skill_team_id_team_id_fk",
+ "tableFrom": "agent_skill",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_skill_team_id_name_unique": {
+ "name": "agent_skill_team_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "team_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "agent_skill_source_check": {
+ "name": "agent_skill_source_check",
+ "value": "\"agent_skill\".\"source\" IN ('upload', 'inline', 'github')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_skill_link": {
+ "name": "agent_skill_link",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "skill_id": {
+ "name": "skill_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "agent_skill_link_skill_idx": {
+ "name": "agent_skill_link_skill_idx",
+ "columns": [
+ {
+ "expression": "skill_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_skill_link_agent_id_ai_agent_id_fk": {
+ "name": "agent_skill_link_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_skill_link",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_skill_link_skill_id_agent_skill_id_fk": {
+ "name": "agent_skill_link_skill_id_agent_skill_id_fk",
+ "tableFrom": "agent_skill_link",
+ "tableTo": "agent_skill",
+ "columnsFrom": [
+ "skill_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_skill_link_agent_id_skill_id_pk": {
+ "name": "agent_skill_link_agent_id_skill_id_pk",
+ "columns": [
+ "agent_id",
+ "skill_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_tool": {
+ "name": "agent_tool",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tool_key": {
+ "name": "tool_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_tool_team_idx": {
+ "name": "agent_tool_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_tool_credential_idx": {
+ "name": "agent_tool_credential_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_tool_team_id_team_id_fk": {
+ "name": "agent_tool_team_id_team_id_fk",
+ "tableFrom": "agent_tool",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_tool_credential_id_integration_credential_id_fk": {
+ "name": "agent_tool_credential_id_integration_credential_id_fk",
+ "tableFrom": "agent_tool",
+ "tableTo": "integration_credential",
+ "columnsFrom": [
+ "credential_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_tool_team_id_tool_key_credential_id_unique": {
+ "name": "agent_tool_team_id_tool_key_credential_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "team_id",
+ "tool_key",
+ "credential_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_tool_link": {
+ "name": "agent_tool_link",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_tool_id": {
+ "name": "agent_tool_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "agent_tool_link_tool_idx": {
+ "name": "agent_tool_link_tool_idx",
+ "columns": [
+ {
+ "expression": "agent_tool_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_tool_link_agent_id_ai_agent_id_fk": {
+ "name": "agent_tool_link_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_tool_link",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_tool_link_agent_tool_id_agent_tool_id_fk": {
+ "name": "agent_tool_link_agent_tool_id_agent_tool_id_fk",
+ "tableFrom": "agent_tool_link",
+ "tableTo": "agent_tool",
+ "columnsFrom": [
+ "agent_tool_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_tool_link_agent_id_agent_tool_id_pk": {
+ "name": "agent_tool_link_agent_id_agent_tool_id_pk",
+ "columns": [
+ "agent_id",
+ "agent_tool_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.ai_agent": {
+ "name": "ai_agent",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "username": {
+ "name": "username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model_credential_id": {
+ "name": "model_credential_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instructions": {
+ "name": "instructions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tools": {
+ "name": "tools",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "temperature": {
+ "name": "temperature",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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
+ },
+ "api_key_ciphertext": {
+ "name": "api_key_ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_key_iv": {
+ "name": "api_key_iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_key_auth_tag": {
+ "name": "api_key_auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "memory_enabled": {
+ "name": "memory_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "memory_last_messages": {
+ "name": "memory_last_messages",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "runner_scope": {
+ "name": "runner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'team'"
+ },
+ "last_seen_at": {
+ "name": "last_seen_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "ai_agent_team_username_uq": {
+ "name": "ai_agent_team_username_uq",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(\"username\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ai_agent_team_idx": {
+ "name": "ai_agent_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "ai_agent_team_id_team_id_fk": {
+ "name": "ai_agent_team_id_team_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ai_agent_user_id_user_id_fk": {
+ "name": "ai_agent_user_id_user_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ai_agent_model_credential_id_integration_credential_id_fk": {
+ "name": "ai_agent_model_credential_id_integration_credential_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "integration_credential",
+ "columnsFrom": [
+ "model_credential_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "ai_agent_owner_user_id_user_id_fk": {
+ "name": "ai_agent_owner_user_id_user_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "ai_agent_user_id_unique": {
+ "name": "ai_agent_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "ai_agent_kind_check": {
+ "name": "ai_agent_kind_check",
+ "value": "\"ai_agent\".\"kind\" IN ('external', 'internal')"
+ },
+ "ai_agent_runner_scope_check": {
+ "name": "ai_agent_runner_scope_check",
+ "value": "\"ai_agent\".\"runner_scope\" IN ('owner', 'team')"
+ },
+ "ai_agent_delegation_delay_check": {
+ "name": "ai_agent_delegation_delay_check",
+ "value": "\"ai_agent\".\"delegation_delay_sec\" >= 0 AND \"ai_agent\".\"delegation_delay_sec\" <= 86400"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.app_secret": {
+ "name": "app_secret",
+ "schema": "",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "ciphertext": {
+ "name": "ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "iv": {
+ "name": "iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_tag": {
+ "name": "auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redacted": {
+ "name": "redacted",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.app_setting": {
+ "name": "app_setting",
+ "schema": "",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.chat_attachment": {
+ "name": "chat_attachment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_by_user_id": {
+ "name": "uploaded_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content_type": {
+ "name": "content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "chat_attachment_project_idx": {
+ "name": "chat_attachment_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "chat_attachment_project_id_project_id_fk": {
+ "name": "chat_attachment_project_id_project_id_fk",
+ "tableFrom": "chat_attachment",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "chat_attachment_uploaded_by_user_id_user_id_fk": {
+ "name": "chat_attachment_uploaded_by_user_id_user_id_fk",
+ "tableFrom": "chat_attachment",
+ "tableTo": "user",
+ "columnsFrom": [
+ "uploaded_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "chat_attachment_public_id_unique": {
+ "name": "chat_attachment_public_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "public_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.custom_field": {
+ "name": "custom_field",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_type_id": {
+ "name": "issue_type_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_type": {
+ "name": "field_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "member_scope": {
+ "name": "member_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "show_in_body": {
+ "name": "show_in_body",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "custom_field_project_id_project_id_fk": {
+ "name": "custom_field_project_id_project_id_fk",
+ "tableFrom": "custom_field",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "custom_field_issue_type_id_issue_type_id_fk": {
+ "name": "custom_field_issue_type_id_issue_type_id_fk",
+ "tableFrom": "custom_field",
+ "tableTo": "issue_type",
+ "columnsFrom": [
+ "issue_type_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "custom_field_field_type_check": {
+ "name": "custom_field_field_type_check",
+ "value": "\"custom_field\".\"field_type\" IN ('text', 'markdown', 'url', 'number', 'boolean', 'date', 'datetime', 'datetime_range', 'select', 'multi_select', 'member')"
+ },
+ "custom_field_member_scope_check": {
+ "name": "custom_field_member_scope_check",
+ "value": "(\"custom_field\".\"field_type\" = 'member') = (\"custom_field\".\"member_scope\" IS NOT NULL) AND (\"custom_field\".\"member_scope\" IS NULL OR \"custom_field\".\"member_scope\" IN ('all', 'humans', 'agents'))"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.custom_field_option": {
+ "name": "custom_field_option",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#6b7280'"
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "custom_field_option_field_id_custom_field_id_fk": {
+ "name": "custom_field_option_field_id_custom_field_id_fk",
+ "tableFrom": "custom_field_option",
+ "tableTo": "custom_field",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "custom_field_option_field_id_value_unique": {
+ "name": "custom_field_option_field_id_value_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "field_id",
+ "value"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cycle": {
+ "name": "cycle",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "start_date": {
+ "name": "start_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "end_date": {
+ "name": "end_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "cycle_project_idx": {
+ "name": "cycle_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "start_date",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cycle_project_id_project_id_fk": {
+ "name": "cycle_project_id_project_id_fk",
+ "tableFrom": "cycle",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "cycle_dates_check": {
+ "name": "cycle_dates_check",
+ "value": "\"cycle\".\"end_date\" >= \"cycle\".\"start_date\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.document_asset": {
+ "name": "document_asset",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_by_user_id": {
+ "name": "uploaded_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content_type": {
+ "name": "content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "document_asset_document_idx": {
+ "name": "document_asset_document_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "document_asset_document_id_project_document_id_fk": {
+ "name": "document_asset_document_id_project_document_id_fk",
+ "tableFrom": "document_asset",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_asset_uploaded_by_user_id_user_id_fk": {
+ "name": "document_asset_uploaded_by_user_id_user_id_fk",
+ "tableFrom": "document_asset",
+ "tableTo": "user",
+ "columnsFrom": [
+ "uploaded_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "document_asset_public_id_unique": {
+ "name": "document_asset_public_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "public_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.document_collaboration": {
+ "name": "document_collaboration",
+ "schema": "",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epoch": {
+ "name": "epoch",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "content_json": {
+ "name": "content_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "document_collaboration_document_id_project_document_id_fk": {
+ "name": "document_collaboration_document_id_project_document_id_fk",
+ "tableFrom": "document_collaboration",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.document_comment": {
+ "name": "document_comment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "quote": {
+ "name": "quote",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "selection_from": {
+ "name": "selection_from",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "selection_to": {
+ "name": "selection_to",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "orphaned": {
+ "name": "orphaned",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "resolved_at": {
+ "name": "resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "document_comment_document_idx": {
+ "name": "document_comment_document_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "document_comment_document_id_project_document_id_fk": {
+ "name": "document_comment_document_id_project_document_id_fk",
+ "tableFrom": "document_comment",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_comment_parent_id_document_comment_id_fk": {
+ "name": "document_comment_parent_id_document_comment_id_fk",
+ "tableFrom": "document_comment",
+ "tableTo": "document_comment",
+ "columnsFrom": [
+ "parent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_comment_author_id_user_id_fk": {
+ "name": "document_comment_author_id_user_id_fk",
+ "tableFrom": "document_comment",
+ "tableTo": "user",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.document_step": {
+ "name": "document_step",
+ "schema": "",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "step": {
+ "name": "step",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "document_step_document_id_project_document_id_fk": {
+ "name": "document_step_document_id_project_document_id_fk",
+ "tableFrom": "document_step",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "document_step_document_id_version_pk": {
+ "name": "document_step_document_id_version_pk",
+ "columns": [
+ "document_id",
+ "version"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.git_managed_repository": {
+ "name": "git_managed_repository",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "full_name": {
+ "name": "full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "web_url": {
+ "name": "web_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "webhook_external_id": {
+ "name": "webhook_external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'connected'"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "git_managed_repository_project_connection_idx": {
+ "name": "git_managed_repository_project_connection_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "connection_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "git_managed_repository_project_id_project_id_fk": {
+ "name": "git_managed_repository_project_id_project_id_fk",
+ "tableFrom": "git_managed_repository",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "git_managed_repository_connection_id_git_provider_connection_id_fk": {
+ "name": "git_managed_repository_connection_id_git_provider_connection_id_fk",
+ "tableFrom": "git_managed_repository",
+ "tableTo": "git_provider_connection",
+ "columnsFrom": [
+ "connection_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "git_managed_repository_project_connection_external_unique": {
+ "name": "git_managed_repository_project_connection_external_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "connection_id",
+ "external_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.git_provider_connection": {
+ "name": "git_provider_connection",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_url": {
+ "name": "base_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "account_login": {
+ "name": "account_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ciphertext": {
+ "name": "ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "iv": {
+ "name": "iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_tag": {
+ "name": "auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "git_provider_connection_team_idx": {
+ "name": "git_provider_connection_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "git_provider_connection_team_id_team_id_fk": {
+ "name": "git_provider_connection_team_id_team_id_fk",
+ "tableFrom": "git_provider_connection",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.import_job": {
+ "name": "import_job",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "phase": {
+ "name": "phase",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'discover'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "cursor": {
+ "name": "cursor",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "credential_ciphertext": {
+ "name": "credential_ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_iv": {
+ "name": "credential_iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_auth_tag": {
+ "name": "credential_auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "import_job_project_idx": {
+ "name": "import_job_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "import_job_due_idx": {
+ "name": "import_job_due_idx",
+ "columns": [
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"import_job\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "import_job_project_id_project_id_fk": {
+ "name": "import_job_project_id_project_id_fk",
+ "tableFrom": "import_job",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "import_job_created_by_user_id_user_id_fk": {
+ "name": "import_job_created_by_user_id_user_id_fk",
+ "tableFrom": "import_job",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "import_job_source_check": {
+ "name": "import_job_source_check",
+ "value": "\"import_job\".\"source\" IN ('plane', 'linear')"
+ },
+ "import_job_phase_check": {
+ "name": "import_job_phase_check",
+ "value": "\"import_job\".\"phase\" IN ('discover', 'create', 'link', 'rewrite', 'attachments', 'done')"
+ },
+ "import_job_status_check": {
+ "name": "import_job_status_check",
+ "value": "\"import_job\".\"status\" IN ('pending', 'running', 'paused', 'completed', 'failed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.import_record": {
+ "name": "import_record",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "import_job_id": {
+ "name": "import_job_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_entity_type": {
+ "name": "source_entity_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_display_id": {
+ "name": "source_display_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "local_entity_type": {
+ "name": "local_entity_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "local_id": {
+ "name": "local_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "import_record_job_source_uq": {
+ "name": "import_record_job_source_uq",
+ "columns": [
+ {
+ "expression": "import_job_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_entity_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "import_record_job_local_idx": {
+ "name": "import_record_job_local_idx",
+ "columns": [
+ {
+ "expression": "import_job_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "local_entity_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "local_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "import_record_job_display_idx": {
+ "name": "import_record_job_display_idx",
+ "columns": [
+ {
+ "expression": "import_job_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_entity_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_display_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "import_record_import_job_id_import_job_id_fk": {
+ "name": "import_record_import_job_id_import_job_id_fk",
+ "tableFrom": "import_record",
+ "tableTo": "import_job",
+ "columnsFrom": [
+ "import_job_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "import_record_source_entity_type_check": {
+ "name": "import_record_source_entity_type_check",
+ "value": "\"import_record\".\"source_entity_type\" IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment')"
+ },
+ "import_record_local_entity_type_check": {
+ "name": "import_record_local_entity_type_check",
+ "value": "\"import_record\".\"local_entity_type\" IS NULL OR \"import_record\".\"local_entity_type\" IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.initiative": {
+ "name": "initiative",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'planned'"
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start_date": {
+ "name": "start_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_date": {
+ "name": "target_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "initiative_project_idx": {
+ "name": "initiative_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "initiative_project_id_project_id_fk": {
+ "name": "initiative_project_id_project_id_fk",
+ "tableFrom": "initiative",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "initiative_owner_user_id_user_id_fk": {
+ "name": "initiative_owner_user_id_user_id_fk",
+ "tableFrom": "initiative",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "initiative_status_check": {
+ "name": "initiative_status_check",
+ "value": "\"initiative\".\"status\" IN ('proposed', 'planned', 'active', 'completed', 'canceled')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.initiative_attachment": {
+ "name": "initiative_attachment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "initiative_id": {
+ "name": "initiative_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content_type": {
+ "name": "content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "initiative_attachment_initiative_idx": {
+ "name": "initiative_attachment_initiative_idx",
+ "columns": [
+ {
+ "expression": "initiative_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "initiative_attachment_initiative_id_initiative_id_fk": {
+ "name": "initiative_attachment_initiative_id_initiative_id_fk",
+ "tableFrom": "initiative_attachment",
+ "tableTo": "initiative",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "initiative_attachment_public_id_unique": {
+ "name": "initiative_attachment_public_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "public_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.initiative_label": {
+ "name": "initiative_label",
+ "schema": "",
+ "columns": {
+ "initiative_id": {
+ "name": "initiative_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label_id": {
+ "name": "label_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "initiative_label_initiative_id_initiative_id_fk": {
+ "name": "initiative_label_initiative_id_initiative_id_fk",
+ "tableFrom": "initiative_label",
+ "tableTo": "initiative",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "initiative_label_label_id_label_id_fk": {
+ "name": "initiative_label_label_id_label_id_fk",
+ "tableFrom": "initiative_label",
+ "tableTo": "label",
+ "columnsFrom": [
+ "label_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "initiative_label_initiative_id_label_id_pk": {
+ "name": "initiative_label_initiative_id_label_id_pk",
+ "columns": [
+ "initiative_id",
+ "label_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.integration_credential": {
+ "name": "integration_credential",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "integration_key": {
+ "name": "integration_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label": {
+ "name": "label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ciphertext": {
+ "name": "ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "iv": {
+ "name": "iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_tag": {
+ "name": "auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redacted": {
+ "name": "redacted",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "integration_credential_team_idx": {
+ "name": "integration_credential_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "integration_credential_team_id_team_id_fk": {
+ "name": "integration_credential_team_id_team_id_fk",
+ "tableFrom": "integration_credential",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue": {
+ "name": "issue",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence_number": {
+ "name": "sequence_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type_id": {
+ "name": "type_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "initiative_id": {
+ "name": "initiative_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cycle_id": {
+ "name": "cycle_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "column_id": {
+ "name": "column_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assignee_user_id": {
+ "name": "assignee_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "delegate_user_id": {
+ "name": "delegate_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimate_points": {
+ "name": "estimate_points",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimate_minutes": {
+ "name": "estimate_minutes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start_date": {
+ "name": "start_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "due_date": {
+ "name": "due_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "share_token": {
+ "name": "share_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "share_extended": {
+ "name": "share_extended",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_project_active_idx": {
+ "name": "issue_project_active_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "column_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"issue\".\"archived_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_project_title_idx": {
+ "name": "issue_project_title_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(btrim(\"title\"))",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_parent_idx": {
+ "name": "issue_parent_idx",
+ "columns": [
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"issue\".\"parent_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_cycle_idx": {
+ "name": "issue_cycle_idx",
+ "columns": [
+ {
+ "expression": "cycle_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"issue\".\"cycle_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_project_id_project_id_fk": {
+ "name": "issue_project_id_project_id_fk",
+ "tableFrom": "issue",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_type_id_issue_type_id_fk": {
+ "name": "issue_type_id_issue_type_id_fk",
+ "tableFrom": "issue",
+ "tableTo": "issue_type",
+ "columnsFrom": [
+ "type_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "issue_initiative_id_initiative_id_fk": {
+ "name": "issue_initiative_id_initiative_id_fk",
+ "tableFrom": "issue",
+ "tableTo": "initiative",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "issue_cycle_id_cycle_id_fk": {
+ "name": "issue_cycle_id_cycle_id_fk",
+ "tableFrom": "issue",
+ "tableTo": "cycle",
+ "columnsFrom": [
+ "cycle_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "issue_column_id_project_column_id_fk": {
+ "name": "issue_column_id_project_column_id_fk",
+ "tableFrom": "issue",
+ "tableTo": "project_column",
+ "columnsFrom": [
+ "column_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "issue_parent_id_issue_id_fk": {
+ "name": "issue_parent_id_issue_id_fk",
+ "tableFrom": "issue",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "parent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "issue_assignee_user_id_user_id_fk": {
+ "name": "issue_assignee_user_id_user_id_fk",
+ "tableFrom": "issue",
+ "tableTo": "user",
+ "columnsFrom": [
+ "assignee_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "issue_delegate_user_id_user_id_fk": {
+ "name": "issue_delegate_user_id_user_id_fk",
+ "tableFrom": "issue",
+ "tableTo": "user",
+ "columnsFrom": [
+ "delegate_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_share_token_unique": {
+ "name": "issue_share_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "share_token"
+ ]
+ },
+ "issue_project_id_sequence_number_unique": {
+ "name": "issue_project_id_sequence_number_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "sequence_number"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "issue_estimate_points_check": {
+ "name": "issue_estimate_points_check",
+ "value": "\"issue\".\"estimate_points\" >= 0"
+ },
+ "issue_estimate_minutes_check": {
+ "name": "issue_estimate_minutes_check",
+ "value": "\"issue\".\"estimate_minutes\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.issue_activity": {
+ "name": "issue_activity",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "initiative_id": {
+ "name": "initiative_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reply_to_id": {
+ "name": "reply_to_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "edited_at": {
+ "name": "edited_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_activity_issue_idx": {
+ "name": "issue_activity_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_activity_reply_idx": {
+ "name": "issue_activity_reply_idx",
+ "columns": [
+ {
+ "expression": "reply_to_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_activity_initiative_idx": {
+ "name": "issue_activity_initiative_idx",
+ "columns": [
+ {
+ "expression": "initiative_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_activity_issue_id_issue_id_fk": {
+ "name": "issue_activity_issue_id_issue_id_fk",
+ "tableFrom": "issue_activity",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_activity_initiative_id_initiative_id_fk": {
+ "name": "issue_activity_initiative_id_initiative_id_fk",
+ "tableFrom": "issue_activity",
+ "tableTo": "initiative",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_activity_reply_to_id_issue_activity_id_fk": {
+ "name": "issue_activity_reply_to_id_issue_activity_id_fk",
+ "tableFrom": "issue_activity",
+ "tableTo": "issue_activity",
+ "columnsFrom": [
+ "reply_to_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_activity_actor_user_id_user_id_fk": {
+ "name": "issue_activity_actor_user_id_user_id_fk",
+ "tableFrom": "issue_activity",
+ "tableTo": "user",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "issue_activity_kind_check": {
+ "name": "issue_activity_kind_check",
+ "value": "\"issue_activity\".\"kind\" IN ('comment', 'activity')"
+ },
+ "issue_activity_owner_check": {
+ "name": "issue_activity_owner_check",
+ "value": "(\"issue_activity\".\"issue_id\" IS NOT NULL) <> (\"issue_activity\".\"initiative_id\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.issue_attachment": {
+ "name": "issue_attachment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content_type": {
+ "name": "content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_attachment_issue_idx": {
+ "name": "issue_attachment_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_attachment_issue_id_issue_id_fk": {
+ "name": "issue_attachment_issue_id_issue_id_fk",
+ "tableFrom": "issue_attachment",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_attachment_public_id_unique": {
+ "name": "issue_attachment_public_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "public_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_checklist": {
+ "name": "issue_checklist",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_checklist_issue_idx": {
+ "name": "issue_checklist_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_checklist_issue_id_issue_id_fk": {
+ "name": "issue_checklist_issue_id_issue_id_fk",
+ "tableFrom": "issue_checklist",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_checklist_item": {
+ "name": "issue_checklist_item",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "checklist_id": {
+ "name": "checklist_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "done": {
+ "name": "done",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_checklist_item_checklist_idx": {
+ "name": "issue_checklist_item_checklist_idx",
+ "columns": [
+ {
+ "expression": "checklist_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_checklist_item_checklist_id_issue_checklist_id_fk": {
+ "name": "issue_checklist_item_checklist_id_issue_checklist_id_fk",
+ "tableFrom": "issue_checklist_item",
+ "tableTo": "issue_checklist",
+ "columnsFrom": [
+ "checklist_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_cycle": {
+ "name": "issue_cycle",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cycle_id": {
+ "name": "cycle_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "entered_at": {
+ "name": "entered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "left_at": {
+ "name": "left_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "issue_cycle_issue_idx": {
+ "name": "issue_cycle_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "entered_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_cycle_cycle_idx": {
+ "name": "issue_cycle_cycle_idx",
+ "columns": [
+ {
+ "expression": "cycle_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_cycle_open_idx": {
+ "name": "issue_cycle_open_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "cycle_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"issue_cycle\".\"left_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_cycle_issue_id_issue_id_fk": {
+ "name": "issue_cycle_issue_id_issue_id_fk",
+ "tableFrom": "issue_cycle",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_cycle_cycle_id_cycle_id_fk": {
+ "name": "issue_cycle_cycle_id_cycle_id_fk",
+ "tableFrom": "issue_cycle",
+ "tableTo": "cycle",
+ "columnsFrom": [
+ "cycle_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_development_check": {
+ "name": "issue_development_check",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "development_link_id": {
+ "name": "development_link_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "app_id": {
+ "name": "app_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_development_check_link_sha_idx": {
+ "name": "issue_development_check_link_sha_idx",
+ "columns": [
+ {
+ "expression": "development_link_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "head_sha",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_development_check_development_link_id_issue_development_link_id_fk": {
+ "name": "issue_development_check_development_link_id_issue_development_link_id_fk",
+ "tableFrom": "issue_development_check",
+ "tableTo": "issue_development_link",
+ "columnsFrom": [
+ "development_link_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_development_check_development_link_id_app_id_name_unique": {
+ "name": "issue_development_check_development_link_id_app_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "development_link_id",
+ "app_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_development_link": {
+ "name": "issue_development_link",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pull_request'"
+ },
+ "external_key": {
+ "name": "external_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number": {
+ "name": "number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "state": {
+ "name": "state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "draft": {
+ "name": "draft",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "source_branch": {
+ "name": "source_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_branch": {
+ "name": "target_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pipeline_status": {
+ "name": "pipeline_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pipeline_url": {
+ "name": "pipeline_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_development_link_issue_idx": {
+ "name": "issue_development_link_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_development_link_pr_idx": {
+ "name": "issue_development_link_pr_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repository",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_development_link_sha_idx": {
+ "name": "issue_development_link_sha_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repository",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "head_sha",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_development_link_issue_id_issue_id_fk": {
+ "name": "issue_development_link_issue_id_issue_id_fk",
+ "tableFrom": "issue_development_link",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_development_link_issue_id_provider_repository_external_key_unique": {
+ "name": "issue_development_link_issue_id_provider_repository_external_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "issue_id",
+ "provider",
+ "repository",
+ "external_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_field_option": {
+ "name": "issue_field_option",
+ "schema": "",
+ "columns": {
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "option_id": {
+ "name": "option_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_field_option_issue_id_issue_id_fk": {
+ "name": "issue_field_option_issue_id_issue_id_fk",
+ "tableFrom": "issue_field_option",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_field_option_field_id_custom_field_id_fk": {
+ "name": "issue_field_option_field_id_custom_field_id_fk",
+ "tableFrom": "issue_field_option",
+ "tableTo": "custom_field",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_field_option_option_id_custom_field_option_id_fk": {
+ "name": "issue_field_option_option_id_custom_field_option_id_fk",
+ "tableFrom": "issue_field_option",
+ "tableTo": "custom_field_option",
+ "columnsFrom": [
+ "option_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "issue_field_option_issue_id_field_id_option_id_pk": {
+ "name": "issue_field_option_issue_id_field_id_option_id_pk",
+ "columns": [
+ "issue_id",
+ "field_id",
+ "option_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_field_value": {
+ "name": "issue_field_value",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value_text": {
+ "name": "value_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_number": {
+ "name": "value_number",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_bool": {
+ "name": "value_bool",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_date": {
+ "name": "value_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_datetime": {
+ "name": "value_datetime",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_datetime_end": {
+ "name": "value_datetime_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_user_id": {
+ "name": "value_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_field_value_issue_id_issue_id_fk": {
+ "name": "issue_field_value_issue_id_issue_id_fk",
+ "tableFrom": "issue_field_value",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_field_value_field_id_custom_field_id_fk": {
+ "name": "issue_field_value_field_id_custom_field_id_fk",
+ "tableFrom": "issue_field_value",
+ "tableTo": "custom_field",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_field_value_value_user_id_user_id_fk": {
+ "name": "issue_field_value_value_user_id_user_id_fk",
+ "tableFrom": "issue_field_value",
+ "tableTo": "user",
+ "columnsFrom": [
+ "value_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_field_value_issue_id_field_id_unique": {
+ "name": "issue_field_value_issue_id_field_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "issue_id",
+ "field_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_import": {
+ "name": "issue_import",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachment_id": {
+ "name": "attachment_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'mapped'"
+ },
+ "mapping": {
+ "name": "mapping",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_text": {
+ "name": "error_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_import_project_idx": {
+ "name": "issue_import_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_import_project_id_project_id_fk": {
+ "name": "issue_import_project_id_project_id_fk",
+ "tableFrom": "issue_import",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_import_attachment_id_chat_attachment_id_fk": {
+ "name": "issue_import_attachment_id_chat_attachment_id_fk",
+ "tableFrom": "issue_import",
+ "tableTo": "chat_attachment",
+ "columnsFrom": [
+ "attachment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_import_public_id_unique": {
+ "name": "issue_import_public_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "public_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_key_alias": {
+ "name": "issue_key_alias",
+ "schema": "",
+ "columns": {
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence_number": {
+ "name": "sequence_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "issue_key_alias_issue_idx": {
+ "name": "issue_key_alias_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_key_alias_project_id_project_id_fk": {
+ "name": "issue_key_alias_project_id_project_id_fk",
+ "tableFrom": "issue_key_alias",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_key_alias_issue_id_issue_id_fk": {
+ "name": "issue_key_alias_issue_id_issue_id_fk",
+ "tableFrom": "issue_key_alias",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "issue_key_alias_project_id_sequence_number_pk": {
+ "name": "issue_key_alias_project_id_sequence_number_pk",
+ "columns": [
+ "project_id",
+ "sequence_number"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_label": {
+ "name": "issue_label",
+ "schema": "",
+ "columns": {
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label_id": {
+ "name": "label_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_label_issue_id_issue_id_fk": {
+ "name": "issue_label_issue_id_issue_id_fk",
+ "tableFrom": "issue_label",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_label_label_id_label_id_fk": {
+ "name": "issue_label_label_id_label_id_fk",
+ "tableFrom": "issue_label",
+ "tableTo": "label",
+ "columnsFrom": [
+ "label_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "issue_label_issue_id_label_id_pk": {
+ "name": "issue_label_issue_id_label_id_pk",
+ "columns": [
+ "issue_id",
+ "label_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_link": {
+ "name": "issue_link",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "source_issue_id": {
+ "name": "source_issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_issue_id": {
+ "name": "target_issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_link_pair_kind_idx": {
+ "name": "issue_link_pair_kind_idx",
+ "columns": [
+ {
+ "expression": "least(\"source_issue_id\", \"target_issue_id\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "greatest(\"source_issue_id\", \"target_issue_id\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_link_source_idx": {
+ "name": "issue_link_source_idx",
+ "columns": [
+ {
+ "expression": "source_issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_link_target_idx": {
+ "name": "issue_link_target_idx",
+ "columns": [
+ {
+ "expression": "target_issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_link_source_issue_id_issue_id_fk": {
+ "name": "issue_link_source_issue_id_issue_id_fk",
+ "tableFrom": "issue_link",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "source_issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_link_target_issue_id_issue_id_fk": {
+ "name": "issue_link_target_issue_id_issue_id_fk",
+ "tableFrom": "issue_link",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "target_issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "issue_link_kind_check": {
+ "name": "issue_link_kind_check",
+ "value": "\"issue_link\".\"kind\" IN ('blocks', 'relates', 'duplicates')"
+ },
+ "issue_link_self_check": {
+ "name": "issue_link_self_check",
+ "value": "\"issue_link\".\"source_issue_id\" <> \"issue_link\".\"target_issue_id\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.issue_status": {
+ "name": "issue_status",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "column_id": {
+ "name": "column_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "column_name": {
+ "name": "column_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "state_type": {
+ "name": "state_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "entered_at": {
+ "name": "entered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "left_at": {
+ "name": "left_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "issue_status_issue_idx": {
+ "name": "issue_status_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "entered_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_status_column_idx": {
+ "name": "issue_status_column_idx",
+ "columns": [
+ {
+ "expression": "column_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"issue_status\".\"column_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_status_open_idx": {
+ "name": "issue_status_open_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"issue_status\".\"left_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_status_issue_id_issue_id_fk": {
+ "name": "issue_status_issue_id_issue_id_fk",
+ "tableFrom": "issue_status",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_status_column_id_project_column_id_fk": {
+ "name": "issue_status_column_id_project_column_id_fk",
+ "tableFrom": "issue_status",
+ "tableTo": "project_column",
+ "columnsFrom": [
+ "column_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_template": {
+ "name": "issue_template",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "title_template": {
+ "name": "title_template",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "description_template": {
+ "name": "description_template",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "type_id": {
+ "name": "type_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "column_id": {
+ "name": "column_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assignee_user_id": {
+ "name": "assignee_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_template_project_id_project_id_fk": {
+ "name": "issue_template_project_id_project_id_fk",
+ "tableFrom": "issue_template",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_template_type_id_issue_type_id_fk": {
+ "name": "issue_template_type_id_issue_type_id_fk",
+ "tableFrom": "issue_template",
+ "tableTo": "issue_type",
+ "columnsFrom": [
+ "type_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "issue_template_column_id_project_column_id_fk": {
+ "name": "issue_template_column_id_project_column_id_fk",
+ "tableFrom": "issue_template",
+ "tableTo": "project_column",
+ "columnsFrom": [
+ "column_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "issue_template_assignee_user_id_user_id_fk": {
+ "name": "issue_template_assignee_user_id_user_id_fk",
+ "tableFrom": "issue_template",
+ "tableTo": "user",
+ "columnsFrom": [
+ "assignee_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_template_project_id_name_unique": {
+ "name": "issue_template_project_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_template_label": {
+ "name": "issue_template_label",
+ "schema": "",
+ "columns": {
+ "template_id": {
+ "name": "template_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label_id": {
+ "name": "label_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_template_label_template_id_issue_template_id_fk": {
+ "name": "issue_template_label_template_id_issue_template_id_fk",
+ "tableFrom": "issue_template_label",
+ "tableTo": "issue_template",
+ "columnsFrom": [
+ "template_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_template_label_label_id_label_id_fk": {
+ "name": "issue_template_label_label_id_label_id_fk",
+ "tableFrom": "issue_template_label",
+ "tableTo": "label",
+ "columnsFrom": [
+ "label_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "issue_template_label_template_id_label_id_pk": {
+ "name": "issue_template_label_template_id_label_id_pk",
+ "columns": [
+ "template_id",
+ "label_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_type": {
+ "name": "issue_type",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#6b7280'"
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_type_project_id_project_id_fk": {
+ "name": "issue_type_project_id_project_id_fk",
+ "tableFrom": "issue_type",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_type_project_id_name_unique": {
+ "name": "issue_type_project_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_watcher": {
+ "name": "issue_watcher",
+ "schema": "",
+ "columns": {
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "subscribed": {
+ "name": "subscribed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_watcher_issue_id_issue_id_fk": {
+ "name": "issue_watcher_issue_id_issue_id_fk",
+ "tableFrom": "issue_watcher",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_watcher_user_id_user_id_fk": {
+ "name": "issue_watcher_user_id_user_id_fk",
+ "tableFrom": "issue_watcher",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "issue_watcher_issue_id_user_id_pk": {
+ "name": "issue_watcher_issue_id_user_id_pk",
+ "columns": [
+ "issue_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_worklog": {
+ "name": "issue_worklog",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "minutes": {
+ "name": "minutes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "spent_on": {
+ "name": "spent_on",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "note": {
+ "name": "note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_worklog_issue_idx": {
+ "name": "issue_worklog_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "spent_on",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_worklog_issue_id_issue_id_fk": {
+ "name": "issue_worklog_issue_id_issue_id_fk",
+ "tableFrom": "issue_worklog",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_worklog_user_id_user_id_fk": {
+ "name": "issue_worklog_user_id_user_id_fk",
+ "tableFrom": "issue_worklog",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "issue_worklog_minutes_check": {
+ "name": "issue_worklog_minutes_check",
+ "value": "\"issue_worklog\".\"minutes\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.label": {
+ "name": "label",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#6b7280'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "label_project_id_project_id_fk": {
+ "name": "label_project_id_project_id_fk",
+ "tableFrom": "label",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "label_group_id_label_group_id_fk": {
+ "name": "label_group_id_label_group_id_fk",
+ "tableFrom": "label",
+ "tableTo": "label_group",
+ "columnsFrom": [
+ "group_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "label_project_id_name_unique": {
+ "name": "label_project_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.label_group": {
+ "name": "label_group",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#6b7280'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "label_group_project_id_project_id_fk": {
+ "name": "label_group_project_id_project_id_fk",
+ "tableFrom": "label_group",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "label_group_project_id_name_unique": {
+ "name": "label_group_project_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.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
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "next_sequence": {
+ "name": "next_sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "mcp_enabled": {
+ "name": "mcp_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "initiatives_enabled": {
+ "name": "initiatives_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "dashboards_enabled": {
+ "name": "dashboards_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "documents_enabled": {
+ "name": "documents_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "notes_enabled": {
+ "name": "notes_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "cycles_enabled": {
+ "name": "cycles_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "subtasks_enabled": {
+ "name": "subtasks_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "checklists_enabled": {
+ "name": "checklists_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "issue_stats_enabled": {
+ "name": "issue_stats_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "points_estimate_enabled": {
+ "name": "points_estimate_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "time_estimate_enabled": {
+ "name": "time_estimate_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "time_logging_enabled": {
+ "name": "time_logging_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_team_id_team_id_fk": {
+ "name": "project_team_id_team_id_fk",
+ "tableFrom": "project",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_team_key_uq": {
+ "name": "project_team_key_uq",
+ "nullsNotDistinct": false,
+ "columns": [
+ "team_id",
+ "key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_action": {
+ "name": "project_action",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "condition": {
+ "name": "condition",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "effect": {
+ "name": "effect",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_action_project_idx": {
+ "name": "project_action_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_action_project_id_project_id_fk": {
+ "name": "project_action_project_id_project_id_fk",
+ "tableFrom": "project_action",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_column": {
+ "name": "project_column",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_type": {
+ "name": "state_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unstarted'"
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#6b7280'"
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wip_limit": {
+ "name": "wip_limit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wip_mode": {
+ "name": "wip_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'soft'"
+ },
+ "auto_assign_user_id": {
+ "name": "auto_assign_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_column_project_id_project_id_fk": {
+ "name": "project_column_project_id_project_id_fk",
+ "tableFrom": "project_column",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_column_auto_assign_user_id_user_id_fk": {
+ "name": "project_column_auto_assign_user_id_user_id_fk",
+ "tableFrom": "project_column",
+ "tableTo": "user",
+ "columnsFrom": [
+ "auto_assign_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_column_project_id_position_unique": {
+ "name": "project_column_project_id_position_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "position"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "project_column_state_type_check": {
+ "name": "project_column_state_type_check",
+ "value": "\"project_column\".\"state_type\" IN ('backlog', 'unstarted', 'started', 'completed', 'canceled')"
+ },
+ "project_column_wip_mode_check": {
+ "name": "project_column_wip_mode_check",
+ "value": "\"project_column\".\"wip_mode\" IN ('soft', 'hard')"
+ },
+ "project_column_wip_limit_check": {
+ "name": "project_column_wip_limit_check",
+ "value": "\"project_column\".\"wip_limit\" IS NULL OR \"project_column\".\"wip_limit\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_dashboard": {
+ "name": "project_dashboard",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "layout": {
+ "name": "layout",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_dashboard_project_idx": {
+ "name": "project_dashboard_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_dashboard_project_id_project_id_fk": {
+ "name": "project_dashboard_project_id_project_id_fk",
+ "tableFrom": "project_dashboard",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_document": {
+ "name": "project_document",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "content_json": {
+ "name": "content_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "full_width": {
+ "name": "full_width",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_private": {
+ "name": "is_private",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_locked": {
+ "name": "is_locked",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_by_ancestor_id": {
+ "name": "archived_by_ancestor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_by_user_id": {
+ "name": "updated_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_document_project_tree_idx": {
+ "name": "project_document_project_tree_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_document_owner_idx": {
+ "name": "project_document_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_document_project_archive_idx": {
+ "name": "project_document_project_archive_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "archived_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_document_project_id_project_id_fk": {
+ "name": "project_document_project_id_project_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_parent_id_project_document_id_fk": {
+ "name": "project_document_parent_id_project_document_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "parent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_document_archived_by_ancestor_id_project_document_id_fk": {
+ "name": "project_document_archived_by_ancestor_id_project_document_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "archived_by_ancestor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_document_owner_user_id_user_id_fk": {
+ "name": "project_document_owner_user_id_user_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_document_created_by_user_id_user_id_fk": {
+ "name": "project_document_created_by_user_id_user_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_document_updated_by_user_id_user_id_fk": {
+ "name": "project_document_updated_by_user_id_user_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "user",
+ "columnsFrom": [
+ "updated_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "project_document_version_check": {
+ "name": "project_document_version_check",
+ "value": "\"project_document\".\"version\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_document_initiative": {
+ "name": "project_document_initiative",
+ "schema": "",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "initiative_id": {
+ "name": "initiative_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_document_initiative_initiative_idx": {
+ "name": "project_document_initiative_initiative_idx",
+ "columns": [
+ {
+ "expression": "initiative_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_document_initiative_document_id_project_document_id_fk": {
+ "name": "project_document_initiative_document_id_project_document_id_fk",
+ "tableFrom": "project_document_initiative",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_initiative_initiative_id_initiative_id_fk": {
+ "name": "project_document_initiative_initiative_id_initiative_id_fk",
+ "tableFrom": "project_document_initiative",
+ "tableTo": "initiative",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_initiative_created_by_user_id_user_id_fk": {
+ "name": "project_document_initiative_created_by_user_id_user_id_fk",
+ "tableFrom": "project_document_initiative",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_document_initiative_document_id_initiative_id_pk": {
+ "name": "project_document_initiative_document_id_initiative_id_pk",
+ "columns": [
+ "document_id",
+ "initiative_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_document_issue": {
+ "name": "project_document_issue",
+ "schema": "",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_document_issue_issue_idx": {
+ "name": "project_document_issue_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_document_issue_document_id_project_document_id_fk": {
+ "name": "project_document_issue_document_id_project_document_id_fk",
+ "tableFrom": "project_document_issue",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_issue_issue_id_issue_id_fk": {
+ "name": "project_document_issue_issue_id_issue_id_fk",
+ "tableFrom": "project_document_issue",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_issue_created_by_user_id_user_id_fk": {
+ "name": "project_document_issue_created_by_user_id_user_id_fk",
+ "tableFrom": "project_document_issue",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_document_issue_document_id_issue_id_pk": {
+ "name": "project_document_issue_document_id_issue_id_pk",
+ "columns": [
+ "document_id",
+ "issue_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_document_preference": {
+ "name": "project_document_preference",
+ "schema": "",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_favorite": {
+ "name": "is_favorite",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_document_preference_user_idx": {
+ "name": "project_document_preference_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_document_preference_document_id_project_document_id_fk": {
+ "name": "project_document_preference_document_id_project_document_id_fk",
+ "tableFrom": "project_document_preference",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_preference_user_id_user_id_fk": {
+ "name": "project_document_preference_user_id_user_id_fk",
+ "tableFrom": "project_document_preference",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_document_preference_document_id_user_id_pk": {
+ "name": "project_document_preference_document_id_user_id_pk",
+ "columns": [
+ "document_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_document_revision": {
+ "name": "project_document_revision",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content_json": {
+ "name": "content_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "full_width": {
+ "name": "full_width",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_private": {
+ "name": "is_private",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_locked": {
+ "name": "is_locked",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_document_revision_document_idx": {
+ "name": "project_document_revision_document_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "version",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_document_revision_document_id_project_document_id_fk": {
+ "name": "project_document_revision_document_id_project_document_id_fk",
+ "tableFrom": "project_document_revision",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_revision_owner_user_id_user_id_fk": {
+ "name": "project_document_revision_owner_user_id_user_id_fk",
+ "tableFrom": "project_document_revision",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_document_revision_created_by_user_id_user_id_fk": {
+ "name": "project_document_revision_created_by_user_id_user_id_fk",
+ "tableFrom": "project_document_revision",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_document_revision_document_version_unique": {
+ "name": "project_document_revision_document_version_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "document_id",
+ "version"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_member": {
+ "name": "project_member",
+ "schema": "",
+ "columns": {
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "role_id": {
+ "name": "role_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'invite'"
+ },
+ "is_favorite": {
+ "name": "is_favorite",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_hidden": {
+ "name": "is_hidden",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_member_user_idx": {
+ "name": "project_member_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_member_project_id_project_id_fk": {
+ "name": "project_member_project_id_project_id_fk",
+ "tableFrom": "project_member",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_member_user_id_user_id_fk": {
+ "name": "project_member_user_id_user_id_fk",
+ "tableFrom": "project_member",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_member_role_id_team_role_id_fk": {
+ "name": "project_member_role_id_team_role_id_fk",
+ "tableFrom": "project_member",
+ "tableTo": "team_role",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_member_project_id_user_id_pk": {
+ "name": "project_member_project_id_user_id_pk",
+ "columns": [
+ "project_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "project_member_role_check": {
+ "name": "project_member_role_check",
+ "value": "\"project_member\".\"role\" IN ('owner', 'member')"
+ },
+ "project_member_source_check": {
+ "name": "project_member_source_check",
+ "value": "\"project_member\".\"source\" IN ('invite', 'scim')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_setting": {
+ "name": "project_setting",
+ "schema": "",
+ "columns": {
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_setting_project_id_project_id_fk": {
+ "name": "project_setting_project_id_project_id_fk",
+ "tableFrom": "project_setting",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_setting_project_id_key_pk": {
+ "name": "project_setting_project_id_key_pk",
+ "columns": [
+ "project_id",
+ "key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_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.team": {
+ "name": "team",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mcp_enabled": {
+ "name": "mcp_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "default_agent_ids": {
+ "name": "default_agent_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "team_workspace_idx": {
+ "name": "team_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "team_workspace_id_workspace_id_fk": {
+ "name": "team_workspace_id_workspace_id_fk",
+ "tableFrom": "team",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "team_slug_unique": {
+ "name": "team_slug_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_invite": {
+ "name": "team_invite",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "team_role": {
+ "name": "team_role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "project_role": {
+ "name": "project_role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "role_id": {
+ "name": "role_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "invited_by_user_id": {
+ "name": "invited_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by_user_id": {
+ "name": "accepted_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "responded_at": {
+ "name": "responded_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "team_invite_team_pending_uq": {
+ "name": "team_invite_team_pending_uq",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"team_invite\".\"status\" = 'pending' AND \"team_invite\".\"project_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "team_invite_project_pending_uq": {
+ "name": "team_invite_project_pending_uq",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"team_invite\".\"status\" = 'pending' AND \"team_invite\".\"project_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "team_invite_team_idx": {
+ "name": "team_invite_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "team_invite_project_idx": {
+ "name": "team_invite_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "team_invite_team_id_team_id_fk": {
+ "name": "team_invite_team_id_team_id_fk",
+ "tableFrom": "team_invite",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "team_invite_project_id_project_id_fk": {
+ "name": "team_invite_project_id_project_id_fk",
+ "tableFrom": "team_invite",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "team_invite_role_id_team_role_id_fk": {
+ "name": "team_invite_role_id_team_role_id_fk",
+ "tableFrom": "team_invite",
+ "tableTo": "team_role",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "team_invite_invited_by_user_id_user_id_fk": {
+ "name": "team_invite_invited_by_user_id_user_id_fk",
+ "tableFrom": "team_invite",
+ "tableTo": "user",
+ "columnsFrom": [
+ "invited_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "team_invite_accepted_by_user_id_user_id_fk": {
+ "name": "team_invite_accepted_by_user_id_user_id_fk",
+ "tableFrom": "team_invite",
+ "tableTo": "user",
+ "columnsFrom": [
+ "accepted_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "team_invite_token_unique": {
+ "name": "team_invite_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "team_invite_team_role_check": {
+ "name": "team_invite_team_role_check",
+ "value": "\"team_invite\".\"team_role\" IN ('owner', 'manager', 'member')"
+ },
+ "team_invite_project_role_check": {
+ "name": "team_invite_project_role_check",
+ "value": "(\"team_invite\".\"project_id\" IS NULL AND \"team_invite\".\"project_role\" IS NULL)\n OR (\"team_invite\".\"project_id\" IS NOT NULL AND \"team_invite\".\"project_role\" IN ('owner', 'member'))"
+ },
+ "team_invite_status_check": {
+ "name": "team_invite_status_check",
+ "value": "\"team_invite\".\"status\" IN ('pending', 'accepted', 'rejected')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.team_member": {
+ "name": "team_member",
+ "schema": "",
+ "columns": {
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'invite'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "team_member_user_idx": {
+ "name": "team_member_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "team_member_team_id_team_id_fk": {
+ "name": "team_member_team_id_team_id_fk",
+ "tableFrom": "team_member",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "team_member_user_id_user_id_fk": {
+ "name": "team_member_user_id_user_id_fk",
+ "tableFrom": "team_member",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "team_member_team_id_user_id_pk": {
+ "name": "team_member_team_id_user_id_pk",
+ "columns": [
+ "team_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "team_member_role_check": {
+ "name": "team_member_role_check",
+ "value": "\"team_member\".\"role\" IN ('owner', 'manager', 'member', 'agent')"
+ },
+ "team_member_source_check": {
+ "name": "team_member_source_check",
+ "value": "\"team_member\".\"source\" IN ('invite', 'scim')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.team_notification_setting": {
+ "name": "team_notification_setting",
+ "schema": "",
+ "columns": {
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "ciphertext": {
+ "name": "ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "iv": {
+ "name": "iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_tag": {
+ "name": "auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redacted": {
+ "name": "redacted",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_notification_setting_team_id_team_id_fk": {
+ "name": "team_notification_setting_team_id_team_id_fk",
+ "tableFrom": "team_notification_setting",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_role": {
+ "name": "team_role",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": 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": {
+ "team_role_default_uq": {
+ "name": "team_role_default_uq",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"team_role\".\"is_default\"",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "team_role_team_idx": {
+ "name": "team_role_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "team_role_team_id_team_id_fk": {
+ "name": "team_role_team_id_team_id_fk",
+ "tableFrom": "team_role",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "team_role_team_id_name_unique": {
+ "name": "team_role_team_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "team_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_notification_preference": {
+ "name": "user_notification_preference",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_events": {
+ "name": "email_events",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "telegram_events": {
+ "name": "telegram_events",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_notification_preference_user_id_user_id_fk": {
+ "name": "user_notification_preference_user_id_user_id_fk",
+ "tableFrom": "user_notification_preference",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_notification_preference_project_id_project_id_fk": {
+ "name": "user_notification_preference_project_id_project_id_fk",
+ "tableFrom": "user_notification_preference",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_notification_pref_user_project_unique": {
+ "name": "user_notification_pref_user_project_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_preference": {
+ "name": "user_preference",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "timezone": {
+ "name": "timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'UTC'"
+ },
+ "locale": {
+ "name": "locale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'en'"
+ },
+ "theme": {
+ "name": "theme",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'system'"
+ },
+ "issue_open_mode": {
+ "name": "issue_open_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'panel'"
+ },
+ "start_page": {
+ "name": "start_page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'work-items'"
+ },
+ "show_chat_by_default": {
+ "name": "show_chat_by_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "issue_stats_open": {
+ "name": "issue_stats_open",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "issue_stats_view": {
+ "name": "issue_stats_view",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'compact'"
+ },
+ "issue_activity_view": {
+ "name": "issue_activity_view",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'flat'"
+ },
+ "auto_watch": {
+ "name": "auto_watch",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "hotkeys": {
+ "name": "hotkeys",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_project_id": {
+ "name": "last_project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "seen_version": {
+ "name": "seen_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_preference_user_id_user_id_fk": {
+ "name": "user_preference_user_id_user_id_fk",
+ "tableFrom": "user_preference",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_preference_last_project_id_project_id_fk": {
+ "name": "user_preference_last_project_id_project_id_fk",
+ "tableFrom": "user_preference",
+ "tableTo": "project",
+ "columnsFrom": [
+ "last_project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "user_preference_theme_check": {
+ "name": "user_preference_theme_check",
+ "value": "\"user_preference\".\"theme\" IN ('light', 'dark', 'system')"
+ },
+ "user_preference_issue_open_mode_check": {
+ "name": "user_preference_issue_open_mode_check",
+ "value": "\"user_preference\".\"issue_open_mode\" IN ('panel', 'page')"
+ },
+ "user_preference_start_page_check": {
+ "name": "user_preference_start_page_check",
+ "value": "\"user_preference\".\"start_page\" IN ('inbox', 'dashboard', 'work-items', 'initiatives')"
+ },
+ "user_preference_issue_stats_view_check": {
+ "name": "user_preference_issue_stats_view_check",
+ "value": "\"user_preference\".\"issue_stats_view\" IN ('compact', 'timeline')"
+ },
+ "user_preference_issue_activity_view_check": {
+ "name": "user_preference_issue_activity_view_check",
+ "value": "\"user_preference\".\"issue_activity_view\" IN ('flat', 'grouped')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_telegram_account": {
+ "name": "user_telegram_account",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "username": {
+ "name": "username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "link_code": {
+ "name": "link_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "link_code_expires_at": {
+ "name": "link_code_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "linked_at": {
+ "name": "linked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_telegram_account_chat_id_unique": {
+ "name": "user_telegram_account_chat_id_unique",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"user_telegram_account\".\"chat_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_telegram_account_link_code_unique": {
+ "name": "user_telegram_account_link_code_unique",
+ "columns": [
+ {
+ "expression": "link_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"user_telegram_account\".\"link_code\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_telegram_account_user_id_user_id_fk": {
+ "name": "user_telegram_account_user_id_user_id_fk",
+ "tableFrom": "user_telegram_account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.webhook": {
+ "name": "webhook",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "secret": {
+ "name": "secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "events": {
+ "name": "events",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "consecutive_failures": {
+ "name": "consecutive_failures",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "webhook_project_idx": {
+ "name": "webhook_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "webhook_project_id_project_id_fk": {
+ "name": "webhook_project_id_project_id_fk",
+ "tableFrom": "webhook",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.webhook_delivery": {
+ "name": "webhook_delivery",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "webhook_id": {
+ "name": "webhook_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_id": {
+ "name": "event_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_status": {
+ "name": "response_status",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_body": {
+ "name": "response_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "webhook_delivery_due_idx": {
+ "name": "webhook_delivery_due_idx",
+ "columns": [
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"webhook_delivery\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "webhook_delivery_webhook_idx": {
+ "name": "webhook_delivery_webhook_idx",
+ "columns": [
+ {
+ "expression": "webhook_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "webhook_delivery_webhook_id_webhook_id_fk": {
+ "name": "webhook_delivery_webhook_id_webhook_id_fk",
+ "tableFrom": "webhook_delivery",
+ "tableTo": "webhook",
+ "columnsFrom": [
+ "webhook_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace": {
+ "name": "workspace",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "team_creation": {
+ "name": "team_creation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'owner'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "workspace_team_creation_check": {
+ "name": "workspace_team_creation_check",
+ "value": "\"workspace\".\"team_creation\" IN ('owner', 'managers', 'members')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.workspace_manager": {
+ "name": "workspace_manager",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'admin'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_manager_owner_uq": {
+ "name": "workspace_manager_owner_uq",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"workspace_manager\".\"role\" = 'owner'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_manager_user_idx": {
+ "name": "workspace_manager_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_manager_workspace_id_workspace_id_fk": {
+ "name": "workspace_manager_workspace_id_workspace_id_fk",
+ "tableFrom": "workspace_manager",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_manager_user_id_user_id_fk": {
+ "name": "workspace_manager_user_id_user_id_fk",
+ "tableFrom": "workspace_manager",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_manager_workspace_id_user_id_pk": {
+ "name": "workspace_manager_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "workspace_manager_role_check": {
+ "name": "workspace_manager_role_check",
+ "value": "\"workspace_manager\".\"role\" IN ('owner', 'admin')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.scim_group": {
+ "name": "scim_group",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "display_name": {
+ "name": "display_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "scim_group_workspace_id_workspace_id_fk": {
+ "name": "scim_group_workspace_id_workspace_id_fk",
+ "tableFrom": "scim_group",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "scim_group_workspace_id_display_name_unique": {
+ "name": "scim_group_workspace_id_display_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "workspace_id",
+ "display_name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scim_group_mapping": {
+ "name": "scim_group_mapping",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "role_id": {
+ "name": "role_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "scim_group_mapping_project_idx": {
+ "name": "scim_group_mapping_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scim_group_mapping_group_id_scim_group_id_fk": {
+ "name": "scim_group_mapping_group_id_scim_group_id_fk",
+ "tableFrom": "scim_group_mapping",
+ "tableTo": "scim_group",
+ "columnsFrom": [
+ "group_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "scim_group_mapping_project_id_project_id_fk": {
+ "name": "scim_group_mapping_project_id_project_id_fk",
+ "tableFrom": "scim_group_mapping",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "scim_group_mapping_role_id_team_role_id_fk": {
+ "name": "scim_group_mapping_role_id_team_role_id_fk",
+ "tableFrom": "scim_group_mapping",
+ "tableTo": "team_role",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "scim_group_mapping_group_id_project_id_unique": {
+ "name": "scim_group_mapping_group_id_project_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "group_id",
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "scim_group_mapping_role_check": {
+ "name": "scim_group_mapping_role_check",
+ "value": "\"scim_group_mapping\".\"role\" IN ('owner', 'member')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.scim_group_member": {
+ "name": "scim_group_member",
+ "schema": "",
+ "columns": {
+ "group_id": {
+ "name": "group_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "scim_group_member_user_idx": {
+ "name": "scim_group_member_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scim_group_member_group_id_scim_group_id_fk": {
+ "name": "scim_group_member_group_id_scim_group_id_fk",
+ "tableFrom": "scim_group_member",
+ "tableTo": "scim_group",
+ "columnsFrom": [
+ "group_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "scim_group_member_user_id_user_id_fk": {
+ "name": "scim_group_member_user_id_user_id_fk",
+ "tableFrom": "scim_group_member",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "scim_group_member_group_id_user_id_pk": {
+ "name": "scim_group_member_group_id_user_id_pk",
+ "columns": [
+ "group_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scim_user": {
+ "name": "scim_user",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "scim_user_user_idx": {
+ "name": "scim_user_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scim_user_workspace_id_workspace_id_fk": {
+ "name": "scim_user_workspace_id_workspace_id_fk",
+ "tableFrom": "scim_user",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "scim_user_user_id_user_id_fk": {
+ "name": "scim_user_user_id_user_id_fk",
+ "tableFrom": "scim_user",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "scim_user_workspace_id_user_id_pk": {
+ "name": "scim_user_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "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 0e384d91..b6c34856 100644
--- a/packages/db/drizzle/meta/_journal.json
+++ b/packages/db/drizzle/meta/_journal.json
@@ -1009,6 +1009,13 @@
"when": 1791374220064,
"tag": "0143_import_job_linear_source",
"breakpoints": true
+ },
+ {
+ "idx": 144,
+ "version": "7",
+ "when": 1791379870030,
+ "tag": "0144_agent_schedule_status_trigger",
+ "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 7573cf0d..7cbba349 100644
--- a/packages/db/src/schema/app.ts
+++ b/packages/db/src/schema/app.ts
@@ -593,28 +593,41 @@ export const agentSchedule = pgTable(
.notNull()
.references(() => project.id, { onDelete: 'cascade' }),
name: text('name').notNull(),
+ // Empty on a 'status' schedule that sends no task of its own.
prompt: text('prompt').notNull(),
- cron: text('cron').notNull(),
+ // 'cron' runs on `cron` and carries `next_run_at`; 'status' runs on an issue each
+ // time one enters `column_id`, `delay_sec` after it does.
+ type: text('type').notNull().default('cron'),
+ cron: text('cron'),
timezone: text('timezone').notNull(),
status: text('status').notNull().default('active'),
- nextRunAt: timestamp('next_run_at', { withTimezone: true }).notNull(),
+ nextRunAt: timestamp('next_run_at', { withTimezone: true }),
+ columnId: integer('column_id').references(() => projectColumn.id, { onDelete: 'cascade' }),
+ delaySec: integer('delay_sec').notNull().default(0),
lastRunAt: timestamp('last_run_at', { withTimezone: true }),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
},
(t) => [
check('agent_schedule_status_check', sql`${t.status} IN ('active', 'paused')`),
+ check(
+ 'agent_schedule_type_check',
+ sql`(${t.type} = 'cron' AND ${t.cron} IS NOT NULL AND ${t.nextRunAt} IS NOT NULL AND ${t.columnId} IS NULL)
+ OR (${t.type} = 'status' AND ${t.columnId} IS NOT NULL AND ${t.cron} IS NULL AND ${t.nextRunAt} IS NULL)`,
+ ),
+ check('agent_schedule_delay_check', sql`${t.delaySec} >= 0 AND ${t.delaySec} <= 86400`),
// A schedule works in one project, and one agent works in several projects of
// its team, so the same name is free again in each of them.
unique().on(t.projectId, t.agentId, t.name),
index('agent_schedule_due_idx').on(t.status, t.nextRunAt),
index('agent_schedule_agent_idx').on(t.agentId),
index('agent_schedule_project_idx').on(t.projectId),
+ index('agent_schedule_column_idx').on(t.columnId),
],
);
-// Queued autonomous runs of an internal agent. Mentions and delegations carry an
-// issue; scheduled and manual runs do not. The worker claims due rows with a lease,
+// Queued autonomous runs of an internal agent. A run triggered on an issue carries it;
+// a cron schedule's run and a manual one do not. The worker claims due rows with a lease,
// runs the agent, and records the result for history and retries.
export const agentRun = pgTable(
'agent_run',
@@ -665,7 +678,7 @@ export const agentRun = pgTable(
),
check(
'agent_run_trigger_check',
- sql`${t.trigger} IN ('mention', 'delegation', 'field', 'schedule', 'manual')`,
+ sql`${t.trigger} IN ('mention', 'delegation', 'field', 'schedule', 'manual', 'status')`,
),
uniqueIndex('agent_run_schedule_fire_uq').on(t.scheduleId, t.scheduledFor),
index('agent_run_due_idx').on(t.status, t.nextAttemptAt),
diff --git a/packages/runner/README.md b/packages/runner/README.md
index 34b617a6..15bc529f 100644
--- a/packages/runner/README.md
+++ b/packages/runner/README.md
@@ -200,12 +200,12 @@ sends `$ITSAPLAN_API_KEY` as a bearer token, and acts as its own user with its r
Every run holds these variables:
-| Variable | What it holds |
-| ------------------------ | ----------------------------------------------------------------- |
-| `ITSAPLAN_URL` | the instance that sent the task |
-| `ITSAPLAN_API_KEY` | the agent's key, for the API and the MCP server |
-| `ITSAPLAN_TRIGGER` | `mention`, `delegation`, `field`, `schedule`, `manual`, or `chat` |
-| `ITSAPLAN_SYSTEM_PROMPT` | the context of the run, for a command that takes a system prompt |
+| Variable | What it holds |
+| ------------------------ | --------------------------------------------------------------------------- |
+| `ITSAPLAN_URL` | the instance that sent the task |
+| `ITSAPLAN_API_KEY` | the agent's key, for the API and the MCP server |
+| `ITSAPLAN_TRIGGER` | `mention`, `delegation`, `field`, `schedule`, `manual`, `status`, or `chat` |
+| `ITSAPLAN_SYSTEM_PROMPT` | the context of the run, for a command that takes a system prompt |
A queued run adds three more:
diff --git a/packages/runner/src/client.ts b/packages/runner/src/client.ts
index 4287e89a..eda1b615 100644
--- a/packages/runner/src/client.ts
+++ b/packages/runner/src/client.ts
@@ -6,7 +6,7 @@ import type { RunnerConfig } from './config';
export interface Run {
id: number;
- trigger: 'mention' | 'delegation' | 'field' | 'schedule' | 'manual';
+ trigger: 'mention' | 'delegation' | 'field' | 'schedule' | 'manual' | 'status';
prompt: string;
systemPrompt: string;
issueId: number | null;