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: import issues from Trello (#716)

Croff0452c1aa8cb7
diff --git a/AGENTS.md b/AGENTS.md
index 9f74bac0..04b3dcc7 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -113,6 +113,7 @@ packages directly.** It talks to the API over HTTP (better-auth client + fetch).
| `docs/agent-endpoint.md` | external agents that receive tasks on their own HTTPS endpoint |
| `docs/mcp-results.md` | the shape of MCP tool results (`structuredContent`) |
| `docs/importing-from-linear.md`, `docs/dev/linear-import.md` | the Linear import: user guide, implementation |
+| `docs/importing-from-trello.md`, `docs/dev/trello-import.md` | the Trello import: user guide, implementation |
| `docs/importing-from-plane.md`, `docs/dev/plane-import.md`, `docs/dev/plane-import-source-notes.md` | the Plane import: user guide, implementation, Plane API facts |
| `docs/dev/revision-engine.md` | live updates: scopes, counters, refetch |
| `docs/dev/i18n.md` | interface languages, the language cookie |
diff --git a/apps/api/src/modules/import-export/__tests__/integration/import-export.test.ts b/apps/api/src/modules/import-export/__tests__/integration/import-export.test.ts
index 9846caed..e44c743c 100644
--- a/apps/api/src/modules/import-export/__tests__/integration/import-export.test.ts
+++ b/apps/api/src/modules/import-export/__tests__/integration/import-export.test.ts
@@ -57,6 +57,8 @@ const zeroedCounts = {
state: zeroCounts,
cycle: zeroCounts,
attachment: zeroCounts,
+ checklist: zeroCounts,
+ custom_field: zeroCounts,
};
describe('import jobs', () => {
@@ -439,6 +441,114 @@ describe('import jobs', () => {
});
});
+ describe('trello', () => {
+ const trelloBody = {
+ source: 'trello' as const,
+ apiKey: 'trellokey1',
+ apiToken: 'ATTAtoken1',
+ boardId: 'board1',
+ archivedCards: 'archive' as const,
+ };
+
+ it('creates a pending Trello job and stores the matched members by email', async () => {
+ const owner = await signUpTestUser();
+ const api = authedApi(owner.cookie);
+ await createProject(api, { key: 'MKT', name: 'Marketing' });
+
+ const res = await jobs(api).post({
+ ...trelloBody,
+ memberMap: { member1: owner.userId, member2: '' },
+ stateOverrides: { list1: 'started' },
+ });
+
+ expect(res.status).toBe(201);
+ expect(res.data).toMatchObject({
+ source: 'trello',
+ phase: 'discover',
+ status: 'pending',
+ counts: zeroedCounts,
+ });
+ const [row] = await db.select().from(importJob).where(eq(importJob.id, res.data!.id));
+ expect(row!.config).toEqual({
+ boardId: 'board1',
+ archivedCards: 'archive',
+ memberEmails: { member1: owner.email },
+ unmatchedUserPolicy: 'unassigned',
+ stateOverrides: { list1: 'started' },
+ });
+ const credential = decryptSecret({
+ ciphertext: row!.credentialCiphertext!,
+ iv: row!.credentialIv!,
+ authTag: row!.credentialAuthTag!,
+ });
+ expect(JSON.parse(credential)).toEqual({ apiKey: 'trellokey1', token: 'ATTAtoken1' });
+ });
+
+ it('stores no members when none are matched', async () => {
+ const { api } = await setupOwnerProject();
+ const res = await jobs(api).post({ ...trelloBody, archivedCards: 'skip' as const });
+ expect(res.status).toBe(201);
+ const [row] = await db.select().from(importJob).where(eq(importJob.id, res.data!.id));
+ expect(row!.config).toEqual({
+ boardId: 'board1',
+ archivedCards: 'skip',
+ unmatchedUserPolicy: 'unassigned',
+ });
+ });
+
+ it('refuses to match a Trello member with someone outside the project', async () => {
+ const { api } = await setupOwnerProject();
+ const outsider = await signUpTestUser();
+ const res = await jobs(api).post({ ...trelloBody, memberMap: { member1: outsider.userId } });
+ expect(res.status).toBe(400);
+ });
+
+ it.each([
+ ['a missing archivedCards', { archivedCards: undefined }],
+ ['an unknown archivedCards', { archivedCards: 'keep' }],
+ ['a blank boardId', { boardId: ' ' }],
+ ['a key that would break the header', { apiKey: 'key", oauth_token="x' }],
+ ['a blank token', { apiToken: ' ' }],
+ ])('rejects %s', async (_case, change) => {
+ const { api } = await setupOwnerProject();
+ const res = await jobs(api).post({ ...trelloBody, ...change } as never);
+ expect(res.status).toBe(400);
+ });
+
+ it('rejects a missing or malformed field on the Trello endpoints before calling Trello', async () => {
+ const { api } = await setupOwnerProject();
+ expect((await jobs(api)['trello-test-connection'].post({} as never)).status).toBe(400);
+ expect(
+ (await jobs(api)['trello-test-connection'].post({ apiKey: 'key"', apiToken: 'token' }))
+ .status,
+ ).toBe(400);
+ expect(
+ (await jobs(api)['trello-preview'].post({ apiKey: 'key', apiToken: 'token' } as never))
+ .status,
+ ).toBe(400);
+ expect(
+ (
+ await jobs(api)['trello-preview'].post({
+ apiKey: 'key',
+ apiToken: 'token',
+ boardId: '../x',
+ })
+ ).status,
+ ).toBe(400);
+ });
+
+ it('denies a member whose role lacks the import_export permission', async () => {
+ const { api } = await setupOwnerProject();
+ const member = await addMember(api);
+ const credential = { apiKey: 'trellokey1', apiToken: 'ATTAtoken1' };
+ expect((await jobs(member)['trello-test-connection'].post(credential)).status).toBe(403);
+ expect(
+ (await jobs(member)['trello-preview'].post({ ...credential, boardId: 'board1' })).status,
+ ).toBe(403);
+ expect((await jobs(member).post(trelloBody)).status).toBe(403);
+ });
+ });
+
describe('access', () => {
it('returns 404 for an unknown project', async () => {
const { api } = await setupOwnerProject();
diff --git a/apps/api/src/modules/import-export/__tests__/unit/trello.test.ts b/apps/api/src/modules/import-export/__tests__/unit/trello.test.ts
new file mode 100644
index 00000000..06091255
--- /dev/null
+++ b/apps/api/src/modules/import-export/__tests__/unit/trello.test.ts
@@ -0,0 +1,143 @@
+import { describe, it, expect } from 'bun:test';
+import type { PinnedRequestInit } from '@repo/net';
+import { HttpError } from '#shared/lib';
+import {
+ TRELLO_API_URL,
+ previewTrelloBoard,
+ testTrelloConnection,
+ type TrelloFetch,
+} from '../../trello';
+
+interface SentRequest {
+ url: string;
+ init: PinnedRequestInit | undefined;
+}
+
+const CREDENTIAL = { apiKey: ' trellokey1 ', apiToken: ' ATTAtoken1 ' };
+const AUTH = 'OAuth oauth_consumer_key="trellokey1", oauth_token="ATTAtoken1"';
+
+function answering(responses: (Response | Error)[], sent: SentRequest[] = []): TrelloFetch {
+ const queue = [...responses];
+ return async (url, init) => {
+ sent.push({ url, init });
+ const next = queue.shift();
+ if (!next) throw new Error(`unexpected request ${url}`);
+ if (next instanceof Error) throw next;
+ return next;
+ };
+}
+
+async function httpError(promise: Promise<unknown>): Promise<HttpError> {
+ const error = await promise.catch((e: unknown) => e);
+ expect(error).toBeInstanceOf(HttpError);
+ return error as HttpError;
+}
+
+describe('testTrelloConnection', () => {
+ it('sends the trimmed key and token to Trello only and lists open boards first', async () => {
+ const sent: SentRequest[] = [];
+ const fetch = answering(
+ [
+ Response.json([
+ { id: 'b3', name: 'Archive', closed: true },
+ { id: 'b2', name: 'Roadmap', closed: false },
+ { id: 'b1', name: 'Bugs', closed: false },
+ ]),
+ ],
+ sent,
+ );
+
+ expect(await testTrelloConnection(CREDENTIAL, fetch)).toEqual({
+ boards: [
+ { id: 'b1', name: 'Bugs', closed: false },
+ { id: 'b2', name: 'Roadmap', closed: false },
+ { id: 'b3', name: 'Archive', closed: true },
+ ],
+ });
+ expect(sent).toEqual([
+ {
+ url: `${TRELLO_API_URL}/members/me/boards?filter=all&fields=name%2Cclosed`,
+ init: { headers: { Authorization: AUTH }, timeoutMs: 15_000 },
+ },
+ ]);
+ });
+
+ it.each([
+ ['an empty key', { apiKey: ' ', apiToken: 'ATTAtoken1' }, 'apiKey is required'],
+ [
+ 'a key with a quote',
+ { apiKey: 'key"x', apiToken: 'ATTAtoken1' },
+ 'apiKey is not a Trello API key',
+ ],
+ ['a token with a comma', { apiKey: 'key', apiToken: 'a,b' }, 'apiToken is not a Trello token'],
+ ])('refuses %s before calling Trello', async (_case, input, message) => {
+ const error = await httpError(testTrelloConnection(input, answering([])));
+ expect(error.status).toBe(400);
+ expect(error.message).toBe(message);
+ });
+
+ it.each([
+ [401, 400, 'Trello rejected the API key or token.'],
+ [429, 502, "Trello's rate limit was reached. Try again in a few minutes."],
+ [500, 502, 'Trello request failed with status 500.'],
+ ])('answers Trello HTTP %d with %d', async (status, expected, message) => {
+ const error = await httpError(
+ testTrelloConnection(CREDENTIAL, answering([new Response('', { status })])),
+ );
+ expect(error.status).toBe(expected);
+ expect(error.message).toBe(message);
+ });
+
+ it('answers 502 when Trello cannot be reached', async () => {
+ const error = await httpError(
+ testTrelloConnection(CREDENTIAL, answering([new Error('ECONNRESET')])),
+ );
+ expect(error.status).toBe(502);
+ });
+});
+
+describe('previewTrelloBoard', () => {
+ it("returns the board's open lists in order with their category, and its members", async () => {
+ const sent: SentRequest[] = [];
+ const fetch = answering(
+ [
+ Response.json([
+ { id: 'l2', name: 'Done', pos: 2 },
+ { id: 'l1', name: 'To Do', pos: 1 },
+ ]),
+ Response.json([{ id: 'm1', fullName: 'Ada Lovelace', username: 'ada' }]),
+ ],
+ sent,
+ );
+
+ expect(await previewTrelloBoard({ ...CREDENTIAL, boardId: 'board1' }, fetch)).toEqual({
+ states: [
+ { id: 'l1', name: 'To Do', category: 'unstarted' },
+ { id: 'l2', name: 'Done', category: 'completed' },
+ ],
+ members: [{ id: 'm1', fullName: 'Ada Lovelace', username: 'ada' }],
+ });
+ expect(sent.map((r) => r.url)).toEqual([
+ `${TRELLO_API_URL}/boards/board1/lists?filter=open&fields=name%2Cpos`,
+ `${TRELLO_API_URL}/boards/board1/members?fields=fullName%2Cusername`,
+ ]);
+ });
+
+ it('refuses a board id that is not a Trello id before calling Trello', async () => {
+ const error = await httpError(
+ previewTrelloBoard({ ...CREDENTIAL, boardId: '../members/me' }, answering([])),
+ );
+ expect(error.status).toBe(400);
+ });
+
+ it('answers 400 for a board Trello does not know', async () => {
+ const error = await httpError(
+ previewTrelloBoard(
+ { ...CREDENTIAL, boardId: 'board1' },
+ answering([new Response('board not found', { status: 404 })]),
+ ),
+ );
+ expect(error.status).toBe(400);
+ expect(error.message).toBe('Trello board not found.');
+ });
+});
diff --git a/apps/api/src/modules/import-export/index.ts b/apps/api/src/modules/import-export/index.ts
index a0cdc799..35103d84 100644
--- a/apps/api/src/modules/import-export/index.ts
+++ b/apps/api/src/modules/import-export/index.ts
@@ -10,6 +10,8 @@ import {
PlanePreviewResponse,
LinearTestConnectionResponse,
LinearPreviewResponse,
+ TrelloTestConnectionResponse,
+ TrelloPreviewResponse,
ProjectExportResponse,
createImportJobBody,
importJobParams,
@@ -17,6 +19,8 @@ import {
planePreviewBody,
linearConnectionBody,
linearPreviewBody,
+ trelloConnectionBody,
+ trelloPreviewBody,
} from './model';
import {
cancelImportJob,
@@ -31,6 +35,7 @@ import {
} from './service';
import { exportProject } from './export';
import { previewLinearStates, testLinearConnection } from './linear';
+import { previewTrelloBoard, testTrelloConnection } from './trello';
// Import jobs bring issues from an external tracker into a project. Creating one
// stores an encrypted credential and leaves it 'pending' for the worker
@@ -115,6 +120,38 @@ export const importExportRoutes = new Elysia({
},
)
+ .post(
+ '/projects/:projectKey/import-jobs/trello-test-connection',
+ ({ body }) => testTrelloConnection(body),
+ {
+ permission: ['import_export', 'create'],
+ body: trelloConnectionBody,
+ response: { 200: TrelloTestConnectionResponse, ...commonErrors, ...errors(502) },
+ detail: {
+ summary: 'Test a Trello API key and token',
+ description:
+ 'Validate a Trello API key and token live, without storing anything. Returns the ' +
+ 'boards they can see, to pick one to import from.',
+ },
+ },
+ )
+
+ .post(
+ '/projects/:projectKey/import-jobs/trello-preview',
+ ({ body }) => previewTrelloBoard(body),
+ {
+ permission: ['import_export', 'create'],
+ body: trelloPreviewBody,
+ response: { 200: TrelloPreviewResponse, ...commonErrors, ...errors(502) },
+ detail: {
+ summary: 'Preview a Trello board before importing it',
+ description:
+ "Fetch the board's open lists, each with the category itsaplan would automatically " +
+ 'map it to, and its members, for review before a job is created.',
+ },
+ },
+ )
+
.get('/projects/:projectKey/import-jobs/export', ({ project }) => exportProject(project.id), {
permission: ['import_export', 'create'],
response: { 200: ProjectExportResponse, ...accessErrors },
@@ -140,8 +177,9 @@ export const importExportRoutes = new Elysia({
detail: {
summary: 'Create an import job',
description:
- "Create a Plane job, or a Linear one with source 'linear'. Encrypt and store the " +
- "submitted credential and leave the job 'pending' for the worker.",
+ "Create a Plane job, a Linear one with source 'linear', or a Trello one with source " +
+ "'trello'. Encrypt and store the submitted credential and leave the job 'pending' " +
+ 'for the worker.',
},
},
)
diff --git a/apps/api/src/modules/import-export/model.ts b/apps/api/src/modules/import-export/model.ts
index eeeed034..5a6c6746 100644
--- a/apps/api/src/modules/import-export/model.ts
+++ b/apps/api/src/modules/import-export/model.ts
@@ -64,7 +64,35 @@ const linearImportJobBody = t.Object({
...importJobChoices,
});
-export const createImportJobBody = t.Union([planeImportJobBody, linearImportJobBody]);
+// One Trello board, with the choices only Trello needs.
+const trelloImportJobBody = t.Object({
+ source: t.Literal('trello'),
+ apiKey: t.String({ minLength: 1, description: 'Trello API key.' }),
+ apiToken: t.String({
+ minLength: 1,
+ description: 'A Trello token made for that key; read access is enough.',
+ }),
+ boardId: t.String({ minLength: 1, description: 'The Trello board id to import from.' }),
+ archivedCards: t.UnionEnum(['archive', 'skip'], {
+ description:
+ "'archive' imports archived cards, and the cards of archived lists, as archived " +
+ "issues; 'skip' leaves them out.",
+ }),
+ memberMap: t.Optional(
+ t.Record(t.String(), t.String(), {
+ description:
+ 'Trello member id -> the user id of a project member. The first matched member of ' +
+ 'a card is its assignee, the others watch it. A member left out is not matched.',
+ }),
+ ),
+ ...importJobChoices,
+});
+
+export const createImportJobBody = t.Union([
+ planeImportJobBody,
+ linearImportJobBody,
+ trelloImportJobBody,
+]);
export const testConnectionBody = t.Object({
baseUrl: t.String({ minLength: 1 }),
@@ -109,6 +137,26 @@ export const linearPreviewBody = t.Object({
export const LinearPreviewResponse = PlanePreviewResponse;
+export const trelloConnectionBody = t.Object({
+ apiKey: t.String({ minLength: 1, description: 'Trello API key.' }),
+ apiToken: t.String({ minLength: 1, description: 'A Trello token made for that key.' }),
+});
+
+export const TrelloTestConnectionResponse = t.Object({
+ boards: t.Array(t.Object({ id: t.String(), name: t.String(), closed: t.Boolean() })),
+});
+
+export const trelloPreviewBody = t.Object({
+ apiKey: t.String({ minLength: 1 }),
+ apiToken: t.String({ minLength: 1 }),
+ boardId: t.String({ minLength: 1 }),
+});
+
+export const TrelloPreviewResponse = t.Object({
+ states: PlanePreviewResponse.properties.states,
+ members: t.Array(t.Object({ id: t.String(), fullName: t.String(), username: t.String() })),
+});
+
// Mirrors import_record_source_entity_type_check in packages/db/src/schema/app.ts.
const entityCount = t.Object({ discovered: t.Number(), created: t.Number() });
const CountsResponse = t.Object({
@@ -118,6 +166,8 @@ const CountsResponse = t.Object({
state: entityCount,
cycle: entityCount,
attachment: entityCount,
+ checklist: entityCount,
+ custom_field: entityCount,
});
const ExportedComment = t.Object({
@@ -160,7 +210,7 @@ export const ProjectExportResponse = t.Object({
export const ImportJobResponse = t.Object({
id: t.Number(),
projectId: t.Number(),
- source: t.UnionEnum(['plane', 'linear']),
+ source: t.String(),
phase: t.UnionEnum(['discover', 'create', 'link', 'rewrite', 'attachments', 'done']),
status: t.UnionEnum(['pending', 'running', 'paused', 'completed', 'failed']),
counts: CountsResponse,
diff --git a/apps/api/src/modules/import-export/service.ts b/apps/api/src/modules/import-export/service.ts
index 15b42a19..e0ef7606 100644
--- a/apps/api/src/modules/import-export/service.ts
+++ b/apps/api/src/modules/import-export/service.ts
@@ -1,16 +1,17 @@
-import { db, importJob, importRecord, type ImportSource } from '@repo/db';
+import { db, importJob, importRecord } from '@repo/db';
import { desc, eq, sql } from 'drizzle-orm';
import { encryptSecret } from '@repo/crypto';
import { HttpError, iso } from '#shared/lib';
import { pinnedFetch } from '#shared/net';
import { linearJobFields, type CreateLinearImportJobInput } from './linear';
+import { trelloJobFields, type CreateTrelloImportJobInput } from './trello';
// Data access and the Plane connection check for import jobs (Linear's is in
-// linear.ts). Creating a job only encrypts and stores the submitted credential and
-// leaves the row 'pending' for the worker (apps/worker/src/import-worker.ts) to pick
-// up and drive through its phases — this module never talks to the worker or reads
-// the credential back. Progress is read from import_record, the worker's own
-// source-id-to-local-id mapping table.
+// linear.ts, Trello's in trello.ts). Creating a job only encrypts and stores the
+// submitted credential and leaves the row 'pending' for the worker
+// (apps/worker/src/import-worker.ts) to pick up and drive through its phases — this
+// module never talks to the worker or reads the credential back. Progress is read
+// from import_record, the worker's own source-id-to-local-id mapping table.
// Mirrors import_record_source_entity_type_check in packages/db/src/schema/app.ts.
export const IMPORT_ENTITY_TYPES = [
@@ -20,6 +21,8 @@ export const IMPORT_ENTITY_TYPES = [
'state',
'cycle',
'attachment',
+ 'checklist',
+ 'custom_field',
] as const;
export type ImportEntityType = (typeof IMPORT_ENTITY_TYPES)[number];
@@ -36,7 +39,7 @@ interface EntityCount {
export interface ImportJobDto {
id: number;
projectId: number;
- source: ImportSource;
+ source: string;
phase: ImportJobPhase;
status: ImportJobStatus;
counts: Record<ImportEntityType, EntityCount>;
@@ -74,7 +77,7 @@ function toDto(row: ImportJobRow, counts: Record<ImportEntityType, EntityCount>)
return {
id: row.id,
projectId: row.projectId,
- source: row.source as ImportSource,
+ source: row.source,
phase: row.phase as ImportJobPhase,
status: row.status as ImportJobStatus,
counts,
@@ -130,7 +133,7 @@ function normalizePlaneBaseUrl(raw: string): string {
return url.origin;
}
-interface ImportJobChoices {
+export interface ImportJobChoices {
unmatchedUserPolicy?: UnmatchedUserPolicy;
stateOverrides?: Record<string, StateCategory>;
}
@@ -146,7 +149,7 @@ export interface CreatePlaneImportJobInput {
}
export type CreateImportJobInput = ImportJobChoices &
- (CreatePlaneImportJobInput | CreateLinearImportJobInput);
+ (CreatePlaneImportJobInput | CreateLinearImportJobInput | CreateTrelloImportJobInput);
function planeJobFields(input: CreatePlaneImportJobInput) {
const baseUrl = normalizePlaneBaseUrl(input.baseUrl);
@@ -165,28 +168,48 @@ function planeJobFields(input: CreatePlaneImportJobInput) {
};
}
-// Stores the submitted credential encrypted and leaves the job 'pending' — the
-// worker picks it up on its next poll. The plaintext token exists only in this
-// function's local variables; it is never persisted or logged.
export async function createImportJob(
projectId: number,
actorUserId: string,
input: CreateImportJobInput,
): Promise<ImportJobDto> {
- const { source, credential, config } =
- input.source === 'linear' ? linearJobFields(input) : planeJobFields(input);
- const encrypted = encryptSecret(JSON.stringify(credential));
+ switch (input.source) {
+ case 'linear':
+ return insertImportJob(projectId, actorUserId, linearJobFields(input), input);
+ case 'trello':
+ return insertImportJob(
+ projectId,
+ actorUserId,
+ await trelloJobFields(projectId, input),
+ input,
+ );
+ default:
+ return insertImportJob(projectId, actorUserId, planeJobFields(input), input);
+ }
+}
+
+// Stores the credential encrypted and leaves the job 'pending' — the worker picks it up
+// on its next poll and reads `source` to pick its adapter. The plaintext token exists
+// only in local variables; it is never persisted or logged. A build's own import routes
+// call this for a source they add.
+export async function insertImportJob(
+ projectId: number,
+ actorUserId: string,
+ fields: { source: string; credential: object; config: object },
+ choices: ImportJobChoices,
+): Promise<ImportJobDto> {
+ const encrypted = encryptSecret(JSON.stringify(fields.credential));
const [row] = await db
.insert(importJob)
.values({
projectId,
createdByUserId: actorUserId,
- source,
+ source: fields.source,
config: {
- ...config,
- unmatchedUserPolicy: input.unmatchedUserPolicy ?? 'unassigned',
- ...(input.stateOverrides && Object.keys(input.stateOverrides).length > 0
- ? { stateOverrides: input.stateOverrides }
+ ...fields.config,
+ unmatchedUserPolicy: choices.unmatchedUserPolicy ?? 'unassigned',
+ ...(choices.stateOverrides && Object.keys(choices.stateOverrides).length > 0
+ ? { stateOverrides: choices.stateOverrides }
: {}),
},
credentialCiphertext: encrypted.ciphertext,
diff --git a/apps/api/src/modules/import-export/trello.ts b/apps/api/src/modules/import-export/trello.ts
new file mode 100644
index 00000000..c661ef0c
--- /dev/null
+++ b/apps/api/src/modules/import-export/trello.ts
@@ -0,0 +1,201 @@
+import { db, projectMember, user } from '@repo/db';
+import { and, eq, inArray } from 'drizzle-orm';
+import { HttpError } from '#shared/lib';
+import { pinnedFetch } from '#shared/net';
+
+// The Trello side of import jobs: checking an API key and token, listing the boards
+// they can see, previewing a board's lists and members, and validating a job's
+// Trello fields. Trello's endpoint is fixed, so no user-supplied URL is ever
+// fetched. The worker's own reader is apps/worker/src/trello-adapter.ts; the api
+// does not depend on the worker, so the small list mapping below is repeated here,
+// as Plane's and Linear's are.
+
+export const TRELLO_API_URL = 'https://api.trello.com/1';
+
+type StateCategory = 'backlog' | 'unstarted' | 'started' | 'completed' | 'canceled';
+export type TrelloFetch = typeof pinnedFetch;
+
+// Trello keys and tokens are letters and digits. Anything else would break out of
+// the quoted Authorization header they are sent in.
+const TOKEN_CHARS = /^[A-Za-z0-9]+$/;
+
+export interface TrelloCredentialInput {
+ apiKey: string;
+ apiToken: string;
+}
+
+export interface TrelloBoardOption {
+ id: string;
+ name: string;
+ closed: boolean;
+}
+
+export interface TrelloStateOption {
+ id: string;
+ name: string;
+ category: StateCategory;
+}
+
+export interface TrelloMemberOption {
+ id: string;
+ fullName: string;
+ username: string;
+}
+
+export interface CreateTrelloImportJobInput extends TrelloCredentialInput {
+ source: 'trello';
+ boardId: string;
+ archivedCards: 'archive' | 'skip';
+ memberMap?: Record<string, string>;
+}
+
+// Mirrors trelloListCategory in apps/worker/src/trello-mapping.ts.
+function listCategory(name: string): StateCategory {
+ if (/\b(done|completed?|finished|closed|shipped|released)\b/i.test(name)) return 'completed';
+ if (/\b(doing|in progress|wip|review|testing|qa)\b/i.test(name)) return 'started';
+ if (/\b(backlog|ideas?|icebox|someday)\b/i.test(name)) return 'backlog';
+ return 'unstarted';
+}
+
+function credentialOf(input: TrelloCredentialInput): { apiKey: string; token: string } {
+ const apiKey = input.apiKey.trim();
+ const token = input.apiToken.trim();
+ if (!apiKey) throw new HttpError(400, 'apiKey is required');
+ if (!token) throw new HttpError(400, 'apiToken is required');
+ if (!TOKEN_CHARS.test(apiKey)) throw new HttpError(400, 'apiKey is not a Trello API key');
+ if (!TOKEN_CHARS.test(token)) throw new HttpError(400, 'apiToken is not a Trello token');
+ return { apiKey, token };
+}
+
+function boardIdOf(raw: string): string {
+ const boardId = raw.trim();
+ if (!boardId) throw new HttpError(400, 'boardId is required');
+ if (!TOKEN_CHARS.test(boardId)) throw new HttpError(400, 'boardId is not a Trello board id');
+ return boardId;
+}
+
+async function trelloGet<T>(
+ credential: { apiKey: string; token: string },
+ path: string,
+ params: Record<string, string>,
+ fetch: TrelloFetch,
+): Promise<T> {
+ let response: Response;
+ try {
+ response = await fetch(`${TRELLO_API_URL}${path}?${new URLSearchParams(params)}`, {
+ headers: {
+ Authorization: `OAuth oauth_consumer_key="${credential.apiKey}", oauth_token="${credential.token}"`,
+ },
+ timeoutMs: 15_000,
+ });
+ } catch (err) {
+ if (err instanceof HttpError) throw err;
+ throw new HttpError(502, 'Trello could not be reached.');
+ }
+ if (response.status === 401) throw new HttpError(400, 'Trello rejected the API key or token.');
+ if (response.status === 429) {
+ throw new HttpError(502, "Trello's rate limit was reached. Try again in a few minutes.");
+ }
+ // A malformed or unknown board id.
+ if (response.status === 400 || response.status === 404) {
+ throw new HttpError(400, 'Trello board not found.');
+ }
+ if (!response.ok)
+ throw new HttpError(502, `Trello request failed with status ${response.status}.`);
+ return (await response.json()) as T;
+}
+
+// Confirms the key and token work before anything is stored, and returns every board
+// they can see, open boards first. Closed boards are listed too: an archive import
+// wants them.
+export async function testTrelloConnection(
+ input: TrelloCredentialInput,
+ fetch: TrelloFetch = pinnedFetch,
+): Promise<{ boards: TrelloBoardOption[] }> {
+ const boards = await trelloGet<TrelloBoardOption[]>(
+ credentialOf(input),
+ '/members/me/boards',
+ { filter: 'all', fields: 'name,closed' },
+ fetch,
+ );
+ return {
+ boards: boards
+ .map((b) => ({ id: b.id, name: b.name, closed: b.closed }))
+ .sort((a, b) => Number(a.closed) - Number(b.closed) || a.name.localeCompare(b.name)),
+ };
+}
+
+// A board's open lists in Trello's order, each with the category the import would
+// map it to, and the board's members to match with project members.
+export async function previewTrelloBoard(
+ input: TrelloCredentialInput & { boardId: string },
+ fetch: TrelloFetch = pinnedFetch,
+): Promise<{ states: TrelloStateOption[]; members: TrelloMemberOption[] }> {
+ const credential = credentialOf(input);
+ const board = `/boards/${boardIdOf(input.boardId)}`;
+ const lists = await trelloGet<{ id: string; name: string; pos: number }[]>(
+ credential,
+ `${board}/lists`,
+ { filter: 'open', fields: 'name,pos' },
+ fetch,
+ );
+ const members = await trelloGet<TrelloMemberOption[]>(
+ credential,
+ `${board}/members`,
+ { fields: 'fullName,username' },
+ fetch,
+ );
+ return {
+ states: [...lists]
+ .sort((a, b) => a.pos - b.pos)
+ .map((l) => ({ id: l.id, name: l.name, category: listCategory(l.name) })),
+ members: members.map((m) => ({ id: m.id, fullName: m.fullName, username: m.username })),
+ };
+}
+
+// The worker matches people by email, so each Trello member the user matched is
+// stored with the email of that project member. Only a member of this project can
+// be matched.
+async function memberEmails(
+ projectId: number,
+ memberMap: Record<string, string>,
+): Promise<Record<string, string>> {
+ const entries = Object.entries(memberMap).filter(([, userId]) => userId.trim() !== '');
+ if (entries.length === 0) return {};
+ for (const [memberId] of entries) {
+ if (!TOKEN_CHARS.test(memberId)) {
+ throw new HttpError(400, 'memberMap names a Trello member id that is not valid');
+ }
+ }
+ const userIds = [...new Set(entries.map(([, userId]) => userId))];
+ const rows = await db
+ .select({ userId: user.id, email: user.email })
+ .from(projectMember)
+ .innerJoin(user, eq(user.id, projectMember.userId))
+ .where(and(eq(projectMember.projectId, projectId), inArray(projectMember.userId, userIds)));
+ const emailOf = new Map(rows.map((r) => [r.userId, r.email]));
+ return Object.fromEntries(
+ entries.map(([memberId, userId]) => {
+ const email = emailOf.get(userId);
+ if (!email) throw new HttpError(400, 'memberMap names someone who is not in this project');
+ return [memberId, email];
+ }),
+ );
+}
+
+// What createImportJob stores for a Trello job: the credential and config the
+// worker's import-sources.ts reads back.
+export async function trelloJobFields(projectId: number, input: CreateTrelloImportJobInput) {
+ const credential = credentialOf(input);
+ const boardId = boardIdOf(input.boardId);
+ const emails = await memberEmails(projectId, input.memberMap ?? {});
+ return {
+ source: 'trello' as const,
+ credential,
+ config: {
+ boardId,
+ archivedCards: input.archivedCards,
+ ...(Object.keys(emails).length > 0 ? { memberEmails: emails } : {}),
+ },
+ };
+}
diff --git a/apps/web/messages/ar/settings.json b/apps/web/messages/ar/settings.json
index efe06386..81d5fd3f 100644
--- a/apps/web/messages/ar/settings.json
+++ b/apps/web/messages/ar/settings.json
@@ -498,7 +498,8 @@
"import": "استيراد",
"source": "المصدر",
"sourceHint": "اختر مصدر الاستيراد.",
- "comingSoon": "قريبًا",
+ "moreSources": "المزيد في Cloud وPro",
+ "moreSourcesHint": "تتوفر مصادر استيراد أخرى في Cloud وفي Pro المستضاف ذاتيًا.",
"connect": "الاتصال بـ Plane",
"connectHint": "حط بيانات نسخة Plane المستضافة ذاتيًا عشان نتأكد من الاتصال ونجيب مشاريعها.",
"baseUrl": "رابط Plane",
@@ -550,6 +551,29 @@
"noProject": "مهام بلا مشروع",
"noTeams": "لا يمكن لمفتاح API هذا الوصول إلى أي فريق."
},
+ "trello": {
+ "connect": "الاتصال بـ Trello",
+ "connectHint": "أدخل مفتاح API الخاص بك في Trello ووافق عليه في Trello لتحميل اللوحات التي يمكنك رؤيتها.",
+ "apiKey": "مفتاح API",
+ "apiKeyHint": "أنشئ Power-Up في <link>إدارة Power-Ups في Trello</link> وأنشئ مفتاح API من تبويب API key الخاص به. في التبويب نفسه، أضف <code>{origin}</code> إلى المصادر المسموح بها (allowed origins): لا يرسل Trello الرمز إلا إلى عنوان مسموح به.",
+ "authorize": "التفويض في Trello",
+ "authorizing": "بانتظار Trello…",
+ "popupBlocked": "حظر المتصفح نافذة Trello. اسمح بالنوافذ المنبثقة لهذا الموقع ثم حاول مرة أخرى.",
+ "scope": "ما الذي تريد استيراده",
+ "scopeHint": "اختر اللوحة التي تريد استيرادها. تصبح قوائمها المفتوحة أعمدة.",
+ "board": "اللوحة",
+ "boardPlaceholder": "اختر لوحة",
+ "closedBoard": "{name} (مغلقة)",
+ "noBoards": "لا يمكن لهذا المفتاح والرمز رؤية أي لوحة.",
+ "archivedCards": "البطاقات المؤرشفة",
+ "archivedCardsArchive": "استيرادها كمهام مؤرشفة",
+ "archivedCardsSkip": "عدم الاستيراد",
+ "members": "أعضاء Trello",
+ "membersSkip": "عدم المطابقة",
+ "membersMatch": "المطابقة يدويًا",
+ "membersHint": "لا يشارك Trello البريد الإلكتروني للأعضاء، لذا طابقهم يدويًا. يصبح أول عضو مُطابَق في البطاقة مسؤولًا عن المهمة، ويتابعها الباقون.",
+ "memberNotMatched": "غير مُطابَق"
+ },
"statuses": {
"pending": "قيد الانتظار",
"running": "شغّال",
@@ -571,7 +595,9 @@
"label": "الوسوم",
"state": "الحالات",
"cycle": "الدورات",
- "attachment": "المرفقات"
+ "attachment": "المرفقات",
+ "checklist": "قوائم التحقق",
+ "custom_field": "الحقول المخصصة"
}
},
"issueTemplates": {
diff --git a/apps/web/messages/en/settings.json b/apps/web/messages/en/settings.json
index 4cea413f..ce8e6dcd 100644
--- a/apps/web/messages/en/settings.json
+++ b/apps/web/messages/en/settings.json
@@ -498,7 +498,8 @@
"import": "Import",
"source": "Source",
"sourceHint": "Choose where to import from.",
- "comingSoon": "Soon",
+ "moreSources": "More in Cloud and Pro",
+ "moreSourcesHint": "More sources to import from are available in Cloud and self-hosted Pro.",
"connect": "Connect to Plane",
"connectHint": "Enter a self-hosted Plane instance to check the connection and load its projects.",
"baseUrl": "Plane URL",
@@ -550,6 +551,29 @@
"noProject": "Issues with no project",
"noTeams": "This API key can't see any teams."
},
+ "trello": {
+ "connect": "Connect to Trello",
+ "connectHint": "Enter your Trello API key and authorize it in Trello to load the boards you can see.",
+ "apiKey": "API key",
+ "apiKeyHint": "Create a Power-Up in the <link>Trello Power-Up admin</link> and generate an API key on its API key tab. On the same tab, add <code>{origin}</code> to the allowed origins: Trello sends the token only to an allowed address.",
+ "authorize": "Authorize in Trello",
+ "authorizing": "Waiting for Trello…",
+ "popupBlocked": "The browser blocked the Trello window. Allow pop-ups for this site and try again.",
+ "scope": "What to import",
+ "scopeHint": "Pick the board to import. Its open lists become columns.",
+ "board": "Board",
+ "boardPlaceholder": "Select a board",
+ "closedBoard": "{name} (closed)",
+ "noBoards": "This key and token can't see any boards.",
+ "archivedCards": "Archived cards",
+ "archivedCardsArchive": "Import as archived issues",
+ "archivedCardsSkip": "Don't import",
+ "members": "Trello members",
+ "membersSkip": "Don't match",
+ "membersMatch": "Match by hand",
+ "membersHint": "Trello doesn't share members' emails, so match them by hand. A card's first matched member becomes its assignee, the others watch the issue.",
+ "memberNotMatched": "Not matched"
+ },
"statuses": {
"pending": "Pending",
"running": "Running",
@@ -571,7 +595,9 @@
"label": "Labels",
"state": "States",
"cycle": "Cycles",
- "attachment": "Attachments"
+ "attachment": "Attachments",
+ "checklist": "Checklists",
+ "custom_field": "Custom fields"
}
},
"issueTemplates": {
diff --git a/apps/web/messages/es-ES/settings.json b/apps/web/messages/es-ES/settings.json
index 74d42954..b935c077 100644
--- a/apps/web/messages/es-ES/settings.json
+++ b/apps/web/messages/es-ES/settings.json
@@ -498,7 +498,8 @@
"import": "Importar",
"source": "Origen",
"sourceHint": "Elige desde dónde importar.",
- "comingSoon": "Pronto",
+ "moreSources": "Más en Cloud y Pro",
+ "moreSourcesHint": "Hay más fuentes de importación en Cloud y en Pro autoalojado.",
"connect": "Conectar con Plane",
"connectHint": "Introduce una instancia autoalojada de Plane para comprobar la conexión y cargar sus proyectos.",
"baseUrl": "URL de Plane",
@@ -550,6 +551,29 @@
"noProject": "Tickets sin proyecto",
"noTeams": "Esta clave de API no ve ningún equipo."
},
+ "trello": {
+ "connect": "Conectar con Trello",
+ "connectHint": "Introduce tu clave API de Trello y autorízala en Trello para cargar los tableros a los que tienes acceso.",
+ "apiKey": "Clave API",
+ "apiKeyHint": "Crea un Power-Up en la <link>administración de Power-Ups de Trello</link> y genera una clave API en su pestaña API key. En la misma pestaña, añade <code>{origin}</code> a los orígenes permitidos: Trello solo envía el token a una dirección permitida.",
+ "authorize": "Autorizar en Trello",
+ "authorizing": "Esperando a Trello…",
+ "popupBlocked": "El navegador ha bloqueado la ventana de Trello. Permite las ventanas emergentes para este sitio y vuelve a intentarlo.",
+ "scope": "Qué importar",
+ "scopeHint": "Elige el tablero que quieres importar. Sus listas abiertas pasan a ser columnas.",
+ "board": "Tablero",
+ "boardPlaceholder": "Selecciona un tablero",
+ "closedBoard": "{name} (cerrado)",
+ "noBoards": "Esta clave y este token no ven ningún tablero.",
+ "archivedCards": "Tarjetas archivadas",
+ "archivedCardsArchive": "Importar como incidencias archivadas",
+ "archivedCardsSkip": "No importar",
+ "members": "Miembros de Trello",
+ "membersSkip": "No asociar",
+ "membersMatch": "Asociar a mano",
+ "membersHint": "Trello no comparte el correo de los miembros, así que asócialos a mano. El primer miembro asociado de una tarjeta será el responsable y los demás seguirán la incidencia.",
+ "memberNotMatched": "Sin asociar"
+ },
"statuses": {
"pending": "Pendiente",
"running": "En ejecución",
@@ -571,7 +595,9 @@
"label": "Etiquetas",
"state": "Estados",
"cycle": "Ciclos",
- "attachment": "Adjuntos"
+ "attachment": "Adjuntos",
+ "checklist": "Listas de comprobación",
+ "custom_field": "Campos personalizados"
}
},
"issueTemplates": {
diff --git a/apps/web/messages/fa/settings.json b/apps/web/messages/fa/settings.json
index b5e992ce..e5436be8 100644
--- a/apps/web/messages/fa/settings.json
+++ b/apps/web/messages/fa/settings.json
@@ -498,7 +498,8 @@
"import": "ورود",
"source": "منبع",
"sourceHint": "انتخاب کنید از کجا وارد شود.",
- "comingSoon": "به‌زودی",
+ "moreSources": "موارد بیشتر در Cloud و Pro",
+ "moreSourcesHint": "منابع بیشتری برای وارد کردن در Cloud و Pro خودمیزبان در دسترس است.",
"connect": "اتصال به Plane",
"connectHint": "یک سامانهٔ خودمیزبان Plane وارد کنید تا اتصال بررسی و پروژه‌هایش بارگذاری شود.",
"baseUrl": "نشانی Plane",
@@ -550,6 +551,29 @@
"noProject": "تسک‌های بدون پروژه",
"noTeams": "این کلید API هیچ تیمی را نمی‌بیند."
},
+ "trello": {
+ "connect": "اتصال به Trello",
+ "connectHint": "کلید API خود در Trello را وارد کنید و در Trello مجوز بدهید تا بردهایی که می‌بینید بارگذاری شوند.",
+ "apiKey": "کلید API",
+ "apiKeyHint": "در <link>مدیریت Power-Upهای Trello</link> یک Power-Up بسازید و در زبانه API key آن یک کلید API بسازید. در همان زبانه، <code>{origin}</code> را به مبدأهای مجاز (allowed origins) اضافه کنید: Trello توکن را فقط به نشانی مجاز می‌فرستد.",
+ "authorize": "مجوز در Trello",
+ "authorizing": "در انتظار Trello…",
+ "popupBlocked": "مرورگر پنجره Trello را مسدود کرد. پنجره‌های بازشو را برای این سایت مجاز کنید و دوباره تلاش کنید.",
+ "scope": "چه چیزی وارد شود",
+ "scopeHint": "بردی را که می‌خواهید وارد کنید انتخاب کنید. فهرست‌های باز آن ستون می‌شوند.",
+ "board": "برد",
+ "boardPlaceholder": "یک برد انتخاب کنید",
+ "closedBoard": "{name} (بسته)",
+ "noBoards": "این کلید و توکن هیچ بردی را نمی‌بینند.",
+ "archivedCards": "کارت‌های بایگانی‌شده",
+ "archivedCardsArchive": "وارد کردن به‌عنوان کارهای بایگانی‌شده",
+ "archivedCardsSkip": "وارد نشوند",
+ "members": "اعضای Trello",
+ "membersSkip": "تطبیق داده نشوند",
+ "membersMatch": "تطبیق دستی",
+ "membersHint": "Trello ایمیل اعضا را در اختیار نمی‌گذارد، پس آن‌ها را دستی تطبیق دهید. نخستین عضو تطبیق‌یافته کارت مسئول کار می‌شود و بقیه آن را دنبال می‌کنند.",
+ "memberNotMatched": "تطبیق داده نشده"
+ },
"statuses": {
"pending": "در انتظار",
"running": "در حال اجرا",
@@ -571,7 +595,9 @@
"label": "برچسب‌ها",
"state": "وضعیت‌ها",
"cycle": "سیکل‌ها",
- "attachment": "پیوست‌ها"
+ "attachment": "پیوست‌ها",
+ "checklist": "چک‌لیست‌ها",
+ "custom_field": "فیلدهای سفارشی"
}
},
"issueTemplates": {
diff --git a/apps/web/messages/fr/settings.json b/apps/web/messages/fr/settings.json
index 2f98edd0..29cd82ec 100644
--- a/apps/web/messages/fr/settings.json
+++ b/apps/web/messages/fr/settings.json
@@ -498,7 +498,8 @@
"import": "Importer",
"source": "Source",
"sourceHint": "Choisissez la source de l’import.",
- "comingSoon": "Bientôt",
+ "moreSources": "Plus avec Cloud et Pro",
+ "moreSourcesHint": "D'autres sources d'import sont disponibles dans Cloud et Pro auto-hébergé.",
"connect": "Se connecter à Plane",
"connectHint": "Indiquez une instance Plane auto-hébergée pour vérifier la connexion et charger ses projets.",
"baseUrl": "URL de Plane",
@@ -550,6 +551,29 @@
"noProject": "Tickets sans projet",
"noTeams": "Cette clé API ne voit aucune équipe."
},
+ "trello": {
+ "connect": "Se connecter à Trello",
+ "connectHint": "Indiquez votre clé API Trello et autorisez-la dans Trello pour charger les tableaux auxquels vous avez accès.",
+ "apiKey": "Clé API",
+ "apiKeyHint": "Créez un Power-Up dans l'<link>administration des Power-Ups Trello</link> et générez une clé API dans son onglet API key. Dans le même onglet, ajoutez <code>{origin}</code> aux origines autorisées : Trello n'envoie le jeton qu'à une adresse autorisée.",
+ "authorize": "Autoriser dans Trello",
+ "authorizing": "En attente de Trello…",
+ "popupBlocked": "Le navigateur a bloqué la fenêtre Trello. Autorisez les fenêtres pop-up pour ce site et réessayez.",
+ "scope": "Contenu à importer",
+ "scopeHint": "Choisissez le tableau à importer. Ses listes ouvertes deviennent des colonnes.",
+ "board": "Tableau",
+ "boardPlaceholder": "Sélectionner un tableau",
+ "closedBoard": "{name} (fermé)",
+ "noBoards": "Cette clé et ce jeton ne voient aucun tableau.",
+ "archivedCards": "Cartes archivées",
+ "archivedCardsArchive": "Importer comme tickets archivés",
+ "archivedCardsSkip": "Ne pas importer",
+ "members": "Membres Trello",
+ "membersSkip": "Ne pas associer",
+ "membersMatch": "Associer à la main",
+ "membersHint": "Trello ne partage pas l'e-mail des membres : associez-les à la main. Le premier membre associé d'une carte devient le responsable du ticket, les autres le suivent.",
+ "memberNotMatched": "Non associé"
+ },
"statuses": {
"pending": "En attente",
"running": "En cours",
@@ -571,7 +595,9 @@
"label": "Étiquettes",
"state": "États",
"cycle": "Cycles",
- "attachment": "Pièces jointes"
+ "attachment": "Pièces jointes",
+ "checklist": "Checklists",
+ "custom_field": "Champs personnalisés"
}
},
"issueTemplates": {
diff --git a/apps/web/messages/id/settings.json b/apps/web/messages/id/settings.json
index 38f4b138..a51d285a 100644
--- a/apps/web/messages/id/settings.json
+++ b/apps/web/messages/id/settings.json
@@ -498,7 +498,8 @@
"import": "Impor",
"source": "Sumber",
"sourceHint": "Pilih sumber impor.",
- "comingSoon": "Segera",
+ "moreSources": "Lebih banyak di Cloud dan Pro",
+ "moreSourcesHint": "Sumber impor lainnya tersedia di Cloud dan Pro self-hosted.",
"connect": "Hubungkan ke Plane",
"connectHint": "Masukkan instans Plane self-hosted untuk memeriksa koneksi dan memuat proyeknya.",
"baseUrl": "URL Plane",
@@ -550,6 +551,29 @@
"noProject": "Issue tanpa proyek",
"noTeams": "Kunci API ini tidak dapat melihat tim mana pun."
},
+ "trello": {
+ "connect": "Hubungkan ke Trello",
+ "connectHint": "Masukkan API key Trello Anda dan otorisasi di Trello untuk memuat board yang bisa Anda lihat.",
+ "apiKey": "API key",
+ "apiKeyHint": "Buat Power-Up di <link>admin Power-Up Trello</link> lalu buat API key di tab API key-nya. Di tab yang sama, tambahkan <code>{origin}</code> ke allowed origins: Trello hanya mengirim token ke alamat yang diizinkan.",
+ "authorize": "Otorisasi di Trello",
+ "authorizing": "Menunggu Trello…",
+ "popupBlocked": "Browser memblokir jendela Trello. Izinkan pop-up untuk situs ini lalu coba lagi.",
+ "scope": "Yang diimpor",
+ "scopeHint": "Pilih board yang akan diimpor. Daftar yang terbuka menjadi kolom.",
+ "board": "Board",
+ "boardPlaceholder": "Pilih board",
+ "closedBoard": "{name} (ditutup)",
+ "noBoards": "Key dan token ini tidak bisa melihat board apa pun.",
+ "archivedCards": "Kartu yang diarsipkan",
+ "archivedCardsArchive": "Impor sebagai isu yang diarsipkan",
+ "archivedCardsSkip": "Jangan impor",
+ "members": "Anggota Trello",
+ "membersSkip": "Jangan cocokkan",
+ "membersMatch": "Cocokkan manual",
+ "membersHint": "Trello tidak membagikan email anggota, jadi cocokkan secara manual. Anggota pertama yang dicocokkan pada kartu menjadi penanggung jawab, yang lain mengikuti isu.",
+ "memberNotMatched": "Tidak dicocokkan"
+ },
"statuses": {
"pending": "Tertunda",
"running": "Berjalan",
@@ -571,7 +595,9 @@
"label": "Label",
"state": "Status",
"cycle": "Cycle",
- "attachment": "Lampiran"
+ "attachment": "Lampiran",
+ "checklist": "Checklist",
+ "custom_field": "Kolom kustom"
}
},
"issueTemplates": {
diff --git a/apps/web/messages/ko/settings.json b/apps/web/messages/ko/settings.json
index 3b3e5641..26415d69 100644
--- a/apps/web/messages/ko/settings.json
+++ b/apps/web/messages/ko/settings.json
@@ -498,7 +498,8 @@
"import": "가져오기",
"source": "가져올 위치",
"sourceHint": "데이터를 가져올 위치를 선택하세요.",
- "comingSoon": "출시 예정",
+ "moreSources": "Cloud와 Pro에서 더 보기",
+ "moreSourcesHint": "더 많은 가져오기 소스는 Cloud와 자체 호스팅 Pro에서 사용할 수 있습니다.",
"connect": "Plane에 연결",
"connectHint": "셀프 호스팅 Plane 인스턴스를 입력하여 연결을 확인하고 프로젝트를 불러옵니다.",
"baseUrl": "Plane URL",
@@ -550,6 +551,29 @@
"noProject": "프로젝트가 없는 이슈",
"noTeams": "이 API 키로 접근할 수 있는 팀이 없습니다."
},
+ "trello": {
+ "connect": "Trello 연결",
+ "connectHint": "Trello API 키를 입력하고 Trello에서 권한을 허용하면 볼 수 있는 보드를 불러옵니다.",
+ "apiKey": "API 키",
+ "apiKeyHint": "<link>Trello Power-Up 관리 페이지</link>에서 Power-Up을 만들고 API key 탭에서 API 키를 생성하세요. 같은 탭에서 <code>{origin}</code>을(를) 허용된 출처(allowed origins)에 추가하세요. Trello는 허용된 주소로만 토큰을 보냅니다.",
+ "authorize": "Trello에서 권한 허용",
+ "authorizing": "Trello 응답 대기 중…",
+ "popupBlocked": "브라우저가 Trello 창을 차단했습니다. 이 사이트의 팝업을 허용한 뒤 다시 시도하세요.",
+ "scope": "가져올 항목",
+ "scopeHint": "가져올 보드를 선택하세요. 열린 리스트는 열(column)이 됩니다.",
+ "board": "보드",
+ "boardPlaceholder": "보드 선택",
+ "closedBoard": "{name} (닫힘)",
+ "noBoards": "이 키와 토큰으로 볼 수 있는 보드가 없습니다.",
+ "archivedCards": "보관된 카드",
+ "archivedCardsArchive": "보관된 이슈로 가져오기",
+ "archivedCardsSkip": "가져오지 않기",
+ "members": "Trello 멤버",
+ "membersSkip": "연결하지 않기",
+ "membersMatch": "직접 연결",
+ "membersHint": "Trello는 멤버의 이메일을 공유하지 않으므로 직접 연결하세요. 카드에서 처음 연결된 멤버가 담당자가 되고, 나머지는 이슈를 지켜봅니다.",
+ "memberNotMatched": "연결 안 됨"
+ },
"statuses": {
"pending": "대기 중",
"running": "실행 중",
@@ -571,7 +595,9 @@
"label": "라벨",
"state": "상태",
"cycle": "사이클",
- "attachment": "첨부 파일"
+ "attachment": "첨부 파일",
+ "checklist": "체크리스트",
+ "custom_field": "사용자 지정 필드"
}
},
"issueTemplates": {
diff --git a/apps/web/messages/pt-BR/settings.json b/apps/web/messages/pt-BR/settings.json
index 21a1c093..f9e20ee5 100644
--- a/apps/web/messages/pt-BR/settings.json
+++ b/apps/web/messages/pt-BR/settings.json
@@ -498,7 +498,8 @@
"import": "Importar",
"source": "Origem",
"sourceHint": "Escolha de onde importar.",
- "comingSoon": "Em breve",
+ "moreSources": "Mais no Cloud e no Pro",
+ "moreSourcesHint": "Mais fontes de importação estão disponíveis no Cloud e no Pro auto-hospedado.",
"connect": "Conectar ao Plane",
"connectHint": "Informe uma instância Plane auto-hospedada para verificar a conexão e carregar seus projetos.",
"baseUrl": "URL do Plane",
@@ -550,6 +551,29 @@
"noProject": "Issues sem projeto",
"noTeams": "Esta chave de API não vê nenhum time."
},
+ "trello": {
+ "connect": "Conectar ao Trello",
+ "connectHint": "Informe sua chave de API do Trello e autorize-a no Trello para carregar os quadros que você pode ver.",
+ "apiKey": "Chave de API",
+ "apiKeyHint": "Crie um Power-Up na <link>administração de Power-Ups do Trello</link> e gere uma chave de API na aba API key. Na mesma aba, adicione <code>{origin}</code> às origens permitidas: o Trello só envia o token para um endereço permitido.",
+ "authorize": "Autorizar no Trello",
+ "authorizing": "Aguardando o Trello…",
+ "popupBlocked": "O navegador bloqueou a janela do Trello. Permita pop-ups para este site e tente novamente.",
+ "scope": "O que importar",
+ "scopeHint": "Escolha o quadro a importar. As listas abertas dele viram colunas.",
+ "board": "Quadro",
+ "boardPlaceholder": "Selecione um quadro",
+ "closedBoard": "{name} (fechado)",
+ "noBoards": "Esta chave e este token não veem nenhum quadro.",
+ "archivedCards": "Cartões arquivados",
+ "archivedCardsArchive": "Importar como itens arquivados",
+ "archivedCardsSkip": "Não importar",
+ "members": "Membros do Trello",
+ "membersSkip": "Não associar",
+ "membersMatch": "Associar manualmente",
+ "membersHint": "O Trello não compartilha o e-mail dos membros, então associe-os manualmente. O primeiro membro associado de um cartão vira o responsável, e os outros acompanham o item.",
+ "memberNotMatched": "Não associado"
+ },
"statuses": {
"pending": "Pendente",
"running": "Em execução",
@@ -571,7 +595,9 @@
"label": "Etiquetas",
"state": "Estados",
"cycle": "Ciclos",
- "attachment": "Anexos"
+ "attachment": "Anexos",
+ "checklist": "Checklists",
+ "custom_field": "Campos personalizados"
}
},
"issueTemplates": {
diff --git a/apps/web/messages/ru/settings.json b/apps/web/messages/ru/settings.json
index a7b694f8..20604a92 100644
--- a/apps/web/messages/ru/settings.json
+++ b/apps/web/messages/ru/settings.json
@@ -498,7 +498,8 @@
"import": "Импорт",
"source": "Источник",
"sourceHint": "Выберите, откуда импортировать.",
- "comingSoon": "Скоро",
+ "moreSources": "Больше в Cloud и Pro",
+ "moreSourcesHint": "Больше источников для импорта доступно в Cloud и self-hosted Pro.",
"connect": "Подключение к Plane",
"connectHint": "Укажите self-hosted инстанс Plane, чтобы проверить соединение и загрузить его проекты.",
"baseUrl": "URL Plane",
@@ -550,6 +551,29 @@
"noProject": "Задачи без проекта",
"noTeams": "Этот API-ключ не видит ни одной команды."
},
+ "trello": {
+ "connect": "Подключение к Trello",
+ "connectHint": "Укажите свой API-ключ Trello и разрешите доступ в Trello, чтобы загрузить доступные вам доски.",
+ "apiKey": "API-ключ",
+ "apiKeyHint": "Создайте Power-Up в <link>админке Power-Up Trello</link> и сгенерируйте API-ключ на его вкладке API key. На той же вкладке добавьте <code>{origin}</code> в разрешённые адреса (allowed origins): Trello отправляет токен только на разрешённый адрес.",
+ "authorize": "Авторизоваться в Trello",
+ "authorizing": "Ожидание Trello…",
+ "popupBlocked": "Браузер заблокировал окно Trello. Разрешите всплывающие окна для этого сайта и попробуйте снова.",
+ "scope": "Что импортировать",
+ "scopeHint": "Выберите доску для импорта. Её открытые списки станут колонками.",
+ "board": "Доска",
+ "boardPlaceholder": "Выберите доску",
+ "closedBoard": "{name} (закрыта)",
+ "noBoards": "Этот ключ и токен не видят ни одной доски.",
+ "archivedCards": "Архивные карточки",
+ "archivedCardsArchive": "Импортировать как архивные задачи",
+ "archivedCardsSkip": "Не импортировать",
+ "members": "Участники Trello",
+ "membersSkip": "Не сопоставлять",
+ "membersMatch": "Сопоставить вручную",
+ "membersHint": "Trello не передаёт email участников, поэтому сопоставьте их вручную. Первый сопоставленный участник карточки станет исполнителем, остальные будут наблюдателями задачи.",
+ "memberNotMatched": "Не сопоставлен"
+ },
"statuses": {
"pending": "В ожидании",
"running": "Выполняется",
@@ -571,7 +595,9 @@
"label": "Метки",
"state": "Статусы",
"cycle": "Циклы",
- "attachment": "Вложения"
+ "attachment": "Вложения",
+ "checklist": "Чек-листы",
+ "custom_field": "Пользовательские поля"
}
},
"issueTemplates": {
diff --git a/apps/web/messages/tr/settings.json b/apps/web/messages/tr/settings.json
index d2716835..72e2959d 100644
--- a/apps/web/messages/tr/settings.json
+++ b/apps/web/messages/tr/settings.json
@@ -498,7 +498,8 @@
"import": "İçe Aktar",
"source": "Kaynak",
"sourceHint": "Nereden içe aktarılacağını seçin.",
- "comingSoon": "Yakında",
+ "moreSources": "Cloud ve Pro'da daha fazlası",
+ "moreSourcesHint": "Daha fazla içe aktarma kaynağı Cloud ve kendi sunucunuzda çalışan Pro'da mevcut.",
"connect": "Plane'e bağlan",
"connectHint": "Bağlantıyı test etmek ve projelerini yüklemek için kendi barındırdığınız bir Plane örneklemini girin.",
"baseUrl": "Plane URL'si",
@@ -550,6 +551,29 @@
"noProject": "Projesiz işler",
"noTeams": "Bu API anahtarı hiçbir takımı göremiyor."
},
+ "trello": {
+ "connect": "Trello'ya bağlan",
+ "connectHint": "Trello API anahtarınızı girin ve görebildiğiniz panoları yüklemek için Trello'da yetkilendirin.",
+ "apiKey": "API anahtarı",
+ "apiKeyHint": "<link>Trello Power-Up yönetiminde</link> bir Power-Up oluşturun ve API key sekmesinde bir API anahtarı üretin. Aynı sekmede <code>{origin}</code> adresini izin verilen kaynaklara (allowed origins) ekleyin: Trello token'ı yalnızca izin verilen bir adrese gönderir.",
+ "authorize": "Trello'da yetkilendir",
+ "authorizing": "Trello bekleniyor…",
+ "popupBlocked": "Tarayıcı Trello penceresini engelledi. Bu site için açılır pencerelere izin verin ve tekrar deneyin.",
+ "scope": "Neyi içe aktaracağınız",
+ "scopeHint": "İçe aktarılacak panoyu seçin. Açık listeleri sütun olur.",
+ "board": "Pano",
+ "boardPlaceholder": "Bir pano seçin",
+ "closedBoard": "{name} (kapalı)",
+ "noBoards": "Bu anahtar ve token hiçbir panoyu göremiyor.",
+ "archivedCards": "Arşivlenmiş kartlar",
+ "archivedCardsArchive": "Arşivlenmiş iş olarak içe aktar",
+ "archivedCardsSkip": "İçe aktarma",
+ "members": "Trello üyeleri",
+ "membersSkip": "Eşleştirme",
+ "membersMatch": "Elle eşleştir",
+ "membersHint": "Trello üyelerin e-postasını paylaşmaz, bu yüzden onları elle eşleştirin. Bir kartın ilk eşleşen üyesi atanan kişi olur, diğerleri işi izler.",
+ "memberNotMatched": "Eşleştirilmedi"
+ },
"statuses": {
"pending": "Bekliyor",
"running": "Çalışıyor",
@@ -571,7 +595,9 @@
"label": "Etiketler",
"state": "Durumlar",
"cycle": "Döngüler",
- "attachment": "Ekler"
+ "attachment": "Ekler",
+ "checklist": "Kontrol listeleri",
+ "custom_field": "Özel alanlar"
}
},
"issueTemplates": {
diff --git a/apps/web/messages/uk/settings.json b/apps/web/messages/uk/settings.json
index 439cdf8f..334ddfac 100644
--- a/apps/web/messages/uk/settings.json
+++ b/apps/web/messages/uk/settings.json
@@ -498,7 +498,8 @@
"import": "Імпорт",
"source": "Джерело",
"sourceHint": "Виберіть, звідки імпортувати.",
- "comingSoon": "Незабаром",
+ "moreSources": "Більше в Cloud і Pro",
+ "moreSourcesHint": "Більше джерел для імпорту доступно в Cloud і self-hosted Pro.",
"connect": "Підключення до Plane",
"connectHint": "Вкажіть самостійно розміщений інстанс Plane, щоб перевірити з'єднання та завантажити його проєкти.",
"baseUrl": "URL Plane",
@@ -550,6 +551,29 @@
"noProject": "Задачі без проєкту",
"noTeams": "Цей API-ключ не бачить жодної команди."
},
+ "trello": {
+ "connect": "Підключення до Trello",
+ "connectHint": "Вкажіть свій API-ключ Trello і дозвольте доступ у Trello, щоб завантажити доступні вам дошки.",
+ "apiKey": "API-ключ",
+ "apiKeyHint": "Створіть Power-Up в <link>адмінці Power-Up Trello</link> і згенеруйте API-ключ на його вкладці API key. На тій самій вкладці додайте <code>{origin}</code> до дозволених адрес (allowed origins): Trello надсилає токен лише на дозволену адресу.",
+ "authorize": "Авторизуватися в Trello",
+ "authorizing": "Очікування Trello…",
+ "popupBlocked": "Браузер заблокував вікно Trello. Дозвольте спливні вікна для цього сайту і спробуйте ще раз.",
+ "scope": "Що імпортувати",
+ "scopeHint": "Виберіть дошку для імпорту. Її відкриті списки стануть колонками.",
+ "board": "Дошка",
+ "boardPlaceholder": "Виберіть дошку",
+ "closedBoard": "{name} (закрита)",
+ "noBoards": "Цей ключ і токен не бачать жодної дошки.",
+ "archivedCards": "Архівні картки",
+ "archivedCardsArchive": "Імпортувати як архівні задачі",
+ "archivedCardsSkip": "Не імпортувати",
+ "members": "Учасники Trello",
+ "membersSkip": "Не зіставляти",
+ "membersMatch": "Зіставити вручну",
+ "membersHint": "Trello не передає email учасників, тому зіставте їх вручну. Перший зіставлений учасник картки стане виконавцем, інші стежитимуть за задачею.",
+ "memberNotMatched": "Не зіставлено"
+ },
"statuses": {
"pending": "В очікуванні",
"running": "Виконується",
@@ -571,7 +595,9 @@
"label": "Мітки",
"state": "Статуси",
"cycle": "Цикли",
- "attachment": "Вкладення"
+ "attachment": "Вкладення",
+ "checklist": "Чек-листи",
+ "custom_field": "Користувацькі поля"
}
},
"issueTemplates": {
diff --git a/apps/web/messages/zh-CN/settings.json b/apps/web/messages/zh-CN/settings.json
index 232d445d..7dc24679 100644
--- a/apps/web/messages/zh-CN/settings.json
+++ b/apps/web/messages/zh-CN/settings.json
@@ -498,7 +498,8 @@
"import": "导入",
"source": "来源",
"sourceHint": "选择导入来源。",
- "comingSoon": "即将推出",
+ "moreSources": "Cloud 和 Pro 中有更多",
+ "moreSourcesHint": "Cloud 和自托管 Pro 支持更多导入来源。",
"connect": "连接 Plane",
"connectHint": "输入自托管的 Plane 实例地址以检查连接并加载其项目。",
"baseUrl": "Plane 地址",
@@ -550,6 +551,29 @@
"noProject": "无项目的工作项",
"noTeams": "此 API 密钥看不到任何团队。"
},
+ "trello": {
+ "connect": "连接 Trello",
+ "connectHint": "输入你的 Trello API 密钥并在 Trello 中授权,以加载你能看到的看板。",
+ "apiKey": "API 密钥",
+ "apiKeyHint": "在 <link>Trello Power-Up 管理页</link> 创建一个 Power-Up,并在它的 API key 标签页生成 API 密钥。在同一标签页把 <code>{origin}</code> 添加到允许的来源(allowed origins):Trello 只会把令牌发送到允许的地址。",
+ "authorize": "在 Trello 中授权",
+ "authorizing": "正在等待 Trello…",
+ "popupBlocked": "浏览器拦截了 Trello 窗口。请允许此网站弹出窗口后重试。",
+ "scope": "导入内容",
+ "scopeHint": "选择要导入的看板。它的未归档列表会成为列。",
+ "board": "看板",
+ "boardPlaceholder": "选择一个看板",
+ "closedBoard": "{name}(已关闭)",
+ "noBoards": "此密钥和令牌看不到任何看板。",
+ "archivedCards": "已归档的卡片",
+ "archivedCardsArchive": "作为已归档工作项导入",
+ "archivedCardsSkip": "不导入",
+ "members": "Trello 成员",
+ "membersSkip": "不匹配",
+ "membersMatch": "手动匹配",
+ "membersHint": "Trello 不提供成员的邮箱,请手动匹配。卡片上第一个匹配的成员成为负责人,其余成员关注该工作项。",
+ "memberNotMatched": "未匹配"
+ },
"statuses": {
"pending": "待处理",
"running": "运行中",
@@ -571,7 +595,9 @@
"label": "标签",
"state": "状态",
"cycle": "周期",
- "attachment": "附件"
+ "attachment": "附件",
+ "checklist": "检查清单",
+ "custom_field": "自定义字段"
}
},
"issueTemplates": {
diff --git a/apps/web/messages/zh-TW/settings.json b/apps/web/messages/zh-TW/settings.json
index e0e46f77..ee25a0fa 100644
--- a/apps/web/messages/zh-TW/settings.json
+++ b/apps/web/messages/zh-TW/settings.json
@@ -498,7 +498,8 @@
"import": "匯入",
"source": "來源",
"sourceHint": "選擇匯入來源。",
- "comingSoon": "即將推出",
+ "moreSources": "Cloud 和 Pro 中有更多",
+ "moreSourcesHint": "Cloud 和自架 Pro 支援更多匯入來源。",
"connect": "連線 Plane",
"connectHint": "輸入自託管的 Plane 執行個體地址以檢查連線並載入其專案。",
"baseUrl": "Plane 地址",
@@ -550,6 +551,29 @@
"noProject": "無專案的工作項目",
"noTeams": "此 API 金鑰看不到任何團隊。"
},
+ "trello": {
+ "connect": "連接 Trello",
+ "connectHint": "輸入你的 Trello API 金鑰並在 Trello 中授權,以載入你能看到的看板。",
+ "apiKey": "API 金鑰",
+ "apiKeyHint": "在 <link>Trello Power-Up 管理頁</link> 建立一個 Power-Up,並在它的 API key 分頁產生 API 金鑰。在同一分頁把 <code>{origin}</code> 加入允許的來源(allowed origins):Trello 只會把權杖傳送到允許的位址。",
+ "authorize": "在 Trello 中授權",
+ "authorizing": "正在等待 Trello…",
+ "popupBlocked": "瀏覽器封鎖了 Trello 視窗。請允許此網站的彈出式視窗後重試。",
+ "scope": "匯入內容",
+ "scopeHint": "選擇要匯入的看板。它的未封存列表會成為欄。",
+ "board": "看板",
+ "boardPlaceholder": "選擇一個看板",
+ "closedBoard": "{name}(已關閉)",
+ "noBoards": "此金鑰和權杖看不到任何看板。",
+ "archivedCards": "已封存的卡片",
+ "archivedCardsArchive": "匯入為已封存的工作項",
+ "archivedCardsSkip": "不匯入",
+ "members": "Trello 成員",
+ "membersSkip": "不配對",
+ "membersMatch": "手動配對",
+ "membersHint": "Trello 不提供成員的電子郵件,請手動配對。卡片上第一個配對的成員成為負責人,其餘成員關注該工作項。",
+ "memberNotMatched": "未配對"
+ },
"statuses": {
"pending": "待處理",
"running": "執行中",
@@ -571,7 +595,9 @@
"label": "標籤",
"state": "狀態",
"cycle": "週期",
- "attachment": "附件"
+ "attachment": "附件",
+ "checklist": "檢查清單",
+ "custom_field": "自訂欄位"
}
},
"issueTemplates": {
diff --git a/apps/web/src/ce/index.ts b/apps/web/src/ce/index.ts
index 1e926a71..1b35a41a 100644
--- a/apps/web/src/ce/index.ts
+++ b/apps/web/src/ce/index.ts
@@ -14,6 +14,7 @@ export { default as ScheduleDialog } from './ScheduleDialog';
export { default as ShellNotice } from './ShellNotice';
export { default as SignInExtras } from './SignInExtras';
export { default as SignInPage } from './SignInPage';
+export { default as useImportSources } from './useImportSources';
export { default as useProjectSettingsSections } from './useProjectSettingsSections';
export { default as useWorkspaceSections } from './useWorkspaceSections';
export { default as WorkspaceRailActions } from './WorkspaceRailActions';
diff --git a/apps/web/src/ce/useImportSources.ts b/apps/web/src/ce/useImportSources.ts
new file mode 100644
index 00000000..9a17a719
--- /dev/null
+++ b/apps/web/src/ce/useImportSources.ts
@@ -0,0 +1,14 @@
+'use client';
+
+import { useTranslations } from 'next-intl';
+import type { ImportSourceEntry } from '@/features/settings/types/importSource';
+
+// A self-hosted instance imports from the core's sources, and a last tab says where
+// more are. The hosted build returns the core's with its own added at any position.
+export default function useImportSources(core: ImportSourceEntry[]): ImportSourceEntry[] {
+ const t = useTranslations('settings.importExport');
+ return [
+ ...core,
+ { kind: 'more', key: 'more', label: t('moreSources'), hint: t('moreSourcesHint') },
+ ];
+}
diff --git a/apps/web/src/features/settings/components/import-export/SettingsImportExport.tsx b/apps/web/src/features/settings/components/import-export/SettingsImportExport.tsx
index d7895723..6069c4b8 100644
--- a/apps/web/src/features/settings/components/import-export/SettingsImportExport.tsx
+++ b/apps/web/src/features/settings/components/import-export/SettingsImportExport.tsx
@@ -1,53 +1,38 @@
import { useState } from 'react';
import { useTranslations } from 'next-intl';
+import { useImportSources } from '@/cloud';
import type { ProjectDetail } from '@/lib/api/endpoints/projects';
-import type {
- ImportSource,
- PlaneConnectionInput,
- PlaneProjectOption,
-} from '@/lib/api/endpoints/importExport';
import { usePermissions } from '@/hooks/usePermissions';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
-import SettingsCard from '@/components/common/page/SettingsCard';
import SettingsSection from '@/components/common/page/SettingsSection';
-import SettingsImportExportConnectForm from './SettingsImportExportConnectForm';
-import SettingsImportExportProjectPicker from './SettingsImportExportProjectPicker';
-import SettingsImportExportMappingReview from './SettingsImportExportMappingReview';
+import type { ImportSourceEntry } from '../../types/importSource';
+import SettingsImportExportPlane from './SettingsImportExportPlane';
+import SettingsImportExportLinear from './SettingsImportExportLinear';
+import SettingsImportExportTrello from './SettingsImportExportTrello';
+import SettingsImportExportMoreSources from './SettingsImportExportMoreSources';
import SettingsImportExportJobList from './SettingsImportExportJobList';
import SettingsImportExportDownloadButton from './SettingsImportExportDownloadButton';
-import SettingsImportExportLinear from './SettingsImportExportLinear';
-
-export interface PlaneConnection extends PlaneConnectionInput {
- projects: PlaneProjectOption[];
-}
-// Plane and Linear import today; the rest are listed disabled.
-const SOURCES = [
- { key: 'plane', label: 'Plane', available: true },
- { key: 'linear', label: 'Linear', available: true },
- { key: 'jira', label: 'Jira', available: false },
- { key: 'trello', label: 'Trello', available: false },
-] as const;
+const CORE_SOURCES: ImportSourceEntry[] = [
+ { kind: 'source', key: 'plane', label: 'Plane', Component: SettingsImportExportPlane },
+ { kind: 'source', key: 'linear', label: 'Linear', Component: SettingsImportExportLinear },
+ { kind: 'source', key: 'trello', label: 'Trello', Component: SettingsImportExportTrello },
+];
-// Import and export on two tabs. Import: pick a source, connect to it, pick a
-// project to import from, and watch the jobs already started. A member who
-// cannot start an import (import_export: create) still sees the job list, since
-// reading it needs only import_export: read, which the page itself already
-// requires; the export tab needs create too.
+// Import and export on two tabs. Import: pick a source, connect to it, pick what to
+// import, and watch the jobs already started. A member who cannot start an import
+// (import_export: create) still sees the job list, since reading it needs only
+// import_export: read, which the page itself already requires; the export tab needs
+// create too.
export default function SettingsImportExport({ project }: { project: ProjectDetail }) {
const t = useTranslations('settings.importExport');
const projectKey = project.project.ref;
const { can } = usePermissions();
const canCreate = can('import_export', 'create');
const canEdit = can('import_export', 'edit');
- const [source, setSource] = useState<ImportSource>('plane');
- const [connection, setConnection] = useState<PlaneConnection | null>(null);
- const [selected, setSelected] = useState<PlaneProjectOption | null>(null);
-
- function onTested(next: PlaneConnection) {
- setConnection(next);
- setSelected(null);
- }
+ const entries = useImportSources(CORE_SOURCES);
+ const [sourceKey, setSourceKey] = useState(CORE_SOURCES[0]!.key);
+ const source = entries.find((e) => e.kind === 'source' && e.key === sourceKey);
return (
<Tabs defaultValue="import">
@@ -59,50 +44,25 @@ export default function SettingsImportExport({ project }: { project: ProjectDeta
{canCreate && (
<>
<SettingsSection title={t('source')} description={t('sourceHint')}>
- <Tabs value={source} onValueChange={(value) => setSource(value as ImportSource)}>
+ <Tabs value={sourceKey} onValueChange={setSourceKey}>
<TabsList variant="line">
- {SOURCES.map((option) => (
- <TabsTrigger key={option.key} value={option.key} disabled={!option.available}>
- {option.label}
- {!option.available && (
- <span className="text-[10px] font-normal tracking-wide uppercase">
- {t('comingSoon')}
- </span>
- )}
- </TabsTrigger>
- ))}
+ {entries.map((entry) =>
+ entry.kind === 'more' ? (
+ <SettingsImportExportMoreSources
+ key={entry.key}
+ label={entry.label}
+ hint={entry.hint}
+ />
+ ) : (
+ <TabsTrigger key={entry.key} value={entry.key}>
+ {entry.label}
+ </TabsTrigger>
+ ),
+ )}
</TabsList>
</Tabs>
</SettingsSection>
- {source === 'plane' && (
- <>
- <SettingsSection title={t('connect')} description={t('connectHint')}>
- <SettingsCard className="p-4">
- <SettingsImportExportConnectForm projectKey={projectKey} onTested={onTested} />
- </SettingsCard>
- </SettingsSection>
- {connection && (
- <SettingsSection title={t('sourceProject')} description={t('sourceProjectHint')}>
- <SettingsCard className="space-y-6 p-4">
- <SettingsImportExportProjectPicker
- key={connection.baseUrl + connection.workspaceSlug}
- connection={connection}
- selected={selected}
- onSelect={setSelected}
- />
- {selected && (
- <SettingsImportExportMappingReview
- projectKey={projectKey}
- target={{ source: 'plane', connection, project: selected }}
- onImported={() => setSelected(null)}
- />
- )}
- </SettingsCard>
- </SettingsSection>
- )}
- </>
- )}
- {source === 'linear' && <SettingsImportExportLinear projectKey={projectKey} />}
+ {source?.kind === 'source' && <source.Component key={source.key} project={project} />}
</>
)}
<SettingsSection title={t('jobs')} description={t('jobsHint')}>
diff --git a/apps/web/src/features/settings/components/import-export/SettingsImportExportConnectForm.tsx b/apps/web/src/features/settings/components/import-export/SettingsImportExportConnectForm.tsx
index ddc37931..4306156f 100644
--- a/apps/web/src/features/settings/components/import-export/SettingsImportExportConnectForm.tsx
+++ b/apps/web/src/features/settings/components/import-export/SettingsImportExportConnectForm.tsx
@@ -4,7 +4,7 @@ import { useTestPlaneConnection } from '../../services/settings.service';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
-import type { PlaneConnection } from './SettingsImportExport';
+import type { PlaneConnection } from './SettingsImportExportPlane';
// baseUrl/workspaceSlug/apiToken for a source Plane instance, checked live
// against it. Nothing is stored until an import is actually started.
diff --git a/apps/web/src/features/settings/components/import-export/SettingsImportExportJobCounts.tsx b/apps/web/src/features/settings/components/import-export/SettingsImportExportJobCounts.tsx
index 68c3bc89..d516d8b4 100644
--- a/apps/web/src/features/settings/components/import-export/SettingsImportExportJobCounts.tsx
+++ b/apps/web/src/features/settings/components/import-export/SettingsImportExportJobCounts.tsx
@@ -9,9 +9,11 @@ const ENTITY_ORDER: ImportEntityType[] = [
'state',
'cycle',
'attachment',
+ 'checklist',
+ 'custom_field',
];
-// Per-entity progress: how many the discover phase found in Plane against how many
+// Per-entity progress: how many the discover phase found in the source against how many
// exist here so far. Attachment counts are metadata captured during create, not
// downloaded bytes — the job never transfers attachment content.
export default function SettingsImportExportJobCounts({ counts }: { counts: ImportJob['counts'] }) {
diff --git a/apps/web/src/features/settings/components/import-export/SettingsImportExportLinear.tsx b/apps/web/src/features/settings/components/import-export/SettingsImportExportLinear.tsx
index 94421895..3c346ff8 100644
--- a/apps/web/src/features/settings/components/import-export/SettingsImportExportLinear.tsx
+++ b/apps/web/src/features/settings/components/import-export/SettingsImportExportLinear.tsx
@@ -1,6 +1,7 @@
import { useState } from 'react';
import { useTranslations } from 'next-intl';
import type { LinearTeamOption } from '@/lib/api/endpoints/importExport';
+import type { ProjectDetail } from '@/lib/api/endpoints/projects';
import SettingsCard from '@/components/common/page/SettingsCard';
import SettingsSection from '@/components/common/page/SettingsSection';
import SettingsImportExportLinearConnectForm from './SettingsImportExportLinearConnectForm';
@@ -16,8 +17,9 @@ export interface LinearConnection {
// The Linear source on the Import tab: check an API key, pick a team and one of its
// projects (or its issues with no project), review the state mapping, start the job.
-export default function SettingsImportExportLinear({ projectKey }: { projectKey: string }) {
+export default function SettingsImportExportLinear({ project }: { project: ProjectDetail }) {
const t = useTranslations('settings.importExport');
+ const projectKey = project.project.ref;
const [connection, setConnection] = useState<LinearConnection | null>(null);
const [team, setTeam] = useState<LinearTeamOption | null>(null);
const [projectChoice, setProjectChoice] = useState<string | null>(null);
diff --git a/apps/web/src/features/settings/components/import-export/SettingsImportExportMappingReview.tsx b/apps/web/src/features/settings/components/import-export/SettingsImportExportMappingReview.tsx
index ac190bb5..02ad4c4d 100644
--- a/apps/web/src/features/settings/components/import-export/SettingsImportExportMappingReview.tsx
+++ b/apps/web/src/features/settings/components/import-export/SettingsImportExportMappingReview.tsx
@@ -3,60 +3,26 @@
import { useState } from 'react';
import { useTranslations } from 'next-intl';
import { toast } from 'sonner';
+import { useCreateImportJob } from '../../services/settings.service';
+import { useImportReviewPreview } from '../../hooks/useImportReviewPreview';
import {
- useCreateImportJob,
- useTestLinearStatesPreview,
- useTestPlaneStatesPreview,
-} from '../../services/settings.service';
+ importJobFields,
+ type ImportReviewTarget,
+ type TrelloImportChoices,
+} from '../../utils/importJobFields';
import { Button } from '@/components/ui/button';
import { Label } from '@/components/ui/label';
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from '@/components/ui/select';
import SettingsCard from '@/components/common/page/SettingsCard';
import ListSkeleton from '@/components/common/skeleton/ListSkeleton';
import SettingsImportExportStateOverrideRow from './SettingsImportExportStateOverrideRow';
-import type {
- LinearImportJobFields,
- LinearTeamOption,
- PlaneConnectionInput,
- PlaneImportJobFields,
- PlaneProjectOption,
- StateCategory,
- UnmatchedUserPolicy,
-} from '@/lib/api/endpoints/importExport';
-
-// What is about to be imported: one Plane project, or one Linear team's project
-// (projectId) or its issues with no project (projectId null).
-export type ImportReviewTarget =
- | { source: 'plane'; connection: PlaneConnectionInput; project: PlaneProjectOption }
- | { source: 'linear'; apiToken: string; team: LinearTeamOption; projectId: string | null };
-
-function jobFields(target: ImportReviewTarget): PlaneImportJobFields | LinearImportJobFields {
- if (target.source === 'plane') {
- return {
- source: 'plane',
- baseUrl: target.connection.baseUrl,
- workspaceSlug: target.connection.workspaceSlug,
- apiToken: target.connection.apiToken,
- planeProjectId: target.project.id,
- planeProjectKey: target.project.identifier,
- };
- }
- const team = { apiToken: target.apiToken, teamId: target.team.id, teamKey: target.team.key };
- return target.projectId
- ? { source: 'linear', ...team, projectFilter: 'project', projectId: target.projectId }
- : { source: 'linear', ...team, projectFilter: 'none' };
-}
+import SettingsImportExportUnmatchedUserPolicy from './SettingsImportExportUnmatchedUserPolicy';
+import SettingsImportExportTrelloOptions from './SettingsImportExportTrelloOptions';
+import type { StateCategory, UnmatchedUserPolicy } from '@/lib/api/endpoints/importExport';
// Shown once a source project is picked, before the job is created: the states
// the source reports for it, each pre-filled with the category itsaplan would map it
-// to automatically, and the unmatched-assignee/comment-author policy. Only a state
-// row the user actually changes from its default is sent as an override.
+// to automatically, and how people are matched. Only a state row the user actually
+// changes from its default is sent as an override.
export default function SettingsImportExportMappingReview({
projectKey,
target,
@@ -67,30 +33,19 @@ export default function SettingsImportExportMappingReview({
onImported: () => void;
}) {
const t = useTranslations('settings.importExport');
- const planePreview = useTestPlaneStatesPreview(
- projectKey,
- target.source === 'plane'
- ? {
- baseUrl: target.connection.baseUrl,
- workspaceSlug: target.connection.workspaceSlug,
- apiToken: target.connection.apiToken,
- planeProjectId: target.project.id,
- }
- : null,
- );
- const linearPreview = useTestLinearStatesPreview(
- projectKey,
- target.source === 'linear' ? { apiToken: target.apiToken, teamId: target.team.id } : null,
- );
- const preview = target.source === 'plane' ? planePreview : linearPreview;
+ const preview = useImportReviewPreview(projectKey, target);
const createJob = useCreateImportJob(projectKey);
const [overrides, setOverrides] = useState<Record<string, StateCategory>>({});
const [unmatchedUserPolicy, setUnmatchedUserPolicy] = useState<UnmatchedUserPolicy>('unassigned');
+ const [trello, setTrello] = useState<TrelloImportChoices>({
+ archivedCards: 'archive',
+ memberMap: null,
+ });
async function start() {
try {
await createJob.mutateAsync({
- ...jobFields(target),
+ ...importJobFields(target, trello),
unmatchedUserPolicy,
stateOverrides: overrides,
});
@@ -144,21 +99,19 @@ export default function SettingsImportExportMappingReview({
</div>
)}
- <div className="w-64 space-y-1.5">
- <Label htmlFor="unmatched-user-policy">{t('unmatchedUserPolicyLabel')}</Label>
- <Select
+ {target.source === 'trello' ? (
+ <SettingsImportExportTrelloOptions
+ members={preview.data?.members ?? []}
+ people={target.people}
+ value={trello}
+ onChange={setTrello}
+ />
+ ) : (
+ <SettingsImportExportUnmatchedUserPolicy
value={unmatchedUserPolicy}
- onValueChange={(value) => setUnmatchedUserPolicy(value as UnmatchedUserPolicy)}
- >
- <SelectTrigger id="unmatched-user-policy" className="w-full">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="unassigned">{t('unmatchedUserPolicyUnassigned')}</SelectItem>
- <SelectItem value="skip">{t('unmatchedUserPolicySkip')}</SelectItem>
- </SelectContent>
- </Select>
- </div>
+ onChange={setUnmatchedUserPolicy}
+ />
+ )}
<Button disabled={createJob.isPending} onClick={() => void start()}>
{createJob.isPending ? t('starting') : t('startImport')}
diff --git a/apps/web/src/features/settings/components/import-export/SettingsImportExportMoreSources.tsx b/apps/web/src/features/settings/components/import-export/SettingsImportExportMoreSources.tsx
new file mode 100644
index 00000000..4c210081
--- /dev/null
+++ b/apps/web/src/features/settings/components/import-export/SettingsImportExportMoreSources.tsx
@@ -0,0 +1,31 @@
+import { ExternalLink, Lock } from 'lucide-react';
+import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
+import { PRO_URL } from '@/utils/app';
+
+// The last of the source tabs where an edition has more sources: a link to that edition,
+// not a tab, so moving through the tabs with the keyboard never opens it.
+export default function SettingsImportExportMoreSources({
+ label,
+ hint,
+}: {
+ label: string;
+ hint: string;
+}) {
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <a
+ href={PRO_URL}
+ target="_blank"
+ rel="noreferrer"
+ className="inline-flex items-center gap-1.5 px-2 text-sm text-muted-foreground hover:text-foreground"
+ >
+ <Lock className="size-3.5" />
+ {label}
+ <ExternalLink className="size-3.5" />
+ </a>
+ </TooltipTrigger>
+ <TooltipContent>{hint}</TooltipContent>
+ </Tooltip>
+ );
+}
diff --git a/apps/web/src/features/settings/components/import-export/SettingsImportExportPlane.tsx b/apps/web/src/features/settings/components/import-export/SettingsImportExportPlane.tsx
new file mode 100644
index 00000000..90f13b3f
--- /dev/null
+++ b/apps/web/src/features/settings/components/import-export/SettingsImportExportPlane.tsx
@@ -0,0 +1,56 @@
+import { useState } from 'react';
+import { useTranslations } from 'next-intl';
+import type { ProjectDetail } from '@/lib/api/endpoints/projects';
+import type { PlaneConnectionInput, PlaneProjectOption } from '@/lib/api/endpoints/importExport';
+import SettingsCard from '@/components/common/page/SettingsCard';
+import SettingsSection from '@/components/common/page/SettingsSection';
+import SettingsImportExportConnectForm from './SettingsImportExportConnectForm';
+import SettingsImportExportProjectPicker from './SettingsImportExportProjectPicker';
+import SettingsImportExportMappingReview from './SettingsImportExportMappingReview';
+
+export interface PlaneConnection extends PlaneConnectionInput {
+ projects: PlaneProjectOption[];
+}
+
+// The Plane source on the Import tab: connect to an instance, pick one of its projects,
+// review the state mapping, start the job.
+export default function SettingsImportExportPlane({ project }: { project: ProjectDetail }) {
+ const t = useTranslations('settings.importExport');
+ const projectKey = project.project.ref;
+ const [connection, setConnection] = useState<PlaneConnection | null>(null);
+ const [selected, setSelected] = useState<PlaneProjectOption | null>(null);
+
+ function onTested(next: PlaneConnection) {
+ setConnection(next);
+ setSelected(null);
+ }
+
+ return (
+ <>
+ <SettingsSection title={t('connect')} description={t('connectHint')}>
+ <SettingsCard className="p-4">
+ <SettingsImportExportConnectForm projectKey={projectKey} onTested={onTested} />
+ </SettingsCard>
+ </SettingsSection>
+ {connection && (
+ <SettingsSection title={t('sourceProject')} description={t('sourceProjectHint')}>
+ <SettingsCard className="space-y-6 p-4">
+ <SettingsImportExportProjectPicker
+ key={connection.baseUrl + connection.workspaceSlug}
+ connection={connection}
+ selected={selected}
+ onSelect={setSelected}
+ />
+ {selected && (
+ <SettingsImportExportMappingReview
+ projectKey={projectKey}
+ target={{ source: 'plane', connection, project: selected }}
+ onImported={() => setSelected(null)}
+ />
+ )}
+ </SettingsCard>
+ </SettingsSection>
+ )}
+ </>
+ );
+}
diff --git a/apps/web/src/features/settings/components/import-export/SettingsImportExportProjectPicker.tsx b/apps/web/src/features/settings/components/import-export/SettingsImportExportProjectPicker.tsx
index b068a5a8..63b44015 100644
--- a/apps/web/src/features/settings/components/import-export/SettingsImportExportProjectPicker.tsx
+++ b/apps/web/src/features/settings/components/import-export/SettingsImportExportProjectPicker.tsx
@@ -7,7 +7,7 @@ import {
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
-import type { PlaneConnection } from './SettingsImportExport';
+import type { PlaneConnection } from './SettingsImportExportPlane';
import type { PlaneProjectOption } from '@/lib/api/endpoints/importExport';
// The projects of the tested workspace. Selecting one is reported to the parent,
diff --git a/apps/web/src/features/settings/components/import-export/SettingsImportExportTrello.tsx b/apps/web/src/features/settings/components/import-export/SettingsImportExportTrello.tsx
new file mode 100644
index 00000000..ba65a798
--- /dev/null
+++ b/apps/web/src/features/settings/components/import-export/SettingsImportExportTrello.tsx
@@ -0,0 +1,61 @@
+import { useState } from 'react';
+import { useTranslations } from 'next-intl';
+import type { ProjectDetail } from '@/lib/api/endpoints/projects';
+import type { TrelloBoardOption, TrelloConnectionInput } from '@/lib/api/endpoints/importExport';
+import SettingsCard from '@/components/common/page/SettingsCard';
+import SettingsSection from '@/components/common/page/SettingsSection';
+import SettingsImportExportTrelloConnectForm from './SettingsImportExportTrelloConnectForm';
+import SettingsImportExportTrelloBoardPicker from './SettingsImportExportTrelloBoardPicker';
+import SettingsImportExportMappingReview from './SettingsImportExportMappingReview';
+
+export interface TrelloConnection extends TrelloConnectionInput {
+ boards: TrelloBoardOption[];
+}
+
+// The Trello source on the Import tab: authorize an API key, pick a board, review the
+// list mapping, archived cards and members, start the job.
+export default function SettingsImportExportTrello({ project }: { project: ProjectDetail }) {
+ const t = useTranslations('settings.importExport');
+ const projectKey = project.project.ref;
+ const [connection, setConnection] = useState<TrelloConnection | null>(null);
+ const [board, setBoard] = useState<TrelloBoardOption | null>(null);
+
+ function onTested(next: TrelloConnection) {
+ setConnection(next);
+ setBoard(null);
+ }
+
+ return (
+ <>
+ <SettingsSection title={t('trello.connect')} description={t('trello.connectHint')}>
+ <SettingsCard className="p-4">
+ <SettingsImportExportTrelloConnectForm projectKey={projectKey} onTested={onTested} />
+ </SettingsCard>
+ </SettingsSection>
+ {connection && (
+ <SettingsSection title={t('trello.scope')} description={t('trello.scopeHint')}>
+ <SettingsCard className="space-y-6 p-4">
+ <SettingsImportExportTrelloBoardPicker
+ boards={connection.boards}
+ selected={board}
+ onSelect={setBoard}
+ />
+ {board && (
+ <SettingsImportExportMappingReview
+ key={board.id}
+ projectKey={projectKey}
+ target={{
+ source: 'trello',
+ connection: { apiKey: connection.apiKey, apiToken: connection.apiToken },
+ board,
+ people: project.assignees.filter((a) => a.kind === 'member'),
+ }}
+ onImported={() => setBoard(null)}
+ />
+ )}
+ </SettingsCard>
+ </SettingsSection>
+ )}
+ </>
+ );
+}
diff --git a/apps/web/src/features/settings/components/import-export/SettingsImportExportTrelloBoardPicker.tsx b/apps/web/src/features/settings/components/import-export/SettingsImportExportTrelloBoardPicker.tsx
new file mode 100644
index 00000000..4cd5fd57
--- /dev/null
+++ b/apps/web/src/features/settings/components/import-export/SettingsImportExportTrelloBoardPicker.tsx
@@ -0,0 +1,49 @@
+import { useTranslations } from 'next-intl';
+import { Label } from '@/components/ui/label';
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from '@/components/ui/select';
+import type { TrelloBoardOption } from '@/lib/api/endpoints/importExport';
+
+// The boards the tested key and token can see. This component only picks; the
+// parent shows the review for the picked board.
+export default function SettingsImportExportTrelloBoardPicker({
+ boards,
+ selected,
+ onSelect,
+}: {
+ boards: TrelloBoardOption[];
+ selected: TrelloBoardOption | null;
+ onSelect: (board: TrelloBoardOption | null) => void;
+}) {
+ const t = useTranslations('settings.importExport');
+
+ if (boards.length === 0) {
+ return <p className="text-sm text-muted-foreground">{t('trello.noBoards')}</p>;
+ }
+
+ return (
+ <div className="w-64 space-y-1.5">
+ <Label htmlFor="trello-board">{t('trello.board')}</Label>
+ <Select
+ value={selected?.id ?? ''}
+ onValueChange={(id) => onSelect(boards.find((b) => b.id === id) ?? null)}
+ >
+ <SelectTrigger id="trello-board" className="w-full">
+ <SelectValue placeholder={t('trello.boardPlaceholder')} />
+ </SelectTrigger>
+ <SelectContent>
+ {boards.map((b) => (
+ <SelectItem key={b.id} value={b.id}>
+ {b.closed ? t('trello.closedBoard', { name: b.name }) : b.name}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/settings/components/import-export/SettingsImportExportTrelloConnectForm.tsx b/apps/web/src/features/settings/components/import-export/SettingsImportExportTrelloConnectForm.tsx
new file mode 100644
index 00000000..9b3ac078
--- /dev/null
+++ b/apps/web/src/features/settings/components/import-export/SettingsImportExportTrelloConnectForm.tsx
@@ -0,0 +1,93 @@
+import { useState, type FormEvent } from 'react';
+import { useTranslations } from 'next-intl';
+import { toast } from 'sonner';
+import { useTestTrelloConnection } from '../../services/settings.service';
+import { useTrelloAuthorize } from '../../hooks/useTrelloAuthorize';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { Label } from '@/components/ui/label';
+import type { TrelloConnection } from './SettingsImportExportTrello';
+
+// A Trello API key, then Trello's own authorization for it: the token comes back
+// from Trello's window and is checked live. Nothing is stored until an import is
+// actually started.
+export default function SettingsImportExportTrelloConnectForm({
+ projectKey,
+ onTested,
+}: {
+ projectKey: string;
+ onTested: (connection: TrelloConnection) => void;
+}) {
+ const t = useTranslations('settings.importExport');
+ const testConnection = useTestTrelloConnection(projectKey);
+ const authorize = useTrelloAuthorize();
+ const [apiKey, setApiKey] = useState('');
+ const [authorizing, setAuthorizing] = useState(false);
+
+ async function submit(event: FormEvent<HTMLFormElement>) {
+ event.preventDefault();
+ const key = apiKey.trim();
+ setAuthorizing(true);
+ let apiToken: string | null;
+ try {
+ apiToken = await authorize(key);
+ } catch {
+ toast.error(t('trello.popupBlocked'));
+ return;
+ } finally {
+ setAuthorizing(false);
+ }
+ if (!apiToken) return;
+ try {
+ const result = await testConnection.mutateAsync({ apiKey: key, apiToken });
+ onTested({ apiKey: key, apiToken, boards: result.boards });
+ } catch {
+ // Surfaced by the global mutation error toast; nothing local to do.
+ }
+ }
+
+ const busy = authorizing || testConnection.isPending;
+ let submitLabel = t('trello.authorize');
+ if (authorizing) submitLabel = t('trello.authorizing');
+ else if (testConnection.isPending) submitLabel = t('testing');
+
+ return (
+ <form
+ onSubmit={(event) => void submit(event)}
+ autoComplete="off"
+ className="max-w-md space-y-4"
+ >
+ <div className="space-y-1.5">
+ <Label htmlFor="trello-api-key">{t('trello.apiKey')}</Label>
+ <Input
+ id="trello-api-key"
+ autoComplete="off"
+ data-1p-ignore
+ data-lpignore="true"
+ value={apiKey}
+ onChange={(event) => setApiKey(event.target.value)}
+ required
+ />
+ <p className="text-xs text-muted-foreground">
+ {t.rich('trello.apiKeyHint', {
+ origin: typeof window === 'undefined' ? '' : window.location.origin,
+ link: (chunks) => (
+ <a
+ href="https://trello.com/power-ups/admin"
+ target="_blank"
+ rel="noreferrer"
+ className="underline"
+ >
+ {chunks}
+ </a>
+ ),
+ code: (chunks) => <code className="font-mono">{chunks}</code>,
+ })}
+ </p>
+ </div>
+ <Button type="submit" disabled={busy || apiKey.trim() === ''}>
+ {submitLabel}
+ </Button>
+ </form>
+ );
+}
diff --git a/apps/web/src/features/settings/components/import-export/SettingsImportExportTrelloMemberRow.tsx b/apps/web/src/features/settings/components/import-export/SettingsImportExportTrelloMemberRow.tsx
new file mode 100644
index 00000000..51415aa0
--- /dev/null
+++ b/apps/web/src/features/settings/components/import-export/SettingsImportExportTrelloMemberRow.tsx
@@ -0,0 +1,53 @@
+import { useTranslations } from 'next-intl';
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from '@/components/ui/select';
+import type { Assignee } from '@/lib/api/endpoints/projects';
+import type { TrelloMemberOption } from '@/lib/api/endpoints/importExport';
+
+// A Select item cannot carry an empty value.
+const NOT_MATCHED = 'not-matched';
+
+// One Trello member and the project member it is matched with, if any. A row of
+// the card its parent renders.
+export default function SettingsImportExportTrelloMemberRow({
+ member,
+ people,
+ value,
+ onChange,
+}: {
+ member: TrelloMemberOption;
+ people: Assignee[];
+ value: string | null;
+ onChange: (userId: string | null) => void;
+}) {
+ const t = useTranslations('settings.importExport');
+ return (
+ <div className="flex items-center justify-between gap-4 px-3 py-2">
+ <span className="min-w-0 flex-1 truncate text-sm">
+ {member.fullName || member.username}{' '}
+ <span className="text-muted-foreground">@{member.username}</span>
+ </span>
+ <Select
+ value={value ?? NOT_MATCHED}
+ onValueChange={(next) => onChange(next === NOT_MATCHED ? null : next)}
+ >
+ <SelectTrigger size="sm" className="w-48 shrink-0">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value={NOT_MATCHED}>{t('trello.memberNotMatched')}</SelectItem>
+ {people.map((person) => (
+ <SelectItem key={person.userId} value={person.userId}>
+ {person.name}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/settings/components/import-export/SettingsImportExportTrelloOptions.tsx b/apps/web/src/features/settings/components/import-export/SettingsImportExportTrelloOptions.tsx
new file mode 100644
index 00000000..b2a727d2
--- /dev/null
+++ b/apps/web/src/features/settings/components/import-export/SettingsImportExportTrelloOptions.tsx
@@ -0,0 +1,95 @@
+import { useTranslations } from 'next-intl';
+import { Label } from '@/components/ui/label';
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from '@/components/ui/select';
+import SettingsCard from '@/components/common/page/SettingsCard';
+import type { Assignee } from '@/lib/api/endpoints/projects';
+import type { TrelloArchivedCards, TrelloMemberOption } from '@/lib/api/endpoints/importExport';
+import type { TrelloImportChoices } from '../../utils/importJobFields';
+import SettingsImportExportTrelloMemberRow from './SettingsImportExportTrelloMemberRow';
+
+// What only a Trello import asks before it starts: what to do with archived cards,
+// and whether to match the board's members with project members by hand. Trello
+// shares no member's email, so there is nothing to match them by automatically.
+export default function SettingsImportExportTrelloOptions({
+ members,
+ people,
+ value,
+ onChange,
+}: {
+ members: TrelloMemberOption[];
+ people: Assignee[];
+ value: TrelloImportChoices;
+ onChange: (next: TrelloImportChoices) => void;
+}) {
+ const t = useTranslations('settings.importExport');
+ const memberMap = value.memberMap;
+
+ function setMember(memberId: string, userId: string | null) {
+ const { [memberId]: _previous, ...rest } = memberMap ?? {};
+ onChange({ ...value, memberMap: userId ? { ...rest, [memberId]: userId } : rest });
+ }
+
+ return (
+ <div className="space-y-6">
+ <div className="w-64 space-y-1.5">
+ <Label htmlFor="trello-archived-cards">{t('trello.archivedCards')}</Label>
+ <Select
+ value={value.archivedCards}
+ onValueChange={(next) =>
+ onChange({ ...value, archivedCards: next as TrelloArchivedCards })
+ }
+ >
+ <SelectTrigger id="trello-archived-cards" className="w-full">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="archive">{t('trello.archivedCardsArchive')}</SelectItem>
+ <SelectItem value="skip">{t('trello.archivedCardsSkip')}</SelectItem>
+ </SelectContent>
+ </Select>
+ </div>
+
+ <div className="space-y-2">
+ <div className="w-64 space-y-1.5">
+ <Label htmlFor="trello-members">{t('trello.members')}</Label>
+ <Select
+ value={memberMap ? 'match' : 'skip'}
+ onValueChange={(next) =>
+ onChange({ ...value, memberMap: next === 'match' ? {} : null })
+ }
+ >
+ <SelectTrigger id="trello-members" className="w-full">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="skip">{t('trello.membersSkip')}</SelectItem>
+ <SelectItem value="match">{t('trello.membersMatch')}</SelectItem>
+ </SelectContent>
+ </Select>
+ </div>
+ {memberMap && (
+ <>
+ <p className="text-xs text-muted-foreground">{t('trello.membersHint')}</p>
+ <SettingsCard className="max-h-64 divide-y divide-border/60 overflow-y-auto">
+ {members.map((member) => (
+ <SettingsImportExportTrelloMemberRow
+ key={member.id}
+ member={member}
+ people={people}
+ value={memberMap[member.id] ?? null}
+ onChange={(userId) => setMember(member.id, userId)}
+ />
+ ))}
+ </SettingsCard>
+ </>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/settings/components/import-export/SettingsImportExportUnmatchedUserPolicy.tsx b/apps/web/src/features/settings/components/import-export/SettingsImportExportUnmatchedUserPolicy.tsx
new file mode 100644
index 00000000..fdd0e2c7
--- /dev/null
+++ b/apps/web/src/features/settings/components/import-export/SettingsImportExportUnmatchedUserPolicy.tsx
@@ -0,0 +1,35 @@
+import { useTranslations } from 'next-intl';
+import { Label } from '@/components/ui/label';
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from '@/components/ui/select';
+import type { UnmatchedUserPolicy } from '@/lib/api/endpoints/importExport';
+
+// What happens to an assignee or comment author whose email matches no project member.
+export default function SettingsImportExportUnmatchedUserPolicy({
+ value,
+ onChange,
+}: {
+ value: UnmatchedUserPolicy;
+ onChange: (policy: UnmatchedUserPolicy) => void;
+}) {
+ const t = useTranslations('settings.importExport');
+ return (
+ <div className="w-64 space-y-1.5">
+ <Label htmlFor="unmatched-user-policy">{t('unmatchedUserPolicyLabel')}</Label>
+ <Select value={value} onValueChange={(next) => onChange(next as UnmatchedUserPolicy)}>
+ <SelectTrigger id="unmatched-user-policy" className="w-full">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="unassigned">{t('unmatchedUserPolicyUnassigned')}</SelectItem>
+ <SelectItem value="skip">{t('unmatchedUserPolicySkip')}</SelectItem>
+ </SelectContent>
+ </Select>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/settings/hooks/useImportReviewPreview.ts b/apps/web/src/features/settings/hooks/useImportReviewPreview.ts
new file mode 100644
index 00000000..8165f15a
--- /dev/null
+++ b/apps/web/src/features/settings/hooks/useImportReviewPreview.ts
@@ -0,0 +1,43 @@
+import type { UseQueryResult } from '@tanstack/react-query';
+import type { PlaneStateOption, TrelloMemberOption } from '@/lib/api/endpoints/importExport';
+import {
+ useTestLinearStatesPreview,
+ useTestPlaneStatesPreview,
+ useTrelloBoardPreview,
+} from '../services/settings.service';
+import type { ImportReviewTarget } from '../utils/importJobFields';
+
+export interface ImportReviewPreview {
+ states: PlaneStateOption[];
+ // A Trello board's members; absent for the other sources.
+ members?: TrelloMemberOption[];
+}
+
+// The preview of the review's target. Every source's query is declared and only the
+// target's one runs.
+export function useImportReviewPreview(
+ projectKey: string,
+ target: ImportReviewTarget,
+): UseQueryResult<ImportReviewPreview> {
+ const plane = useTestPlaneStatesPreview(
+ projectKey,
+ target.source === 'plane'
+ ? {
+ baseUrl: target.connection.baseUrl,
+ workspaceSlug: target.connection.workspaceSlug,
+ apiToken: target.connection.apiToken,
+ planeProjectId: target.project.id,
+ }
+ : null,
+ );
+ const linear = useTestLinearStatesPreview(
+ projectKey,
+ target.source === 'linear' ? { apiToken: target.apiToken, teamId: target.team.id } : null,
+ );
+ const trello = useTrelloBoardPreview(
+ projectKey,
+ target.source === 'trello' ? { ...target.connection, boardId: target.board.id } : null,
+ );
+ if (target.source === 'trello') return trello;
+ return target.source === 'plane' ? plane : linear;
+}
diff --git a/apps/web/src/features/settings/hooks/useTrelloAuthorize.ts b/apps/web/src/features/settings/hooks/useTrelloAuthorize.ts
new file mode 100644
index 00000000..57961b8b
--- /dev/null
+++ b/apps/web/src/features/settings/hooks/useTrelloAuthorize.ts
@@ -0,0 +1,52 @@
+import { useCallback, useEffect, useRef } from 'react';
+
+const TRELLO_ORIGIN = 'https://trello.com';
+// The api accepts only letters and digits in a token.
+const TOKEN = /^[A-Za-z0-9]+$/;
+
+// Opens Trello's authorize page for an API key in a popup. Trello sends the token
+// back to this page with postMessage, and only when this page's origin is one of
+// the key's allowed origins. Resolves with the token, or with null when the popup
+// closes without one; rejects when the browser blocks the popup, which it does
+// unless this is called from a click handler.
+export function useTrelloAuthorize(): (apiKey: string) => Promise<string | null> {
+ const stop = useRef<(() => void) | null>(null);
+ useEffect(() => () => stop.current?.(), []);
+
+ return useCallback((apiKey: string) => {
+ stop.current?.();
+ const params = new URLSearchParams({
+ expiration: '30days',
+ scope: 'read',
+ response_type: 'token',
+ key: apiKey,
+ callback_method: 'postMessage',
+ return_url: window.location.origin,
+ });
+ const popup = window.open(
+ `${TRELLO_ORIGIN}/1/authorize?${params}`,
+ 'trello-authorize',
+ 'popup,width=600,height=720',
+ );
+ if (!popup) return Promise.reject(new Error('the browser blocked the Trello window'));
+
+ return new Promise<string | null>((resolve) => {
+ function onMessage(event: MessageEvent) {
+ if (event.origin !== TRELLO_ORIGIN || event.source !== popup) return;
+ popup!.close();
+ finish(typeof event.data === 'string' && TOKEN.test(event.data) ? event.data : null);
+ }
+ const closed = setInterval(() => {
+ if (popup.closed) finish(null);
+ }, 500);
+ function finish(token: string | null) {
+ window.removeEventListener('message', onMessage);
+ clearInterval(closed);
+ stop.current = null;
+ resolve(token);
+ }
+ window.addEventListener('message', onMessage);
+ stop.current = () => finish(null);
+ });
+ }, []);
+}
diff --git a/apps/web/src/features/settings/services/settings.service.ts b/apps/web/src/features/settings/services/settings.service.ts
index cf5faf8a..b331c7f4 100644
--- a/apps/web/src/features/settings/services/settings.service.ts
+++ b/apps/web/src/features/settings/services/settings.service.ts
@@ -45,6 +45,9 @@ import {
type PlaneConnectionInput,
testLinearConnection,
testLinearStatesPreview,
+ type TrelloConnectionInput,
+ testTrelloConnection,
+ previewTrelloBoard,
testPlaneConnection,
testPlaneStatesPreview,
createImportJob,
@@ -274,8 +277,9 @@ export function useDisconnectGitRepository(projectKey: string, connectionId: num
});
}
-// Import/export section: testing a connection to a source Plane instance or a
-// Linear API key, starting an import job, and tracking the ones already running.
+// Import/export section: testing a connection to a source Plane instance, a Linear
+// API key or a Trello key and token, starting an import job, and tracking the ones
+// already running.
export function useTestPlaneConnection(projectKey: string) {
return useMutation({
mutationFn: (input: PlaneConnectionInput) => testPlaneConnection(projectKey, input),
@@ -314,6 +318,24 @@ export function useTestLinearStatesPreview(
});
}
+export function useTestTrelloConnection(projectKey: string) {
+ return useMutation({
+ mutationFn: (input: TrelloConnectionInput) => testTrelloConnection(projectKey, input),
+ });
+}
+
+// Fetched automatically once a Trello board is picked, in the mapping review step.
+export function useTrelloBoardPreview(
+ projectKey: string,
+ input: (TrelloConnectionInput & { boardId: string }) | null,
+) {
+ return useQuery({
+ queryKey: qk.trelloPreview(projectKey, input?.boardId ?? 'none'),
+ queryFn: () => previewTrelloBoard(projectKey, input!),
+ enabled: input != null,
+ });
+}
+
export function useCreateImportJob(projectKey: string) {
const qc = useQueryClient();
return useMutation({
diff --git a/apps/web/src/features/settings/types/importSource.ts b/apps/web/src/features/settings/types/importSource.ts
new file mode 100644
index 00000000..b4739e68
--- /dev/null
+++ b/apps/web/src/features/settings/types/importSource.ts
@@ -0,0 +1,13 @@
+import type { ComponentType } from 'react';
+import type { ProjectDetail } from '@/lib/api/endpoints/projects';
+
+// One tab of the sources on the Import tab: a source with what its tab shows (connect,
+// pick what to import, start the job), or a link to the editions with more sources.
+export type ImportSourceEntry =
+ | {
+ kind: 'source';
+ key: string;
+ label: string;
+ Component: ComponentType<{ project: ProjectDetail }>;
+ }
+ | { kind: 'more'; key: string; label: string; hint: string };
diff --git a/apps/web/src/features/settings/utils/importJobFields.ts b/apps/web/src/features/settings/utils/importJobFields.ts
new file mode 100644
index 00000000..45645ae8
--- /dev/null
+++ b/apps/web/src/features/settings/utils/importJobFields.ts
@@ -0,0 +1,59 @@
+import type { Assignee } from '@/lib/api/endpoints/projects';
+import type {
+ CreateImportJobInput,
+ LinearTeamOption,
+ PlaneConnectionInput,
+ PlaneProjectOption,
+ TrelloArchivedCards,
+ TrelloBoardOption,
+ TrelloConnectionInput,
+} from '@/lib/api/endpoints/importExport';
+
+// memberMap null: the members are not matched, and no card gets an assignee.
+export interface TrelloImportChoices {
+ archivedCards: TrelloArchivedCards;
+ memberMap: Record<string, string> | null;
+}
+
+// What is about to be imported: one Plane project, one Linear team's project
+// (projectId) or its issues with no project (projectId null), or one Trello board
+// with the project members its members can be matched with.
+export type ImportReviewTarget =
+ | { source: 'plane'; connection: PlaneConnectionInput; project: PlaneProjectOption }
+ | { source: 'linear'; apiToken: string; team: LinearTeamOption; projectId: string | null }
+ | {
+ source: 'trello';
+ connection: TrelloConnectionInput;
+ board: TrelloBoardOption;
+ people: Assignee[];
+ };
+
+// The source fields of the job a review starts. `trello` is read for a Trello target only.
+export function importJobFields(
+ target: ImportReviewTarget,
+ trello: TrelloImportChoices,
+): CreateImportJobInput {
+ if (target.source === 'plane') {
+ return {
+ source: 'plane',
+ baseUrl: target.connection.baseUrl,
+ workspaceSlug: target.connection.workspaceSlug,
+ apiToken: target.connection.apiToken,
+ planeProjectId: target.project.id,
+ planeProjectKey: target.project.identifier,
+ };
+ }
+ if (target.source === 'trello') {
+ return {
+ source: 'trello',
+ ...target.connection,
+ boardId: target.board.id,
+ archivedCards: trello.archivedCards,
+ ...(trello.memberMap ? { memberMap: trello.memberMap } : {}),
+ };
+ }
+ const team = { apiToken: target.apiToken, teamId: target.team.id, teamKey: target.team.key };
+ return target.projectId
+ ? { source: 'linear', ...team, projectFilter: 'project', projectId: target.projectId }
+ : { source: 'linear', ...team, projectFilter: 'none' };
+}
diff --git a/apps/web/src/lib/api/endpoints/importExport.ts b/apps/web/src/lib/api/endpoints/importExport.ts
index 4199273c..5156a02e 100644
--- a/apps/web/src/lib/api/endpoints/importExport.ts
+++ b/apps/web/src/lib/api/endpoints/importExport.ts
@@ -1,14 +1,14 @@
import { request } from '@/lib/api/core/client';
-// Import jobs bring issues in from a Plane instance or a Linear workspace (mirrors
-// apps/api modules/import-export/service.ts and linear.ts). Creating one stores an
-// encrypted credential and leaves the job 'pending' for the worker to drive through
-// its phases.
+// Import jobs bring issues in from a Plane instance, a Linear workspace or a Trello
+// board (mirrors apps/api modules/import-export/service.ts, linear.ts and trello.ts).
+// Creating one stores an encrypted credential and leaves the job 'pending' for the
+// worker to drive through its phases.
export type ImportJobPhase = 'discover' | 'create' | 'link' | 'rewrite' | 'attachments' | 'done';
export type ImportJobStatus = 'pending' | 'running' | 'paused' | 'completed' | 'failed';
-export type ImportEntityType = 'issue' | 'comment' | 'label' | 'state' | 'cycle' | 'attachment';
-export type ImportSource = 'plane' | 'linear';
+export type ImportEntityType =
+ 'issue' | 'comment' | 'label' | 'state' | 'cycle' | 'attachment' | 'checklist' | 'custom_field';
export interface ImportEntityCount {
discovered: number;
@@ -18,7 +18,7 @@ export interface ImportEntityCount {
export interface ImportJob {
id: number;
projectId: number;
- source: ImportSource;
+ source: string;
phase: ImportJobPhase;
status: ImportJobStatus;
counts: Record<ImportEntityType, ImportEntityCount>;
@@ -65,6 +65,25 @@ export interface LinearConnectionInput {
apiToken: string;
}
+export interface TrelloConnectionInput {
+ apiKey: string;
+ apiToken: string;
+}
+
+export interface TrelloBoardOption {
+ id: string;
+ name: string;
+ closed: boolean;
+}
+
+export interface TrelloMemberOption {
+ id: string;
+ fullName: string;
+ username: string;
+}
+
+export type TrelloArchivedCards = 'archive' | 'skip';
+
export interface ImportJobChoices {
unmatchedUserPolicy?: UnmatchedUserPolicy;
stateOverrides?: Record<string, StateCategory>;
@@ -84,8 +103,16 @@ export interface LinearImportJobFields extends LinearConnectionInput {
projectId?: string;
}
+export interface TrelloImportJobFields extends TrelloConnectionInput {
+ source: 'trello';
+ boardId: string;
+ archivedCards: TrelloArchivedCards;
+ // Trello member id -> the user id of the project member it is matched with.
+ memberMap?: Record<string, string>;
+}
+
export type CreateImportJobInput = ImportJobChoices &
- (PlaneImportJobFields | LinearImportJobFields);
+ (PlaneImportJobFields | LinearImportJobFields | TrelloImportJobFields);
export const testPlaneConnection = (projectKey: string, input: PlaneConnectionInput) =>
request<{ projects: PlaneProjectOption[] }>(
@@ -117,6 +144,21 @@ export const testLinearStatesPreview = (
body: JSON.stringify(input),
});
+export const testTrelloConnection = (projectKey: string, input: TrelloConnectionInput) =>
+ request<{ boards: TrelloBoardOption[] }>(
+ `/projects/${projectKey}/import-jobs/trello-test-connection`,
+ { method: 'POST', body: JSON.stringify(input) },
+ );
+
+export const previewTrelloBoard = (
+ projectKey: string,
+ input: TrelloConnectionInput & { boardId: string },
+) =>
+ request<{ states: PlaneStateOption[]; members: TrelloMemberOption[] }>(
+ `/projects/${projectKey}/import-jobs/trello-preview`,
+ { method: 'POST', body: JSON.stringify(input) },
+ );
+
export const createImportJob = (projectKey: string, input: CreateImportJobInput) =>
request<ImportJob>(`/projects/${projectKey}/import-jobs`, {
method: 'POST',
diff --git a/apps/web/src/services/queryKeys.ts b/apps/web/src/services/queryKeys.ts
index a422c17e..6693483f 100644
--- a/apps/web/src/services/queryKeys.ts
+++ b/apps/web/src/services/queryKeys.ts
@@ -92,6 +92,9 @@ export const qk = {
// The same preview for one Linear team's workflow states.
linearPreview: (projectKey: string, teamId: string) =>
['linearPreview', projectKey, teamId] as const,
+ // The same preview for one Trello board's lists and members.
+ trelloPreview: (projectKey: string, boardId: string) =>
+ ['trelloPreview', projectKey, boardId] as const,
// Saved dashboards (the analytics tabs) and the read-only metrics behind their
// widgets. `kind` names the metric (stats/pulse/throughput/breakdown/...) and
// `params` scopes it to the widget's query (window, filters).
diff --git a/apps/worker/AGENTS.md b/apps/worker/AGENTS.md
index d48da15c..0d7bb984 100644
--- a/apps/worker/AGENTS.md
+++ b/apps/worker/AGENTS.md
@@ -54,13 +54,20 @@ running to completion in one.
`resolveAttachmentDownload` follows `uploads.linear.app`'s redirects itself
and sends the key to that host only. `docs/dev/linear-import.md` has the
queries, limits and mapping.
+- `trello-adapter.ts` and `trello-mapping.ts` — the Trello implementation: its
+ REST API at the fixed `https://api.trello.com/1` with the job's API key and
+ token, and the pure mapping from Trello's shapes. Lists become states, cards
+ issues with their checklists and custom field values; the board's members
+ reach the job already matched with project members' emails.
+ `docs/dev/trello-import.md` has the requests, limits and mapping.
- `cross-reference.ts` — pure text matching for a source's own "KEY-123"-style
issue identifier: no `@repo/db`, no network, unit-tested directly. What
the Rewrite phase resolves into itsaplan's own issue ids.
- `import-store.ts` — all `@repo/db` access for imports: claiming due jobs,
reading/writing a job's phase/cursor/status, the `import_record`
source-id-to-local-id upsert, and creating the local rows (states, labels,
- cycles, issues, comments, issue links) an import produces.
+ cycles, custom fields, issues, checklists, comments, watchers, issue links)
+ an import produces.
- `import-worker.ts` — the phase state machine. Discover snapshots every
source id up front (`import_record` rows with no local id yet) before Create
begins, rather than treating the source's own pagination cursor as the
@@ -113,11 +120,11 @@ running to completion in one.
`isRetryableStatus` import nothing from `@repo/db`, so unit tests run without a
database. Keep DB access in `store.ts`. Same split for imports: `canonical.ts`,
`reader.ts`, `plane-adapter.ts`, `linear-adapter.ts`, `linear-mapping.ts`,
- `cross-reference.ts`, `attachment-download.ts`, `import-sources.ts`, and
- `import-retry.ts` import nothing from `@repo/db` (their state-category
- normalization, markdown conversion, cursor/rate-limit, and cross-reference
- matching logic are unit-tested directly); `@repo/db` access stays in
- `import-store.ts`.
+ `trello-adapter.ts`, `trello-mapping.ts`, `cross-reference.ts`,
+ `attachment-download.ts`, `import-sources.ts`, and `import-retry.ts` import
+ nothing from `@repo/db` (their state-category normalization, markdown
+ conversion, cursor/rate-limit, and cross-reference matching logic are
+ unit-tested directly); `@repo/db` access stays in `import-store.ts`.
- **An import job's credential is decrypted here, never routed through
`packages/db/src/domains/`.** That directory is for config more than one
process reads; only the worker ever decrypts a stored import credential (the
diff --git a/apps/worker/src/__tests__/integration/import-create.test.ts b/apps/worker/src/__tests__/integration/import-create.test.ts
index b4778a12..2a3ef968 100644
--- a/apps/worker/src/__tests__/integration/import-create.test.ts
+++ b/apps/worker/src/__tests__/integration/import-create.test.ts
@@ -11,6 +11,14 @@ import {
importJob,
importRecord,
issueLabel,
+ issueWatcher,
+ issueChecklist,
+ issueChecklistItem,
+ customField,
+ issueFieldValue,
+ issueFieldOption,
+ customFieldOption,
+ projectMember,
user,
} from '@repo/db';
import { and, eq } from 'drizzle-orm';
@@ -80,6 +88,7 @@ const ISSUE: CanonicalIssue = {
descriptionMarkdown: '',
stateSourceId: 'state-1',
assigneeEmail: null,
+ watcherEmails: [],
labelSourceIds: [],
cycleSourceId: null,
parentSourceId: null,
@@ -89,6 +98,7 @@ const ISSUE: CanonicalIssue = {
customFields: [],
createdAt: '2026-01-01T00:00:00Z',
updatedAt: '2026-01-01T00:00:00Z',
+ archivedAt: null,
};
const COMMENTS: CanonicalComment[] = [
@@ -116,11 +126,13 @@ type CreateReader = Pick<
| 'listStates'
| 'listLabels'
| 'listCycles'
+ | 'listCustomFields'
| 'listIssues'
| 'getIssue'
| 'listIssueRelations'
| 'listIssueComments'
| 'listIssueAttachments'
+ | 'listIssueChecklists'
>;
function readerWithFlakyComments(): SourceReader {
@@ -129,6 +141,7 @@ function readerWithFlakyComments(): SourceReader {
listStates: async () => [],
listLabels: async () => [],
listCycles: async () => [],
+ listCustomFields: async () => [],
listIssues: async () => ({ items: [ISSUE], cursor: null }),
getIssue: async () => ISSUE,
listIssueRelations: async () => [],
@@ -138,6 +151,7 @@ function readerWithFlakyComments(): SourceReader {
return COMMENTS;
},
listIssueAttachments: async () => [],
+ listIssueChecklists: async () => [],
};
return reader as SourceReader;
}
@@ -147,11 +161,13 @@ function readerForIssues(issues: CanonicalIssue[]): SourceReader {
listStates: async () => [],
listLabels: async () => [],
listCycles: async () => [],
+ listCustomFields: async () => [],
listIssues: async () => ({ items: issues, cursor: null }),
getIssue: async (id) => issues.find((item) => item.sourceId === id)!,
listIssueRelations: async () => [],
listIssueComments: async () => COMMENTS,
listIssueAttachments: async () => [],
+ listIssueChecklists: async () => [],
resolveAttachmentDownload: async () => {
throw new Error('Create must not download attachments');
},
@@ -177,7 +193,141 @@ async function seedMappedIssue(job: ClaimedImportJob): Promise<number> {
});
}
+async function addProjectMember(projectId: number, email: string): Promise<string> {
+ const userId = randomUUID();
+ await db.insert(user).values({ id: userId, name: email, email });
+ await db.insert(projectMember).values({ projectId, userId, role: 'member' });
+ return userId;
+}
+
describe('runCreate', () => {
+ it('creates custom fields, checklists, watchers and an archived issue, once across a retry', async () => {
+ const job = await makeCreateJob();
+ const ada = await addProjectMember(job.projectId, `ada-${job.id}@example.test`);
+ const bob = await addProjectMember(job.projectId, `bob-${job.id}@example.test`);
+ const archived: CanonicalIssue = {
+ ...ISSUE,
+ assigneeEmail: `ada-${job.id}@example.test`,
+ watcherEmails: [`bob-${job.id}@example.test`, '[email protected]'],
+ customFields: [
+ { fieldSourceId: 'field-size', value: 'L' },
+ { fieldSourceId: 'field-points', value: 3 },
+ { fieldSourceId: 'field-missing', value: 'lost' },
+ ],
+ archivedAt: '2026-01-05T00:00:00Z',
+ };
+ await insertDiscoveredIds(job.id, 'issue', [archived.sourceId]);
+ await insertDiscoveredIds(job.id, 'custom_field', ['field-size', 'field-points']);
+ const reader = readerForIssues([archived]);
+ reader.listIssueComments = async () => [];
+ reader.listCustomFields = async () => [
+ { sourceId: 'field-size', name: 'Size', fieldType: 'select', options: ['S', 'L'] },
+ { sourceId: 'field-points', name: 'Points', fieldType: 'number', options: [] },
+ ];
+ reader.listIssueChecklists = async () => [
+ {
+ sourceId: 'checklist-1',
+ title: 'Checklist',
+ items: [
+ { content: 'First', done: true },
+ { content: 'Second', done: false },
+ ],
+ },
+ { sourceId: 'checklist-2', title: 'Checklist', items: [] },
+ ];
+
+ await runCreate(job, reader);
+ await runCreate(job, reader);
+
+ const [created] = await db.select().from(issue).where(eq(issue.projectId, job.projectId));
+ expect(created!.assigneeUserId).toBe(ada);
+ expect(created!.archivedAt).toEqual(new Date('2026-01-05T00:00:00Z'));
+ const watchers = await db
+ .select({ userId: issueWatcher.userId })
+ .from(issueWatcher)
+ .where(eq(issueWatcher.issueId, created!.id));
+ expect(watchers).toEqual([{ userId: bob }]);
+
+ const fields = await db
+ .select({ id: customField.id, name: customField.name, fieldType: customField.fieldType })
+ .from(customField)
+ .where(eq(customField.projectId, job.projectId))
+ .orderBy(customField.position);
+ expect(fields.map(({ name, fieldType }) => [name, fieldType])).toEqual([
+ ['Size', 'select'],
+ ['Points', 'number'],
+ ]);
+ const options = await db
+ .select({ value: customFieldOption.value })
+ .from(customFieldOption)
+ .where(eq(customFieldOption.fieldId, fields[0]!.id))
+ .orderBy(customFieldOption.position);
+ expect(options.map((o) => o.value)).toEqual(['S', 'L']);
+ const [picked] = await db
+ .select({ value: customFieldOption.value })
+ .from(issueFieldOption)
+ .innerJoin(customFieldOption, eq(customFieldOption.id, issueFieldOption.optionId))
+ .where(eq(issueFieldOption.issueId, created!.id));
+ expect(picked!.value).toBe('L');
+ const values = await db
+ .select({ valueNumber: issueFieldValue.valueNumber })
+ .from(issueFieldValue)
+ .where(eq(issueFieldValue.issueId, created!.id));
+ expect(values.map((v) => Number(v.valueNumber))).toEqual([3]);
+
+ const checklists = await db
+ .select()
+ .from(issueChecklist)
+ .where(eq(issueChecklist.issueId, created!.id))
+ .orderBy(issueChecklist.position);
+ expect(checklists.map((c) => c.title)).toEqual(['Checklist', 'Checklist']);
+ const items = await db
+ .select({ content: issueChecklistItem.content, done: issueChecklistItem.done })
+ .from(issueChecklistItem)
+ .where(eq(issueChecklistItem.checklistId, checklists[0]!.id))
+ .orderBy(issueChecklistItem.position);
+ expect(items).toEqual([
+ { content: 'First', done: true },
+ { content: 'Second', done: false },
+ ]);
+ });
+
+ it('reuses a field of the same name and type and adds the options it lacks', async () => {
+ const job = await makeCreateJob();
+ const [existing] = await db
+ .insert(customField)
+ .values({ projectId: job.projectId, name: 'Size', fieldType: 'select' })
+ .returning({ id: customField.id });
+ await db.insert(customFieldOption).values({ fieldId: existing!.id, value: 'S' });
+ await db
+ .insert(customField)
+ .values({ projectId: job.projectId, name: 'Points', fieldType: 'text' });
+ await insertDiscoveredIds(job.id, 'custom_field', ['field-size', 'field-points']);
+ const reader = readerForIssues([]);
+ reader.listCustomFields = async () => [
+ { sourceId: 'field-size', name: 'Size', fieldType: 'select', options: ['S', 'L'] },
+ { sourceId: 'field-points', name: 'Points', fieldType: 'number', options: [] },
+ ];
+
+ await runCreate(job, reader);
+
+ expect(await findImportRecord(job.id, 'custom_field', 'field-size')).toEqual({
+ localId: existing!.id,
+ });
+ const options = await db
+ .select({ value: customFieldOption.value })
+ .from(customFieldOption)
+ .where(eq(customFieldOption.fieldId, existing!.id))
+ .orderBy(customFieldOption.position);
+ expect(options.map((o) => o.value)).toEqual(['S', 'L']);
+ const points = await db
+ .select({ fieldType: customField.fieldType })
+ .from(customField)
+ .where(and(eq(customField.projectId, job.projectId), eq(customField.name, 'Points')))
+ .orderBy(customField.id);
+ expect(points.map((p) => p.fieldType)).toEqual(['text', 'number']);
+ });
+
it("creates an issue's comments on the retry after its comment read failed", async () => {
const job = await makeCreateJob();
await insertDiscoveredIds(job.id, 'issue', [ISSUE.sourceId]);
diff --git a/apps/worker/src/__tests__/integration/import-store.test.ts b/apps/worker/src/__tests__/integration/import-store.test.ts
index 26f63942..84d71101 100644
--- a/apps/worker/src/__tests__/integration/import-store.test.ts
+++ b/apps/worker/src/__tests__/integration/import-store.test.ts
@@ -160,13 +160,13 @@ describe('import_job source', () => {
expect(job?.source).toBe('linear');
});
- it('still refuses a source that has no adapter', async () => {
+ it('stores a source the core has no adapter for, which a build can register', async () => {
const { projectId, userId } = await makeProject();
- const error = await db
+ const [row] = await db
.insert(importJob)
- .values({ projectId, createdByUserId: userId, source: 'jira' })
- .catch((e: unknown) => e);
- expect((error as { cause?: Error }).cause?.message).toContain('import_job_source_check');
+ .values({ projectId, createdByUserId: userId, source: 'jira', status: 'paused' })
+ .returning({ source: importJob.source });
+ expect(row!.source).toBe('jira');
});
});
diff --git a/apps/worker/src/__tests__/unit/import-sources.test.ts b/apps/worker/src/__tests__/unit/import-sources.test.ts
index cd7cf425..cfcb2744 100644
--- a/apps/worker/src/__tests__/unit/import-sources.test.ts
+++ b/apps/worker/src/__tests__/unit/import-sources.test.ts
@@ -1,8 +1,9 @@
import { describe, it, expect } from 'bun:test';
-import { readerForJob, sourceProjectKeyForJob } from '../../import-sources';
+import { readerForJob, registerImportSource, sourceProjectKeyForJob } from '../../import-sources';
import { LinearReader } from '../../linear-adapter';
import { PlaneReader } from '../../plane-adapter';
-import { UnsupportedImportSourceError } from '../../reader';
+import { TrelloReader } from '../../trello-adapter';
+import { UnsupportedImportSourceError, type SourceReader } from '../../reader';
const planeCredential = {
baseUrl: 'https://plane.example.test',
@@ -12,6 +13,9 @@ const planeCredential = {
const linearCredential = { apiKey: 'lin_api_test' };
+const trelloCredential = { apiKey: 'trellokey1', token: 'ATTAtoken1' };
+const trelloConfig = { boardId: 'board1', archivedCards: 'archive' };
+
describe('readerForJob', () => {
it('builds a Plane reader for a Plane job', () => {
const job = { id: 7, source: 'plane', config: { planeProjectId: 'project-1' } };
@@ -66,6 +70,33 @@ describe('readerForJob', () => {
);
});
+ it('builds a Trello reader for a board', () => {
+ const job = { id: 9, source: 'trello', config: trelloConfig };
+ expect(readerForJob(job, trelloCredential)).toBeInstanceOf(TrelloReader);
+ });
+
+ it.each([
+ { archivedCards: 'archive' },
+ { boardId: 'board1' },
+ { boardId: 'board1', archivedCards: 'keep' },
+ ])('refuses a Trello job with no complete board config: %o', (config) => {
+ const job = { id: 9, source: 'trello', config };
+ expect(() => readerForJob(job, trelloCredential)).toThrow(
+ 'import job 9 has no source board configured',
+ );
+ });
+
+ it.each([
+ ['a Linear-shaped credential', linearCredential],
+ ['an empty token', { apiKey: 'trellokey1', token: '' }],
+ ['an extra field', { ...trelloCredential, baseUrl: 'https://trello.example.test' }],
+ ])('refuses a Trello job whose credential is %s', (_name, credential) => {
+ const job = { id: 9, source: 'trello', config: trelloConfig };
+ expect(() => readerForJob(job, credential as never)).toThrow(
+ 'import job 9 has a credential that is not a Trello key and token',
+ );
+ });
+
it('marks an unsupported source as a permanent error', () => {
const job = { id: 7, source: 'jira', config: {} };
expect(() => readerForJob(job, planeCredential)).toThrow(UnsupportedImportSourceError);
@@ -79,6 +110,34 @@ describe('readerForJob', () => {
});
});
+describe('registerImportSource', () => {
+ it('adds a source that jobs of that name are read with', () => {
+ const reader = {} as SourceReader;
+ const seen: unknown[] = [];
+ registerImportSource<{ token: string }, { boardKey: string }>('registered-test', {
+ buildReader(credential, config, jobId) {
+ seen.push(credential, config, jobId);
+ return reader;
+ },
+ projectKey: (config) => config.boardKey ?? null,
+ });
+ const job = { id: 11, source: 'registered-test', config: { boardKey: 'KEY' } };
+
+ expect(readerForJob(job, { token: 't' })).toBe(reader);
+ expect(seen).toEqual([{ token: 't' }, { boardKey: 'KEY' }, 11]);
+ expect(sourceProjectKeyForJob(job)).toBe('KEY');
+ });
+
+ it('refuses a name that is already taken', () => {
+ expect(() =>
+ registerImportSource('trello', {
+ buildReader: () => ({}) as SourceReader,
+ projectKey: () => null,
+ }),
+ ).toThrow('import source "trello" is already registered');
+ });
+});
+
describe('sourceProjectKeyForJob', () => {
it("returns a Plane job's project identifier", () => {
const job = {
@@ -102,4 +161,8 @@ describe('sourceProjectKeyForJob', () => {
};
expect(sourceProjectKeyForJob(job)).toBe('ATO');
});
+
+ it('returns null for a Trello job: a card has no key-style identifier', () => {
+ expect(sourceProjectKeyForJob({ id: 9, source: 'trello', config: trelloConfig })).toBeNull();
+ });
});
diff --git a/apps/worker/src/__tests__/unit/linear-adapter.test.ts b/apps/worker/src/__tests__/unit/linear-adapter.test.ts
index 147d3422..99f4cff2 100644
--- a/apps/worker/src/__tests__/unit/linear-adapter.test.ts
+++ b/apps/worker/src/__tests__/unit/linear-adapter.test.ts
@@ -1,12 +1,11 @@
import { describe, it, expect } from 'bun:test';
import type { PinnedRequestInit } from '@repo/net';
-import { AttachmentRejectedError } from '../../attachment-download';
+import { AttachmentRejectedError, nextDownloadHop } from '../../attachment-download';
import {
LINEAR_GRAPHQL_URL,
LinearReader,
linearRateLimitBackoffMs,
linearUploadHeaders,
- nextUploadHop,
} from '../../linear-adapter';
import type { LinearIssueNode, LinearScope } from '../../linear-mapping';
import { SourceRateLimitedError } from '../../reader';
@@ -426,11 +425,11 @@ describe('upload helpers', () => {
});
it('reads a redirect without a location as a refusal', () => {
- expect(() => nextUploadHop(UPLOAD, 302, null)).toThrow(
+ expect(() => nextDownloadHop('Linear', UPLOAD, 302, null)).toThrow(
'Linear file storage redirected nowhere',
);
- expect(nextUploadHop(UPLOAD, 204, null)).toEqual({ kind: 'download' });
- expect(nextUploadHop(UPLOAD, 410, null)).toEqual({ kind: 'refused' });
+ expect(nextDownloadHop('Linear', UPLOAD, 204, null)).toEqual({ kind: 'download' });
+ expect(nextDownloadHop('Linear', UPLOAD, 410, null)).toEqual({ kind: 'refused' });
});
});
diff --git a/apps/worker/src/__tests__/unit/linear-mapping.test.ts b/apps/worker/src/__tests__/unit/linear-mapping.test.ts
index 01c3551e..87b02f6e 100644
--- a/apps/worker/src/__tests__/unit/linear-mapping.test.ts
+++ b/apps/worker/src/__tests__/unit/linear-mapping.test.ts
@@ -181,6 +181,7 @@ describe('mapLinearIssue', () => {
descriptionMarkdown: 'Body text.\n\nImported from Linear: ATO-505',
stateSourceId: 'state-todo',
assigneeEmail: '[email protected]',
+ watcherEmails: [],
labelSourceIds: ['label-bug', 'label-api'],
cycleSourceId: 'cycle-7',
parentSourceId: null,
@@ -190,6 +191,7 @@ describe('mapLinearIssue', () => {
customFields: [],
createdAt: '2025-01-02T03:04:05.000Z',
updatedAt: '2025-02-03T04:05:06.000Z',
+ archivedAt: null,
});
});
diff --git a/apps/worker/src/__tests__/unit/trello-adapter.test.ts b/apps/worker/src/__tests__/unit/trello-adapter.test.ts
new file mode 100644
index 00000000..fbadda51
--- /dev/null
+++ b/apps/worker/src/__tests__/unit/trello-adapter.test.ts
@@ -0,0 +1,227 @@
+import { describe, it, expect } from 'bun:test';
+import type { PinnedRequestInit } from '@repo/net';
+import { AttachmentRejectedError } from '../../attachment-download';
+import { SourceRateLimitedError } from '../../reader';
+import {
+ TRELLO_API_URL,
+ TrelloReader,
+ trelloAuthorization,
+ trelloFileHeaders,
+} from '../../trello-adapter';
+import type { TrelloCard, TrelloScope } from '../../trello-mapping';
+
+const CREDENTIAL = { apiKey: 'trellokey1', token: 'ATTAtoken1' };
+const AUTH = { Authorization: 'OAuth oauth_consumer_key="trellokey1", oauth_token="ATTAtoken1"' };
+const SCOPE: TrelloScope = { boardId: 'board-1', archivedCards: 'skip', memberEmails: {} };
+const UPLOAD = 'https://trello.com/1/cards/card-1/attachments/a1/download/shot.png';
+const SIGNED = 'https://storage.example.test/bucket/shot.png?signature=abc';
+
+interface SentRequest {
+ url: string;
+ init: PinnedRequestInit | undefined;
+}
+
+function readerAnswering(responses: Response[], sent: SentRequest[] = [], scope = SCOPE) {
+ const queue = [...responses];
+ return new TrelloReader(CREDENTIAL, scope, async (url, init) => {
+ sent.push({ url, init });
+ const next = queue.shift();
+ if (!next) throw new Error(`unexpected request ${url}`);
+ return next;
+ });
+}
+
+function card(id: string, overrides: Partial<TrelloCard> = {}): TrelloCard {
+ return {
+ id,
+ idShort: 1,
+ name: id,
+ desc: '',
+ closed: false,
+ idList: 'list-1',
+ pos: 1,
+ idLabels: [],
+ idMembers: [],
+ start: null,
+ due: null,
+ dateLastActivity: '2026-02-03T04:05:06.000Z',
+ shortUrl: `https://trello.com/c/${id}`,
+ attachments: [],
+ ...overrides,
+ };
+}
+
+const LISTS = [{ id: 'list-1', name: 'To Do', closed: false, pos: 1 }];
+
+describe('TrelloReader requests', () => {
+ it('sends the key and token in the Authorization header to the Trello API only', async () => {
+ const sent: SentRequest[] = [];
+ const reader = readerAnswering(
+ [Response.json([{ id: 'l1', name: 'Bug', color: 'red' }])],
+ sent,
+ );
+
+ expect(await reader.listLabels()).toEqual([{ sourceId: 'l1', name: 'Bug', color: '#eb5a46' }]);
+ expect(sent).toEqual([
+ {
+ url: `${TRELLO_API_URL}/boards/board-1/labels?fields=name%2Ccolor&limit=1000`,
+ init: { headers: AUTH, timeoutMs: 15_000 },
+ },
+ ]);
+ });
+
+ it('reads every card in pages of 1000 and returns them in one page', async () => {
+ const sent: SentRequest[] = [];
+ const firstPage = Array.from({ length: 1000 }, (_, i) =>
+ card(`65000000${String(1000 + i).padStart(16, '0')}`, { pos: i }),
+ );
+ const reader = readerAnswering(
+ [
+ Response.json(firstPage),
+ Response.json([card('64000000aaaaaaaaaaaaaaaa', { pos: 5000 })]),
+ Response.json(LISTS),
+ Response.json([]),
+ ],
+ sent,
+ );
+
+ const page = await reader.listIssues();
+
+ expect(page.cursor).toBeNull();
+ expect(page.items).toHaveLength(1001);
+ const second = new URL(sent[1]!.url);
+ expect(second.pathname).toBe('/1/boards/board-1/cards');
+ expect(second.searchParams.get('filter')).toBe('open');
+ expect(second.searchParams.get('before')).toBe('650000000000000000001000');
+ });
+
+ it('asks for archived cards too when they are imported archived', async () => {
+ const sent: SentRequest[] = [];
+ const reader = readerAnswering(
+ [Response.json([]), Response.json(LISTS), Response.json([])],
+ sent,
+ { ...SCOPE, archivedCards: 'archive' },
+ );
+ await reader.listIssues();
+ expect(new URL(sent[0]!.url).searchParams.get('filter')).toBe('all');
+ });
+
+ it('waits out a rate limit and fails on any other error', async () => {
+ await expect(
+ readerAnswering([new Response('', { status: 429 })]).listLabels(),
+ ).rejects.toBeInstanceOf(SourceRateLimitedError);
+ await expect(readerAnswering([new Response('', { status: 401 })]).listLabels()).rejects.toThrow(
+ 'Trello request failed: HTTP 401',
+ );
+ });
+
+ it('links a card to another card of the same board only', async () => {
+ const linked = (shortLink: string) => ({
+ id: `link-${shortLink}`,
+ name: `https://trello.com/c/${shortLink}`,
+ url: `https://trello.com/c/${shortLink}/2-title`,
+ isUpload: false,
+ bytes: null,
+ mimeType: null,
+ });
+ const reader = readerAnswering([
+ Response.json(
+ card('card-1', {
+ attachments: [linked('Same1'), linked('Other1'), linked('Gone1'), linked('zz')],
+ }),
+ ),
+ Response.json({ id: 'card-2', idBoard: 'board-1' }),
+ Response.json({ id: 'card-3', idBoard: 'board-other' }),
+ new Response('Card not found', { status: 404 }),
+ new Response('invalid id', { status: 400 }),
+ ]);
+
+ expect(await reader.listIssueRelations('card-1')).toEqual([
+ { kind: 'relates', sourceIssueSourceId: 'card-1', targetIssueSourceId: 'card-2' },
+ ]);
+ });
+
+ it('pages comments before the oldest one and returns them oldest first', async () => {
+ const sent: SentRequest[] = [];
+ const comment = (id: string, date: string) => ({
+ id,
+ date,
+ idMemberCreator: 'm1',
+ data: { text: id },
+ memberCreator: { fullName: 'Ada', username: 'ada' },
+ });
+ const full = Array.from({ length: 1000 }, (_, i) =>
+ comment(`66000000${String(1000 + i).padStart(16, '0')}`, '2026-02-02T00:00:00.000Z'),
+ );
+ const reader = readerAnswering(
+ [
+ Response.json(full),
+ Response.json([comment('65000000aaaaaaaaaaaaaaaa', '2026-01-01T00:00:00.000Z')]),
+ ],
+ sent,
+ );
+
+ const comments = await reader.listIssueComments('card-1');
+
+ expect(comments).toHaveLength(1001);
+ expect(comments[0]!.sourceId).toBe('65000000aaaaaaaaaaaaaaaa');
+ expect(new URL(sent[1]!.url).searchParams.get('before')).toBe('660000000000000000001000');
+ });
+});
+
+describe('resolveAttachmentDownload', () => {
+ const withUpload = () =>
+ Response.json(
+ card('card-1', {
+ attachments: [
+ {
+ id: 'a1',
+ name: 'shot.png',
+ url: UPLOAD,
+ isUpload: true,
+ bytes: 10,
+ mimeType: 'image/png',
+ },
+ ],
+ }),
+ );
+
+ it('follows the redirect to storage and never sends the key and token past Trello', async () => {
+ const sent: SentRequest[] = [];
+ const reader = readerAnswering(
+ [
+ withUpload(),
+ new Response(null, { status: 302, headers: { location: SIGNED } }),
+ new Response('', { status: 200 }),
+ ],
+ sent,
+ );
+
+ expect(await reader.resolveAttachmentDownload('card-1', 'a1')).toStrictEqual({ url: SIGNED });
+ expect(sent.slice(1).map((r) => [r.url, r.init?.headers])).toEqual([
+ [UPLOAD, AUTH],
+ [SIGNED, undefined],
+ ]);
+ });
+
+ it('skips a file that is no longer on the card', async () => {
+ const reader = readerAnswering([withUpload()]);
+ await expect(reader.resolveAttachmentDownload('card-1', 'gone')).rejects.toBeInstanceOf(
+ AttachmentRejectedError,
+ );
+ });
+});
+
+describe('trelloFileHeaders', () => {
+ it('gives the key and token to Trello hosts over https only', () => {
+ expect(trelloFileHeaders(UPLOAD, CREDENTIAL)).toEqual(AUTH);
+ expect(trelloFileHeaders('https://api.trello.com/1/x', CREDENTIAL)).toEqual(AUTH);
+ expect(trelloFileHeaders(SIGNED, CREDENTIAL)).toBeUndefined();
+ expect(trelloFileHeaders('https://trello.com.evil.test/x', CREDENTIAL)).toBeUndefined();
+ expect(trelloFileHeaders('http://trello.com/x', CREDENTIAL)).toBeUndefined();
+ });
+
+ it('quotes the key and token in the OAuth header', () => {
+ expect(trelloAuthorization(CREDENTIAL)).toBe(AUTH.Authorization);
+ });
+});
diff --git a/apps/worker/src/__tests__/unit/trello-mapping.test.ts b/apps/worker/src/__tests__/unit/trello-mapping.test.ts
new file mode 100644
index 00000000..0353235e
--- /dev/null
+++ b/apps/worker/src/__tests__/unit/trello-mapping.test.ts
@@ -0,0 +1,390 @@
+import { describe, it, expect } from 'bun:test';
+import {
+ mapTrelloCard,
+ mapTrelloChecklists,
+ mapTrelloComments,
+ mapTrelloCustomFields,
+ mapTrelloCustomFieldValues,
+ mapTrelloLabels,
+ mapTrelloStates,
+ trelloCardShortLink,
+ trelloCardsToImport,
+ trelloCreatedAt,
+ trelloListCategory,
+ trelloUploads,
+ type TrelloCard,
+ type TrelloCustomFieldDef,
+ type TrelloList,
+ type TrelloScope,
+} from '../../trello-mapping';
+
+// 0x65000000 seconds since the epoch.
+const CARD_ID = '65000000aaaaaaaaaaaaaaaa';
+
+const LISTS: TrelloList[] = [
+ { id: 'list-done', name: 'Done', closed: false, pos: 3 },
+ { id: 'list-todo', name: 'To Do', closed: false, pos: 1 },
+ { id: 'list-old', name: 'Old', closed: true, pos: 2 },
+];
+
+const SCOPE: TrelloScope = {
+ boardId: 'board-1',
+ archivedCards: 'archive',
+ memberEmails: { 'member-ada': '[email protected]', 'member-bob': '[email protected]' },
+};
+
+const FIELD_DEFS: TrelloCustomFieldDef[] = [
+ { id: 'f-text', name: 'Notes', type: 'text' },
+ { id: 'f-num', name: 'Points', type: 'number' },
+ { id: 'f-check', name: 'Approved', type: 'checkbox' },
+ { id: 'f-date', name: 'Launch', type: 'date' },
+ {
+ id: 'f-list',
+ name: 'Size',
+ type: 'list',
+ options: [
+ { id: 'opt-l', value: { text: 'L' }, pos: 2 },
+ { id: 'opt-s', value: { text: 'S' }, pos: 1 },
+ ],
+ },
+];
+
+function card(overrides: Partial<TrelloCard> = {}): TrelloCard {
+ return {
+ id: CARD_ID,
+ idShort: 12,
+ name: 'Ship the importer',
+ desc: 'Body text.',
+ closed: false,
+ idList: 'list-todo',
+ pos: 100,
+ idLabels: ['label-1'],
+ idMembers: [],
+ start: null,
+ due: null,
+ dateLastActivity: '2026-02-03T04:05:06.000Z',
+ shortUrl: 'https://trello.com/c/AbCd1234',
+ attachments: [],
+ checklists: [],
+ customFieldItems: [],
+ ...overrides,
+ };
+}
+
+describe('trelloListCategory', () => {
+ it.each([
+ ['Done', 'completed'],
+ ['Completed this week', 'completed'],
+ ['Doing', 'started'],
+ ['In Progress', 'started'],
+ ['Code review', 'started'],
+ ['Backlog', 'backlog'],
+ ['Ideas', 'backlog'],
+ ['To Do', 'unstarted'],
+ ['Week 12', 'unstarted'],
+ ])('maps "%s" to %s', (name, category) => {
+ expect(trelloListCategory(name)).toBe(category as never);
+ });
+});
+
+describe('mapTrelloStates', () => {
+ it('keeps the open lists only, in board order', () => {
+ expect(mapTrelloStates(LISTS)).toEqual([
+ { sourceId: 'list-todo', name: 'To Do', category: 'unstarted' },
+ { sourceId: 'list-done', name: 'Done', category: 'completed' },
+ ]);
+ });
+});
+
+describe('mapTrelloLabels', () => {
+ it('stores Trello color names as hex and names a nameless label after its color', () => {
+ expect(
+ mapTrelloLabels([
+ { id: 'l1', name: 'Bug', color: 'red' },
+ { id: 'l2', name: '', color: 'green_dark' },
+ { id: 'l3', name: ' ', color: null },
+ ]),
+ ).toEqual([
+ { sourceId: 'l1', name: 'Bug', color: '#eb5a46' },
+ { sourceId: 'l2', name: 'Green', color: '#61bd4f' },
+ { sourceId: 'l3', name: 'Label', color: undefined },
+ ]);
+ });
+});
+
+describe('mapTrelloCustomFields', () => {
+ it('maps each Trello type, a dropdown with its options in order, and drops unknown types', () => {
+ expect(
+ mapTrelloCustomFields([...FIELD_DEFS, { id: 'f-other', name: 'Other', type: 'rating' }]),
+ ).toEqual([
+ { sourceId: 'f-text', name: 'Notes', fieldType: 'text', options: [] },
+ { sourceId: 'f-num', name: 'Points', fieldType: 'number', options: [] },
+ { sourceId: 'f-check', name: 'Approved', fieldType: 'boolean', options: [] },
+ { sourceId: 'f-date', name: 'Launch', fieldType: 'datetime', options: [] },
+ { sourceId: 'f-list', name: 'Size', fieldType: 'select', options: ['S', 'L'] },
+ ]);
+ });
+});
+
+describe('mapTrelloCustomFieldValues', () => {
+ it('reads each value from its own Trello property and names a dropdown value by its text', () => {
+ expect(
+ mapTrelloCustomFieldValues(
+ [
+ { idCustomField: 'f-text', value: { text: 'hello' } },
+ { idCustomField: 'f-num', value: { number: '3.5' } },
+ { idCustomField: 'f-check', value: { checked: 'true' } },
+ { idCustomField: 'f-date', value: { date: '2026-03-01T10:00:00.000Z' } },
+ { idCustomField: 'f-list', idValue: 'opt-l' },
+ { idCustomField: 'f-unknown', value: { text: 'lost' } },
+ { idCustomField: 'f-num', value: { number: 'n/a' } },
+ ],
+ FIELD_DEFS,
+ ),
+ ).toEqual([
+ { fieldSourceId: 'f-text', value: 'hello' },
+ { fieldSourceId: 'f-num', value: 3.5 },
+ { fieldSourceId: 'f-check', value: true },
+ { fieldSourceId: 'f-date', value: '2026-03-01T10:00:00.000Z' },
+ { fieldSourceId: 'f-list', value: 'L' },
+ ]);
+ });
+});
+
+describe('trelloCreatedAt', () => {
+ it('reads the creation time from the id', () => {
+ expect(trelloCreatedAt(CARD_ID)).toBe(new Date(0x65000000 * 1000).toISOString());
+ });
+});
+
+describe('mapTrelloCard', () => {
+ it('maps every field the import keeps', () => {
+ const issue = mapTrelloCard(
+ card({
+ idMembers: ['member-unmatched', 'member-bob', 'member-ada'],
+ start: '2026-02-01T09:00:00.000Z',
+ due: '2026-02-10T17:00:00.000Z',
+ customFieldItems: [{ idCustomField: 'f-text', value: { text: 'hello' } }],
+ }),
+ SCOPE,
+ LISTS,
+ FIELD_DEFS,
+ );
+ expect(issue).toEqual({
+ sourceId: CARD_ID,
+ sequenceId: 12,
+ title: 'Ship the importer',
+ descriptionMarkdown: 'Body text.\n\nImported from Trello: https://trello.com/c/AbCd1234',
+ stateSourceId: 'list-todo',
+ assigneeEmail: '[email protected]',
+ watcherEmails: ['[email protected]'],
+ labelSourceIds: ['label-1'],
+ cycleSourceId: null,
+ parentSourceId: null,
+ priority: null,
+ startDate: '2026-02-01',
+ dueDate: '2026-02-10',
+ customFields: [{ fieldSourceId: 'f-text', value: 'hello' }],
+ createdAt: trelloCreatedAt(CARD_ID),
+ updatedAt: '2026-02-03T04:05:06.000Z',
+ archivedAt: null,
+ });
+ });
+
+ it('archives a card that is archived itself or sits in an archived list', () => {
+ expect(mapTrelloCard(card({ closed: true }), SCOPE, LISTS, []).archivedAt).toBe(
+ '2026-02-03T04:05:06.000Z',
+ );
+ expect(mapTrelloCard(card({ idList: 'list-old' }), SCOPE, LISTS, []).archivedAt).toBe(
+ '2026-02-03T04:05:06.000Z',
+ );
+ });
+
+ it('assigns nobody when no member was matched', () => {
+ const issue = mapTrelloCard(
+ card({ idMembers: ['member-ada'] }),
+ { ...SCOPE, memberEmails: {} },
+ LISTS,
+ [],
+ );
+ expect(issue.assigneeEmail).toBeNull();
+ expect(issue.watcherEmails).toEqual([]);
+ });
+
+ it('lists link attachments under Links and leaves uploaded files out of it', () => {
+ const issue = mapTrelloCard(
+ card({
+ desc: '',
+ attachments: [
+ {
+ id: 'a1',
+ name: 'Spec [v2]',
+ url: 'https://docs.example.test/spec',
+ isUpload: false,
+ bytes: null,
+ mimeType: null,
+ },
+ {
+ id: 'a2',
+ name: 'shot.png',
+ url: 'https://trello.com/1/cards/c/attachments/a2/download/shot.png',
+ isUpload: true,
+ bytes: 10,
+ mimeType: 'image/png',
+ },
+ ],
+ }),
+ SCOPE,
+ LISTS,
+ [],
+ );
+ expect(issue.descriptionMarkdown).toBe(
+ '## Links\n\n- [Spec \\[v2\\]](https://docs.example.test/spec)\n\n' +
+ 'Imported from Trello: https://trello.com/c/AbCd1234',
+ );
+ });
+});
+
+describe('trelloCardsToImport', () => {
+ const cards = [
+ card({ id: 'done-1', idList: 'list-done', pos: 1 }),
+ card({ id: 'todo-2', idList: 'list-todo', pos: 2 }),
+ card({ id: 'old-1', idList: 'list-old', pos: 1 }),
+ card({ id: 'todo-1', idList: 'list-todo', pos: 1 }),
+ card({ id: 'todo-archived', idList: 'list-todo', pos: 3, closed: true }),
+ ];
+
+ it('puts the cards in board order and keeps archived ones when they are imported', () => {
+ expect(trelloCardsToImport(cards, LISTS, 'archive').map((c) => c.id)).toEqual([
+ 'todo-1',
+ 'todo-2',
+ 'todo-archived',
+ 'old-1',
+ 'done-1',
+ ]);
+ });
+
+ it('leaves out archived cards and the cards of archived lists when they are skipped', () => {
+ expect(trelloCardsToImport(cards, LISTS, 'skip').map((c) => c.id)).toEqual([
+ 'todo-1',
+ 'todo-2',
+ 'done-1',
+ ]);
+ });
+});
+
+describe('mapTrelloChecklists', () => {
+ it('keeps the order of checklists and items, and which items are done', () => {
+ expect(
+ mapTrelloChecklists([
+ {
+ id: 'cl-2',
+ name: 'Release',
+ pos: 2,
+ checkItems: [{ id: 'i1', name: 'Tag', state: 'incomplete', pos: 1 }],
+ },
+ {
+ id: 'cl-1',
+ name: 'Checklist',
+ pos: 1,
+ checkItems: [
+ { id: 'i3', name: 'Second', state: 'incomplete', pos: 2 },
+ { id: 'i2', name: 'First', state: 'complete', pos: 1 },
+ ],
+ },
+ ]),
+ ).toEqual([
+ {
+ sourceId: 'cl-1',
+ title: 'Checklist',
+ items: [
+ { content: 'First', done: true },
+ { content: 'Second', done: false },
+ ],
+ },
+ { sourceId: 'cl-2', title: 'Release', items: [{ content: 'Tag', done: false }] },
+ ]);
+ });
+});
+
+describe('mapTrelloComments', () => {
+ it('sorts oldest first and gives a matched author their project email', () => {
+ const comments = mapTrelloComments(
+ [
+ {
+ id: 'c2',
+ date: '2026-02-02T00:00:00.000Z',
+ idMemberCreator: 'member-unmatched',
+ data: { text: 'Second' },
+ memberCreator: { fullName: '', username: 'carol' },
+ },
+ {
+ id: 'c1',
+ date: '2026-02-01T00:00:00.000Z',
+ idMemberCreator: 'member-ada',
+ data: { text: 'First' },
+ memberCreator: { fullName: 'Ada Lovelace', username: 'ada' },
+ },
+ ],
+ SCOPE.memberEmails,
+ );
+ expect(comments).toEqual([
+ {
+ sourceId: 'c1',
+ authorEmail: '[email protected]',
+ authorName: 'Ada Lovelace',
+ bodyMarkdown: 'First',
+ createdAt: '2026-02-01T00:00:00.000Z',
+ replyToSourceId: null,
+ },
+ {
+ sourceId: 'c2',
+ authorEmail: null,
+ authorName: 'carol',
+ bodyMarkdown: 'Second',
+ createdAt: '2026-02-02T00:00:00.000Z',
+ replyToSourceId: null,
+ },
+ ]);
+ });
+});
+
+describe('trelloUploads', () => {
+ it('lists uploaded files only, with distinct names and a type from the name when Trello has none', () => {
+ const upload = (id: string, name: string, mimeType: string | null) => ({
+ id,
+ name,
+ url: `https://trello.com/1/cards/c/attachments/${id}/download/${name}`,
+ isUpload: true,
+ bytes: 2048,
+ mimeType,
+ });
+ expect(
+ trelloUploads(
+ card({
+ attachments: [
+ upload('a1', 'image.png', 'image/png'),
+ upload('a2', 'image.png', ''),
+ { ...upload('a3', 'link', null), isUpload: false },
+ ],
+ }),
+ ),
+ ).toEqual([
+ { sourceId: 'a1', filename: 'image.png', contentType: 'image/png', sizeBytes: 2048 },
+ { sourceId: 'a2', filename: 'image (2).png', contentType: 'image/png', sizeBytes: 2048 },
+ ]);
+ });
+});
+
+describe('trelloCardShortLink', () => {
+ it.each([
+ ['https://trello.com/c/AbCd1234', 'AbCd1234'],
+ ['https://trello.com/c/AbCd1234/12-some-title', 'AbCd1234'],
+ ['https://trello.com/c/AbCd1234?filter=x', 'AbCd1234'],
+ ['https://trello.com/b/AbCd1234/board', null],
+ ['https://trello.com.evil.test/c/AbCd1234', null],
+ ['http://trello.com/c/AbCd1234', null],
+ ])('reads %s as %s', (url, shortLink) => {
+ expect(trelloCardShortLink(url)).toBe(shortLink);
+ });
+});
diff --git a/apps/worker/src/attachment-download.ts b/apps/worker/src/attachment-download.ts
index 9f3a471e..9e63c2c7 100644
--- a/apps/worker/src/attachment-download.ts
+++ b/apps/worker/src/attachment-download.ts
@@ -1,5 +1,5 @@
import { pinnedFetch, ResponseTooLargeError } from '@repo/net';
-import type { AttachmentDownload } from './reader';
+import { SourceRateLimitedError, type AttachmentDownload } from './reader';
// An attachment that cannot be stored: over this instance's size, type or quota
// limits, or a download that did not return the file. The Attachments phase logs
@@ -9,6 +9,8 @@ export class AttachmentRejectedError extends Error {}
export type AttachmentFetch = typeof pinnedFetch;
const DOWNLOAD_TIMEOUT_MS = 30_000;
+const HOP_TIMEOUT_MS = 15_000;
+const MAX_REDIRECTS = 3;
// A source that reports no size (Linear) is only caught by the byte limit itself.
async function fetchWithinLimit(
@@ -43,3 +45,93 @@ export async function downloadAttachment(
}
return Buffer.from(await res.arrayBuffer());
}
+
+export type DownloadHop =
+ { kind: 'download' } | { kind: 'redirect'; url: string } | { kind: 'refused' };
+
+// What one response from a source's file host means for resolveDownloadRedirects.
+export function nextDownloadHop(
+ source: string,
+ currentUrl: string,
+ status: number,
+ location: string | null,
+): DownloadHop {
+ if (status >= 200 && status < 300) return { kind: 'download' };
+ if (status < 300 || status >= 400) return { kind: 'refused' };
+ if (!location) throw new AttachmentRejectedError(`${source} file storage redirected nowhere`);
+ const next = new URL(location, currentUrl);
+ if (next.protocol !== 'https:') {
+ throw new AttachmentRejectedError(`${source} file storage redirected to a non-https URL`);
+ }
+ return { kind: 'redirect', url: next.toString() };
+}
+
+export interface DownloadRedirectOptions {
+ // Names the source in the reasons a file is skipped.
+ source: string;
+ // The source's credential for a hop to its own file host, undefined for any other host.
+ headersFor: (url: string) => Record<string, string> | undefined;
+ rateLimitWaitMs: number;
+}
+
+// For a file host that needs the source's credential and may redirect to signed
+// storage. pinnedFetch follows no redirect, so each hop is taken here, reading only
+// the response head, and the credential goes only where headersFor gives it.
+export async function resolveDownloadRedirects(
+ url: string,
+ options: DownloadRedirectOptions,
+ fetch: AttachmentFetch = pinnedFetch,
+): Promise<AttachmentDownload> {
+ let current = url;
+ for (let hop = 0; hop <= MAX_REDIRECTS; hop++) {
+ const headers = options.headersFor(current);
+ const res = await fetch(current, {
+ headers,
+ timeoutMs: HOP_TIMEOUT_MS,
+ maxBytes: 0,
+ truncateBody: true,
+ });
+ if (res.status === 429) {
+ throw new SourceRateLimitedError(
+ options.rateLimitWaitMs,
+ `${options.source} rate limit reached`,
+ );
+ }
+ const next = nextDownloadHop(options.source, current, res.status, res.headers.get('location'));
+ if (next.kind === 'download') return headers ? { url: current, headers } : { url: current };
+ if (next.kind === 'refused') {
+ throw new AttachmentRejectedError(
+ `${options.source} file storage answered HTTP ${res.status}`,
+ );
+ }
+ current = next.url;
+ }
+ throw new AttachmentRejectedError(
+ `${options.source} file storage redirected more than ${MAX_REDIRECTS} times`,
+ );
+}
+
+export function contentTypeForFilename(filename: string): string {
+ return Bun.file(filename).type.split(';')[0]!;
+}
+
+// The Attachments phase reuses a file already on the issue under the same name, so
+// three screenshots named "image.png" would otherwise become one.
+export function uniqueFilenames(names: string[]): string[] {
+ const seen = new Map<string, number>();
+ return names.map((name) => {
+ const key = name.toLowerCase();
+ const count = (seen.get(key) ?? 0) + 1;
+ seen.set(key, count);
+ if (count === 1) return name;
+ const dot = name.lastIndexOf('.');
+ let n = count;
+ let candidate = '';
+ do {
+ candidate = dot > 0 ? `${name.slice(0, dot)} (${n})${name.slice(dot)}` : `${name} (${n})`;
+ n++;
+ } while (seen.has(candidate.toLowerCase()));
+ seen.set(candidate.toLowerCase(), 1);
+ return candidate;
+ });
+}
diff --git a/apps/worker/src/canonical.ts b/apps/worker/src/canonical.ts
index 59c96e95..0e23b7b0 100644
--- a/apps/worker/src/canonical.ts
+++ b/apps/worker/src/canonical.ts
@@ -28,11 +28,29 @@ export interface CanonicalCycle {
goal?: string;
}
+// itsaplan's own custom_field.field_type values that an import creates.
+export type CanonicalCustomFieldType = 'text' | 'number' | 'boolean' | 'datetime' | 'select';
+
+export interface CanonicalCustomField {
+ sourceId: string;
+ name: string;
+ fieldType: CanonicalCustomFieldType;
+ // The option values of a 'select' field, in the source's order.
+ options: string[];
+}
+
+// A 'select' value is the option's text; a 'datetime' value is an ISO timestamp.
export interface CanonicalCustomFieldValue {
fieldSourceId: string;
value: string | number | boolean | null;
}
+export interface CanonicalChecklist {
+ sourceId: string;
+ title: string;
+ items: { content: string; done: boolean }[];
+}
+
// No URL field: an attachment's download URL is a presigned link that expires
// (see docs/dev/plane-import-source-notes.md), so it must never be resolved
// ahead of the phase that actually downloads the bytes. sourceId is what a later
@@ -74,6 +92,7 @@ export interface CanonicalIssue {
descriptionMarkdown: string;
stateSourceId: string;
assigneeEmail: string | null;
+ watcherEmails: string[];
labelSourceIds: string[];
cycleSourceId: string | null;
parentSourceId: string | null;
@@ -83,4 +102,6 @@ export interface CanonicalIssue {
customFields: CanonicalCustomFieldValue[];
createdAt: string;
updatedAt: string;
+ // Set when the source has the issue archived; the issue is created archived.
+ archivedAt: string | null;
}
diff --git a/apps/worker/src/import-sources.ts b/apps/worker/src/import-sources.ts
index 07156928..70f1fffe 100644
--- a/apps/worker/src/import-sources.ts
+++ b/apps/worker/src/import-sources.ts
@@ -1,6 +1,7 @@
import type { CanonicalStateCategory } from './canonical';
import { LinearReader, type LinearCredential } from './linear-adapter';
import { PlaneReader, type PlaneCredential } from './plane-adapter';
+import { TrelloReader, type TrelloCredential } from './trello-adapter';
import { UnsupportedImportSourceError, type SourceReader } from './reader';
// The import_job.config fields every source shares; the phases read them directly.
@@ -24,63 +25,90 @@ export interface LinearImportConfig extends CommonImportConfig {
projectId: string | null;
}
-// One entry per import_job.source. A new source adds a member to both maps and an
-// entry to IMPORT_SOURCES.
-export interface ImportCredentials {
- plane: PlaneCredential;
- linear: LinearCredential;
+export interface TrelloImportConfig extends CommonImportConfig {
+ boardId: string;
+ archivedCards: 'archive' | 'skip';
+ // Trello member id -> the email of the project member the user matched it with.
+ memberEmails?: Record<string, string>;
}
-export interface ImportConfigs {
- plane: PlaneImportConfig;
- linear: LinearImportConfig;
+export interface ImportSourceDefinition<Credential, Config> {
+ buildReader(credential: Credential, config: Partial<Config>, jobId: number): SourceReader;
+ // The prefix of the source's own issue identifiers ("ROOMS" in "ROOMS-524").
+ projectKey(config: Partial<Config>): string | null;
}
-export type ImportSourceKind = keyof ImportConfigs;
-export type ImportCredential = ImportCredentials[ImportSourceKind];
-export type ImportConfig = ImportConfigs[ImportSourceKind];
+type StoredSourceDefinition = ImportSourceDefinition<unknown, unknown>;
-interface ImportSourceDefinition<S extends ImportSourceKind> {
- buildReader(
- credential: ImportCredentials[S],
- config: Partial<ImportConfigs[S]>,
- jobId: number,
- ): SourceReader;
- // The prefix of the source's own issue identifiers ("ROOMS" in "ROOMS-524").
- projectKey(config: Partial<ImportConfigs[S]>): string | null;
+// One entry per import_job.source. A build adds its own sources before the worker starts.
+const IMPORT_SOURCES = new Map<string, StoredSourceDefinition>();
+
+export function registerImportSource<Credential, Config>(
+ source: string,
+ definition: ImportSourceDefinition<Credential, Config>,
+): void {
+ if (IMPORT_SOURCES.has(source)) {
+ throw new Error(`import source "${source}" is already registered`);
+ }
+ IMPORT_SOURCES.set(source, definition as unknown as StoredSourceDefinition);
}
-const IMPORT_SOURCES: { [S in ImportSourceKind]: ImportSourceDefinition<S> } = {
- plane: {
- buildReader(credential, config, jobId) {
- if (!config.planeProjectId) {
- throw new Error(`import job ${jobId} has no source project configured`);
- }
- return new PlaneReader(credential, config.planeProjectId);
- },
- projectKey: (config) => config.planeProjectKey ?? null,
+registerImportSource<PlaneCredential, PlaneImportConfig>('plane', {
+ buildReader(credential, config, jobId) {
+ if (!config.planeProjectId) {
+ throw new Error(`import job ${jobId} has no source project configured`);
+ }
+ return new PlaneReader(credential, config.planeProjectId);
+ },
+ projectKey: (config) => config.planeProjectKey ?? null,
+});
+
+registerImportSource<LinearCredential, LinearImportConfig>('linear', {
+ buildReader(credential, config, jobId) {
+ // The registry types do not tie a decrypted credential to its job's source.
+ // Exactly { apiKey }: a Plane credential also has an apiKey, plus baseUrl and workspaceSlug.
+ const keys = credential && typeof credential === 'object' ? Object.keys(credential) : [];
+ if (keys.length !== 1 || typeof credential.apiKey !== 'string' || credential.apiKey === '') {
+ throw new Error(`import job ${jobId} has a credential that is not a Linear API key`);
+ }
+ const { teamId, projectFilter, projectId } = config;
+ if (!teamId || !(projectFilter === 'none' || (projectFilter === 'project' && projectId))) {
+ throw new Error(`import job ${jobId} has no source project configured`);
+ }
+ return new LinearReader(credential, {
+ teamId,
+ projectFilter,
+ projectId: projectFilter === 'project' ? (projectId ?? null) : null,
+ });
},
- linear: {
- buildReader(credential, config, jobId) {
- // The registry types do not tie a decrypted credential to its job's source.
- // Exactly { apiKey }: a Plane credential also has an apiKey, plus baseUrl and workspaceSlug.
- const keys = credential && typeof credential === 'object' ? Object.keys(credential) : [];
- if (keys.length !== 1 || typeof credential.apiKey !== 'string' || credential.apiKey === '') {
- throw new Error(`import job ${jobId} has a credential that is not a Linear API key`);
- }
- const { teamId, projectFilter, projectId } = config;
- if (!teamId || !(projectFilter === 'none' || (projectFilter === 'project' && projectId))) {
- throw new Error(`import job ${jobId} has no source project configured`);
- }
- return new LinearReader(credential, {
- teamId,
- projectFilter,
- projectId: projectFilter === 'project' ? (projectId ?? null) : null,
- });
- },
- projectKey: (config) => config.teamKey ?? null,
+ projectKey: (config) => config.teamKey ?? null,
+});
+
+registerImportSource<TrelloCredential, TrelloImportConfig>('trello', {
+ buildReader(credential, config, jobId) {
+ const keys = credential && typeof credential === 'object' ? Object.keys(credential) : [];
+ const isTrello =
+ keys.length === 2 &&
+ typeof credential.apiKey === 'string' &&
+ credential.apiKey !== '' &&
+ typeof credential.token === 'string' &&
+ credential.token !== '';
+ if (!isTrello) {
+ throw new Error(`import job ${jobId} has a credential that is not a Trello key and token`);
+ }
+ const { boardId, archivedCards } = config;
+ if (!boardId || (archivedCards !== 'archive' && archivedCards !== 'skip')) {
+ throw new Error(`import job ${jobId} has no source board configured`);
+ }
+ return new TrelloReader(credential, {
+ boardId,
+ archivedCards,
+ memberEmails: config.memberEmails ?? {},
+ });
},
-};
+ // A Trello card has no key-style identifier; another card is referred to by its URL.
+ projectKey: () => null,
+});
export interface ImportJobSource {
id: number;
@@ -88,25 +116,16 @@ export interface ImportJobSource {
config: Record<string, unknown>;
}
-function sourceOf(job: ImportJobSource): ImportSourceKind {
- if (!Object.hasOwn(IMPORT_SOURCES, job.source)) {
- throw new UnsupportedImportSourceError(job.id, job.source);
- }
- return job.source as ImportSourceKind;
-}
-
-function definitionOf<S extends ImportSourceKind>(source: S): ImportSourceDefinition<S> {
- return IMPORT_SOURCES[source];
+function definitionOf(job: ImportJobSource): StoredSourceDefinition {
+ const definition = IMPORT_SOURCES.get(job.source);
+ if (!definition) throw new UnsupportedImportSourceError(job.id, job.source);
+ return definition;
}
-export function readerForJob(job: ImportJobSource, credential: ImportCredential): SourceReader {
- return definitionOf(sourceOf(job)).buildReader(
- credential,
- job.config as Partial<ImportConfig>,
- job.id,
- );
+export function readerForJob(job: ImportJobSource, credential: unknown): SourceReader {
+ return definitionOf(job).buildReader(credential, job.config, job.id);
}
export function sourceProjectKeyForJob(job: ImportJobSource): string | null {
- return definitionOf(sourceOf(job)).projectKey(job.config as Partial<ImportConfig>);
+ return definitionOf(job).projectKey(job.config);
}
diff --git a/apps/worker/src/import-store.ts b/apps/worker/src/import-store.ts
index 5f349667..38bd5e9a 100644
--- a/apps/worker/src/import-store.ts
+++ b/apps/worker/src/import-store.ts
@@ -9,6 +9,13 @@ import {
issueActivity,
issueLink,
issueAttachment,
+ issueWatcher,
+ issueChecklist,
+ issueChecklistItem,
+ customField,
+ customFieldOption,
+ issueFieldValue,
+ issueFieldOption,
user,
projectMember,
importJob,
@@ -18,7 +25,6 @@ import {
MB,
projectStoredBytes,
lockAttachmentStorage,
- type ImportSource,
} from '@repo/db';
import { and, eq, gt, isNull, isNotNull, sql, type Column } from 'drizzle-orm';
import { decryptSecret, type EncryptedSecret } from '@repo/crypto';
@@ -28,8 +34,13 @@ import {
safeAttachmentFilename,
attachmentObjectKey,
} from '@repo/storage';
-import type { CanonicalState, CanonicalLabel, CanonicalCycle } from './canonical';
-import type { ImportCredential } from './import-sources';
+import type {
+ CanonicalState,
+ CanonicalLabel,
+ CanonicalCycle,
+ CanonicalCustomField,
+ CanonicalChecklist,
+} from './canonical';
import { AttachmentRejectedError } from './attachment-download';
export { AttachmentRejectedError };
@@ -48,7 +59,7 @@ const LEASE_SECONDS = 120;
export interface ClaimedImportJob {
id: number;
projectId: number;
- source: ImportSource;
+ source: string;
phase: string;
status: string;
config: Record<string, unknown>;
@@ -101,7 +112,7 @@ export async function claimDueImportJobs(limit = 1): Promise<ClaimedImportJob[]>
return rows as unknown as ClaimedImportJob[];
}
-export function decryptImportCredential(job: ClaimedImportJob): ImportCredential {
+export function decryptImportCredential(job: ClaimedImportJob): unknown {
if (!job.credentialCiphertext || !job.credentialIv || !job.credentialAuthTag) {
throw new Error(`import job ${job.id} has no stored credential`);
}
@@ -110,7 +121,7 @@ export function decryptImportCredential(job: ClaimedImportJob): ImportCredential
iv: job.credentialIv,
authTag: job.credentialAuthTag,
};
- return JSON.parse(decryptSecret(encrypted)) as ImportCredential;
+ return JSON.parse(decryptSecret(encrypted));
}
// A successful tick clears the claim lease (nextAttemptAt) and lastError, and
@@ -197,7 +208,8 @@ export async function retryImportJobLater(
.where(eq(importJob.id, jobId));
}
-export type ImportEntityType = 'issue' | 'comment' | 'label' | 'state' | 'cycle' | 'attachment';
+export type ImportEntityType =
+ 'issue' | 'comment' | 'label' | 'state' | 'cycle' | 'attachment' | 'checklist' | 'custom_field';
// Bulk id-only snapshot write for the Discover phase: rows start with no local
// mapping. Idempotent — a source id already recorded (from an earlier attempt
@@ -560,6 +572,7 @@ export interface NewLocalIssue {
// The source's own ISO timestamps. Absent or unparseable leaves the column default, now().
createdAt?: string;
updatedAt?: string;
+ archivedAt?: string | null;
}
function sourceTimestamp(value: string | undefined): Date | undefined {
@@ -646,6 +659,7 @@ export async function createLocalIssueAndRecord(
position: Number(posRow!.pos),
createdAt: sourceTimestamp(input.createdAt),
updatedAt: sourceTimestamp(input.updatedAt),
+ archivedAt: input.archivedAt ? (sourceTimestamp(input.archivedAt) ?? new Date()) : null,
})
.returning({ id: issue.id });
await upsertImportRecordWith(tx, jobId, 'issue', sourceId, 'issue', row!.id, sourceDisplayId);
@@ -661,6 +675,186 @@ export async function setIssueLabels(issueId: number, labelIds: number[]): Promi
.onConflictDoNothing();
}
+export async function addIssueWatchers(issueId: number, userIds: string[]): Promise<void> {
+ if (userIds.length === 0) return;
+ await db
+ .insert(issueWatcher)
+ .values(userIds.map((userId) => ({ issueId, userId })))
+ .onConflictDoNothing();
+}
+
+// A project-wide field with the same name and type is reused, and a select field
+// gets the options it lacks. One with the same name and another type is not: the
+// imported values would land in columns that field never reads.
+export async function createLocalCustomFieldAndRecord(
+ jobId: number,
+ sourceId: string,
+ projectId: number,
+ field: CanonicalCustomField,
+): Promise<number> {
+ return db.transaction(async (tx) => {
+ const [existing] = await tx
+ .select({ id: customField.id })
+ .from(customField)
+ .where(
+ and(
+ eq(customField.projectId, projectId),
+ isNull(customField.issueTypeId),
+ eq(customField.name, field.name),
+ eq(customField.fieldType, field.fieldType),
+ ),
+ )
+ .orderBy(customField.id)
+ .limit(1);
+ let fieldId = existing?.id;
+ if (fieldId == null) {
+ const [posRow] = await tx
+ .select({ pos: sql<number>`COALESCE(MAX(${customField.position}), -1) + 1` })
+ .from(customField)
+ .where(and(eq(customField.projectId, projectId), isNull(customField.issueTypeId)));
+ const [row] = await tx
+ .insert(customField)
+ .values({
+ projectId,
+ name: field.name,
+ fieldType: field.fieldType,
+ position: Number(posRow!.pos),
+ })
+ .returning({ id: customField.id });
+ fieldId = row!.id;
+ }
+ if (field.options.length > 0) {
+ const [posRow] = await tx
+ .select({ pos: sql<number>`COALESCE(MAX(${customFieldOption.position}), -1) + 1` })
+ .from(customFieldOption)
+ .where(eq(customFieldOption.fieldId, fieldId));
+ await tx
+ .insert(customFieldOption)
+ .values(
+ field.options.map((value, index) => ({
+ fieldId: fieldId!,
+ value,
+ position: Number(posRow!.pos) + index,
+ })),
+ )
+ .onConflictDoNothing();
+ }
+ await upsertImportRecordWith(tx, jobId, 'custom_field', sourceId, 'custom_field', fieldId);
+ return fieldId;
+ });
+}
+
+// Written in the column of the field's own type. A value the issue already holds is
+// kept, the way a reused issue keeps its title.
+export async function setIssueCustomFieldValue(
+ issueId: number,
+ fieldId: number,
+ value: string | number | boolean,
+): Promise<void> {
+ const [field] = await db
+ .select({ fieldType: customField.fieldType })
+ .from(customField)
+ .where(eq(customField.id, fieldId));
+ if (!field) return;
+ if (field.fieldType === 'select') {
+ const [option] = await db
+ .select({ id: customFieldOption.id })
+ .from(customFieldOption)
+ .where(
+ and(eq(customFieldOption.fieldId, fieldId), eq(customFieldOption.value, String(value))),
+ );
+ if (!option) return;
+ const [held] = await db
+ .select({ optionId: issueFieldOption.optionId })
+ .from(issueFieldOption)
+ .where(and(eq(issueFieldOption.issueId, issueId), eq(issueFieldOption.fieldId, fieldId)))
+ .limit(1);
+ if (held) return;
+ await db
+ .insert(issueFieldOption)
+ .values({ issueId, fieldId, optionId: option.id })
+ .onConflictDoNothing();
+ return;
+ }
+ let column: Partial<typeof issueFieldValue.$inferInsert>;
+ switch (field.fieldType) {
+ case 'number':
+ column = { valueNumber: String(value) };
+ break;
+ case 'boolean':
+ column = { valueBool: Boolean(value) };
+ break;
+ case 'datetime': {
+ const at = sourceTimestamp(String(value));
+ if (!at) return;
+ column = { valueDatetime: at };
+ break;
+ }
+ default:
+ column = { valueText: String(value) };
+ }
+ await db
+ .insert(issueFieldValue)
+ .values({ issueId, fieldId, ...column })
+ .onConflictDoNothing();
+}
+
+// A checklist already on the issue with the same title, and not mapped by this job,
+// is reused: a second import of the same source issue lands on the issue the first
+// one created. The checklist, its items and the mapping are written together, so a
+// retry never finds half of one.
+export async function createLocalChecklistAndRecord(
+ jobId: number,
+ issueId: number,
+ checklist: CanonicalChecklist,
+): Promise<number> {
+ return db.transaction(async (tx) => {
+ const [existing] = await tx
+ .select({ id: issueChecklist.id })
+ .from(issueChecklist)
+ .where(
+ and(
+ eq(issueChecklist.issueId, issueId),
+ eq(issueChecklist.title, checklist.title),
+ notMappedByJob(jobId, 'checklist', issueChecklist.id),
+ ),
+ )
+ .orderBy(issueChecklist.id)
+ .limit(1);
+ if (existing) {
+ await upsertImportRecordWith(
+ tx,
+ jobId,
+ 'checklist',
+ checklist.sourceId,
+ 'checklist',
+ existing.id,
+ );
+ return existing.id;
+ }
+ const [row] = await tx
+ .insert(issueChecklist)
+ .values({
+ issueId,
+ title: checklist.title,
+ position: sql<number>`(select coalesce(max(${issueChecklist.position}), 0) + 1000 from ${issueChecklist} where ${eq(issueChecklist.issueId, issueId)})`,
+ })
+ .returning({ id: issueChecklist.id });
+ if (checklist.items.length > 0) {
+ await tx.insert(issueChecklistItem).values(
+ checklist.items.map((item, index) => ({
+ checklistId: row!.id,
+ content: item.content,
+ done: item.done,
+ position: (index + 1) * 1000,
+ })),
+ );
+ }
+ await upsertImportRecordWith(tx, jobId, 'checklist', checklist.sourceId, 'checklist', row!.id);
+ return row!.id;
+ });
+}
+
// A comment already on the issue with the same body and createdAt (the two
// fields Plane's own record carries verbatim), and not already mapped by this
// job, is reused instead of duplicated — the same reuse-by-content protection
diff --git a/apps/worker/src/import-worker.ts b/apps/worker/src/import-worker.ts
index 7b49f59a..cb74474a 100644
--- a/apps/worker/src/import-worker.ts
+++ b/apps/worker/src/import-worker.ts
@@ -4,7 +4,7 @@ import { intEnv } from './env';
import { tickErrorOutcome } from './import-retry';
import { readerForJob, sourceProjectKeyForJob, type CommonImportConfig } from './import-sources';
import type { SourceReader } from './reader';
-import type { CanonicalComment } from './canonical';
+import type { CanonicalChecklist, CanonicalComment, CanonicalIssue } from './canonical';
import { extractCrossReferences, applyCrossReferenceReplacements } from './cross-reference';
import { downloadAttachment } from './attachment-download';
import {
@@ -33,6 +33,10 @@ import {
createLocalCycleAndRecord,
createLocalIssueAndRecord,
setIssueLabels,
+ addIssueWatchers,
+ createLocalCustomFieldAndRecord,
+ setIssueCustomFieldValue,
+ createLocalChecklistAndRecord,
setIssueParentIfUnset,
createLocalComment,
createIssueLink,
@@ -113,10 +117,11 @@ interface DiscoverCursor {
async function runDiscover(job: ClaimedImportJob, reader: SourceReader): Promise<void> {
const cursor = job.cursor as Partial<DiscoverCursor>;
if (cursor.subphase !== 'issues') {
- const [states, labels, cycles] = await Promise.all([
+ const [states, labels, cycles, customFields] = await Promise.all([
reader.listStates(),
reader.listLabels(),
reader.listCycles(),
+ reader.listCustomFields(),
]);
await insertDiscoveredIds(
job.id,
@@ -133,6 +138,11 @@ async function runDiscover(job: ClaimedImportJob, reader: SourceReader): Promise
'cycle',
cycles.map((c) => c.sourceId),
);
+ await insertDiscoveredIds(
+ job.id,
+ 'custom_field',
+ customFields.map((f) => f.sourceId),
+ );
const next: DiscoverCursor = { subphase: 'issues', planeCursor: null };
await saveImportJobCursor(job.id, next);
return;
@@ -152,7 +162,7 @@ async function runDiscover(job: ClaimedImportJob, reader: SourceReader): Promise
await saveImportJobCursor(job.id, next);
}
-// --- Create: materialize states/labels/cycles once (cheap, unpaginated),
+// --- Create: materialize states/labels/cycles/custom fields once (cheap, unpaginated),
// then finish one chunk of issues per tick, with their
// comments and their attachment metadata (byte download is a later phase).
@@ -164,6 +174,7 @@ export async function runCreate(job: ClaimedImportJob, reader: SourceReader): Pr
await materializeStates(job, reader);
await materializeLabels(job, reader);
await materializeCycles(job, reader);
+ await materializeCustomFields(job, reader);
const cursor = job.cursor as Partial<RecordCursor>;
const afterId = cursor.lastRecordId ?? 0;
@@ -222,6 +233,17 @@ async function materializeCycles(job: ClaimedImportJob, reader: SourceReader): P
}
}
+async function materializeCustomFields(job: ClaimedImportJob, reader: SourceReader): Promise<void> {
+ const pending = await listUncreatedImportRecords(job.id, 'custom_field', 0, 1000);
+ if (pending.length === 0) return;
+ const fields = new Map((await reader.listCustomFields()).map((f) => [f.sourceId, f]));
+ for (const record of pending) {
+ const field = fields.get(record.sourceId);
+ if (!field) continue;
+ await createLocalCustomFieldAndRecord(job.id, record.sourceId, job.projectId, field);
+ }
+}
+
async function createOneIssue(
job: ClaimedImportJob,
reader: SourceReader,
@@ -231,6 +253,7 @@ async function createOneIssue(
// Fetch source data before writing local rows; a failed read leaves no partial writes.
const comments = await reader.listIssueComments(sourceId);
const attachments = await reader.listIssueAttachments(sourceId);
+ const checklists = await reader.listIssueChecklists(sourceId);
const existing = await findImportRecord(job.id, 'issue', sourceId);
let localId = existing?.localId;
@@ -263,6 +286,7 @@ async function createOneIssue(
dueDate: canonical.dueDate,
createdAt: canonical.createdAt,
updatedAt: canonical.updatedAt,
+ archivedAt: canonical.archivedAt,
});
}
const labelIds: number[] = [];
@@ -272,6 +296,9 @@ async function createOneIssue(
}
if (labelIds.length) await setIssueLabels(localId, labelIds);
+ await addWatchers(job, localId, canonical.watcherEmails);
+ await setCustomFieldValues(job, localId, canonical.customFields);
+ await createChecklists(job, localId, checklists);
await createComments(job, localId, comments);
if (attachments.length) {
@@ -283,6 +310,44 @@ async function createOneIssue(
}
}
+async function addWatchers(
+ job: ClaimedImportJob,
+ issueLocalId: number,
+ emails: string[],
+): Promise<void> {
+ const userIds: string[] = [];
+ for (const email of emails) {
+ const userId = await findProjectMemberUserId(job.projectId, email);
+ if (userId) userIds.push(userId);
+ }
+ await addIssueWatchers(issueLocalId, userIds);
+}
+
+async function setCustomFieldValues(
+ job: ClaimedImportJob,
+ issueLocalId: number,
+ values: CanonicalIssue['customFields'],
+): Promise<void> {
+ for (const { fieldSourceId, value } of values) {
+ if (value === null || value === '') continue;
+ const record = await findImportRecord(job.id, 'custom_field', fieldSourceId);
+ if (record?.localId == null) continue;
+ await setIssueCustomFieldValue(issueLocalId, record.localId, value);
+ }
+}
+
+async function createChecklists(
+ job: ClaimedImportJob,
+ issueLocalId: number,
+ checklists: CanonicalChecklist[],
+): Promise<void> {
+ for (const checklist of checklists) {
+ if ((await findImportRecord(job.id, 'checklist', checklist.sourceId))?.localId != null)
+ continue;
+ await createLocalChecklistAndRecord(job.id, issueLocalId, checklist);
+ }
+}
+
// Comments are recorded in import_record too (entity type 'comment'), so a
// crashed-and-retried tick does not insert the same comment twice — issue_
// activity carries no unique constraint of its own to fall back on.
diff --git a/apps/worker/src/index.ts b/apps/worker/src/index.ts
index 60274c4b..dbfaa2ed 100644
--- a/apps/worker/src/index.ts
+++ b/apps/worker/src/index.ts
@@ -1,21 +1,4 @@
-import { startWorker } from './worker';
-import { startAgentWorker } from './agent-worker';
-import { startImportWorker } from './import-worker';
+import { startWorkers } from './start';
-// Entry point for webhook delivery, agent scheduling, autonomous agent runs,
-// and source imports. The api applies database migrations on startup.
-console.log('[worker] worker starting');
-const worker = startWorker();
-const agentWorker = startAgentWorker();
-const importWorker = startImportWorker();
-
-function shutdown(signal: string): void {
- console.log(`[worker] ${signal} received, stopping`);
- worker.stop();
- agentWorker.stop();
- importWorker.stop();
- process.exit(0);
-}
-
-process.on('SIGTERM', () => shutdown('SIGTERM'));
-process.on('SIGINT', () => shutdown('SIGINT'));
+// Entry point of the worker. The api applies database migrations on startup.
+startWorkers();
diff --git a/apps/worker/src/linear-adapter.ts b/apps/worker/src/linear-adapter.ts
index 7a39ae1f..a2b74fd0 100644
--- a/apps/worker/src/linear-adapter.ts
+++ b/apps/worker/src/linear-adapter.ts
@@ -1,5 +1,5 @@
import { pinnedFetch } from '@repo/net';
-import { AttachmentRejectedError } from './attachment-download';
+import { resolveDownloadRedirects } from './attachment-download';
import {
SourceRateLimitedError,
type AttachmentDownload,
@@ -8,7 +8,9 @@ import {
} from './reader';
import type {
CanonicalAttachment,
+ CanonicalChecklist,
CanonicalComment,
+ CanonicalCustomField,
CanonicalCycle,
CanonicalIssue,
CanonicalLabel,
@@ -48,7 +50,6 @@ const UPLOAD_HOST = 'uploads.linear.app';
// limit for one query.
const PAGE_SIZE = 50;
const REQUEST_TIMEOUT_MS = 15_000;
-const MAX_UPLOAD_REDIRECTS = 3;
// Linear's budgets refill over an hour, so no reset is honoured beyond that.
const MAX_RATE_LIMIT_WAIT_MS = 3_600_000;
@@ -164,25 +165,6 @@ export function linearRateLimitBackoffMs(
return Math.min(MAX_RATE_LIMIT_WAIT_MS, Math.max(1000, Math.max(...resets) - nowMs));
}
-export type UploadHop =
- { kind: 'download' } | { kind: 'redirect'; url: string } | { kind: 'refused' };
-
-// What one response from the file host means for resolveAttachmentDownload.
-export function nextUploadHop(
- currentUrl: string,
- status: number,
- location: string | null,
-): UploadHop {
- if (status >= 200 && status < 300) return { kind: 'download' };
- if (status < 300 || status >= 400) return { kind: 'refused' };
- if (!location) throw new AttachmentRejectedError('Linear file storage redirected nowhere');
- const next = new URL(location, currentUrl);
- if (next.protocol !== 'https:') {
- throw new AttachmentRejectedError('Linear file storage redirected to a non-https URL');
- }
- return { kind: 'redirect', url: next.toString() };
-}
-
// The API key goes to Linear's own file host only, never to wherever it redirects.
export function linearUploadHeaders(
url: string,
@@ -247,6 +229,10 @@ export class LinearReader implements SourceReader {
return mapLinearCycles(nodes);
}
+ async listCustomFields(): Promise<CanonicalCustomField[]> {
+ return [];
+ }
+
async listIssues(cursor: string | null): Promise<Page<CanonicalIssue>> {
const project =
this.scope.projectFilter === 'none' ? { null: true } : { id: { eq: this.scope.projectId } };
@@ -292,32 +278,23 @@ export class LinearReader implements SourceReader {
);
}
- // uploads.linear.app needs the API key; whether it serves the file or redirects
- // to signed storage, pinnedFetch follows no redirect, so each hop is taken here.
- // Every hop only reads the response head.
+ async listIssueChecklists(): Promise<CanonicalChecklist[]> {
+ return [];
+ }
+
+ // uploads.linear.app needs the API key; it serves the file or redirects to signed storage.
async resolveAttachmentDownload(
issueSourceId: string,
attachmentSourceId: string,
): Promise<AttachmentDownload> {
- let url = linearUploadUrl(issueSourceId, attachmentSourceId);
- for (let hop = 0; hop <= MAX_UPLOAD_REDIRECTS; hop++) {
- const headers = linearUploadHeaders(url, this.credential.apiKey);
- const res = await this.fetch(url, {
- headers,
- timeoutMs: REQUEST_TIMEOUT_MS,
- maxBytes: 0,
- truncateBody: true,
- });
- if (res.status === 429) throw new SourceRateLimitedError(60_000, 'Linear rate limit reached');
- const next = nextUploadHop(url, res.status, res.headers.get('location'));
- if (next.kind === 'download') return headers ? { url, headers } : { url };
- if (next.kind === 'refused') {
- throw new AttachmentRejectedError(`Linear file storage answered HTTP ${res.status}`);
- }
- url = next.url;
- }
- throw new AttachmentRejectedError(
- `Linear file storage redirected more than ${MAX_UPLOAD_REDIRECTS} times`,
+ return resolveDownloadRedirects(
+ linearUploadUrl(issueSourceId, attachmentSourceId),
+ {
+ source: 'Linear',
+ headersFor: (url) => linearUploadHeaders(url, this.credential.apiKey),
+ rateLimitWaitMs: 60_000,
+ },
+ this.fetch,
);
}
diff --git a/apps/worker/src/linear-mapping.ts b/apps/worker/src/linear-mapping.ts
index fdcd3dd1..90a70ab5 100644
--- a/apps/worker/src/linear-mapping.ts
+++ b/apps/worker/src/linear-mapping.ts
@@ -8,6 +8,7 @@ import type {
CanonicalState,
CanonicalStateCategory,
} from './canonical';
+import { contentTypeForFilename, uniqueFilenames } from './attachment-download';
// Pure mapping from Linear's GraphQL shapes (the fields linear-adapter.ts asks for)
// to the canonical import shapes. No network, no @repo/db.
@@ -236,6 +237,7 @@ export function mapLinearIssue(issue: LinearIssueNode, scope: LinearScope): Cano
descriptionMarkdown: linearIssueDescription(issue, scope),
stateSourceId: issue.state.id,
assigneeEmail: issue.assignee?.email || null,
+ watcherEmails: [],
labelSourceIds: issue.labels.nodes.map((l) => l.id),
cycleSourceId: issue.cycle?.id ?? null,
parentSourceId: issue.parent?.id ?? null,
@@ -245,6 +247,7 @@ export function mapLinearIssue(issue: LinearIssueNode, scope: LinearScope): Cano
customFields: [],
createdAt: issue.createdAt,
updatedAt: issue.updatedAt,
+ archivedAt: null,
};
}
@@ -328,35 +331,10 @@ export function linearUploadUrl(issueSourceId: string, attachmentSourceId: strin
return url;
}
-export function contentTypeForFilename(filename: string): string {
- return Bun.file(filename).type.split(';')[0]!;
-}
-
function lastPathSegment(url: string): string {
return new URL(url).pathname.split('/').filter(Boolean).pop() ?? 'file';
}
-// The Attachments phase reuses a file already on the issue under the same name, so
-// three screenshots pasted as "image.png" would otherwise become one.
-function uniqueFilenames(names: string[]): string[] {
- const seen = new Map<string, number>();
- return names.map((name) => {
- const key = name.toLowerCase();
- const count = (seen.get(key) ?? 0) + 1;
- seen.set(key, count);
- if (count === 1) return name;
- const dot = name.lastIndexOf('.');
- let n = count;
- let candidate = '';
- do {
- candidate = dot > 0 ? `${name.slice(0, dot)} (${n})${name.slice(dot)}` : `${name} (${n})`;
- n++;
- } while (seen.has(candidate.toLowerCase()));
- seen.set(candidate.toLowerCase(), 1);
- return candidate;
- });
-}
-
// Files uploaded into Linear text (description, then comments, then upload-hosted
// link attachments), first mention wins. Linear reports no size or type for them:
// the type comes from the file name and the size check waits for the real bytes.
diff --git a/apps/worker/src/plane-adapter.ts b/apps/worker/src/plane-adapter.ts
index 12e4c448..7652f529 100644
--- a/apps/worker/src/plane-adapter.ts
+++ b/apps/worker/src/plane-adapter.ts
@@ -10,6 +10,8 @@ import type {
CanonicalStateCategory,
CanonicalLabel,
CanonicalCycle,
+ CanonicalCustomField,
+ CanonicalChecklist,
CanonicalIssue,
CanonicalRelation,
CanonicalComment,
@@ -308,6 +310,14 @@ export class PlaneReader implements SourceReader {
});
}
+ async listCustomFields(): Promise<CanonicalCustomField[]> {
+ return [];
+ }
+
+ async listIssueChecklists(): Promise<CanonicalChecklist[]> {
+ return [];
+ }
+
async listIssueAttachments(issueSourceId: string): Promise<CanonicalAttachment[]> {
const rows = await this.getJson<
{ id: string; attributes: { name: string; type: string; size: number } }[]
@@ -432,6 +442,7 @@ function mapWorkItem(raw: PlaneWorkItem): CanonicalIssue {
descriptionMarkdown: htmlToMarkdown(raw.description_html),
stateSourceId: typeof raw.state === 'string' ? raw.state : (raw.state?.id ?? ''),
assigneeEmail: firstAssigneeEmail(raw.assignees),
+ watcherEmails: [],
labelSourceIds: (raw.labels ?? []).map((l) => (typeof l === 'string' ? l : l.id)),
cycleSourceId: raw.cycle_id ?? raw.cycle ?? null,
parentSourceId: raw.parent_id ?? raw.parent ?? null,
@@ -444,6 +455,7 @@ function mapWorkItem(raw: PlaneWorkItem): CanonicalIssue {
customFields: [],
createdAt: raw.created_at,
updatedAt: raw.updated_at,
+ archivedAt: null,
};
}
diff --git a/apps/worker/src/reader.ts b/apps/worker/src/reader.ts
index ca7f2908..cb86f47c 100644
--- a/apps/worker/src/reader.ts
+++ b/apps/worker/src/reader.ts
@@ -2,6 +2,8 @@ import type {
CanonicalState,
CanonicalLabel,
CanonicalCycle,
+ CanonicalCustomField,
+ CanonicalChecklist,
CanonicalIssue,
CanonicalRelation,
CanonicalComment,
@@ -45,11 +47,12 @@ export interface Page<T> {
cursor: string | null;
}
-// The port a source-specific adapter implements (plane-adapter.ts is the only
-// implementation today). Shaped from what import-worker.ts actually needs to
-// drive the Discover/Create/Link phases, not speculatively:
+// The port a source-specific adapter implements (plane-adapter.ts,
+// linear-adapter.ts, trello-adapter.ts). Shaped from what import-worker.ts
+// actually needs to drive the Discover/Create/Link phases, not speculatively:
//
-// - states/labels/cycles are small, unpaginated project-level lists.
+// - states/labels/cycles/custom fields are small, unpaginated project-level
+// lists. A source without one of them returns [].
// - listIssues walks the source's own pagination for the Discover snapshot.
// - getIssue re-fetches one issue by id: Create resumes from itsaplan's own
// import_record snapshot, not from the source's pagination position, so it
@@ -62,11 +65,13 @@ export interface SourceReader {
listStates(): Promise<CanonicalState[]>;
listLabels(): Promise<CanonicalLabel[]>;
listCycles(): Promise<CanonicalCycle[]>;
+ listCustomFields(): Promise<CanonicalCustomField[]>;
listIssues(cursor: string | null): Promise<Page<CanonicalIssue>>;
getIssue(sourceId: string): Promise<CanonicalIssue>;
listIssueRelations(issueSourceId: string): Promise<CanonicalRelation[]>;
listIssueComments(issueSourceId: string): Promise<CanonicalComment[]>;
listIssueAttachments(issueSourceId: string): Promise<CanonicalAttachment[]>;
+ listIssueChecklists(issueSourceId: string): Promise<CanonicalChecklist[]>;
// Resolves how to download one attachment, fresh each call: the source's own
// resolved URL is a presigned link that expires (Plane's lasts exactly an
// hour), so this is called at the moment of download, never cached or
diff --git a/apps/worker/src/start.ts b/apps/worker/src/start.ts
new file mode 100644
index 00000000..8703f888
--- /dev/null
+++ b/apps/worker/src/start.ts
@@ -0,0 +1,24 @@
+import { startWorker } from './worker';
+import { startAgentWorker } from './agent-worker';
+import { startImportWorker } from './import-worker';
+
+// Starts webhook delivery, agent scheduling, autonomous agent runs and source imports,
+// and stops them on SIGTERM or SIGINT. A build that registers import sources of its own
+// (registerImportSource) does it before calling this.
+export function startWorkers(): void {
+ console.log('[worker] worker starting');
+ const worker = startWorker();
+ const agentWorker = startAgentWorker();
+ const importWorker = startImportWorker();
+
+ function shutdown(signal: string): void {
+ console.log(`[worker] ${signal} received, stopping`);
+ worker.stop();
+ agentWorker.stop();
+ importWorker.stop();
+ process.exit(0);
+ }
+
+ process.on('SIGTERM', () => shutdown('SIGTERM'));
+ process.on('SIGINT', () => shutdown('SIGINT'));
+}
diff --git a/apps/worker/src/trello-adapter.ts b/apps/worker/src/trello-adapter.ts
new file mode 100644
index 00000000..5956cb5e
--- /dev/null
+++ b/apps/worker/src/trello-adapter.ts
@@ -0,0 +1,284 @@
+import { pinnedFetch } from '@repo/net';
+import { AttachmentRejectedError, resolveDownloadRedirects } from './attachment-download';
+import {
+ SourceRateLimitedError,
+ type AttachmentDownload,
+ type Page,
+ type SourceReader,
+} from './reader';
+import type {
+ CanonicalAttachment,
+ CanonicalChecklist,
+ CanonicalComment,
+ CanonicalCustomField,
+ CanonicalCycle,
+ CanonicalIssue,
+ CanonicalLabel,
+ CanonicalRelation,
+ CanonicalState,
+} from './canonical';
+import {
+ mapTrelloCard,
+ mapTrelloChecklists,
+ mapTrelloComments,
+ mapTrelloCustomFields,
+ mapTrelloLabels,
+ mapTrelloStates,
+ trelloCardShortLink,
+ trelloCardsToImport,
+ trelloUploads,
+ type TrelloCard,
+ type TrelloCommentAction,
+ type TrelloCustomFieldDef,
+ type TrelloLabel,
+ type TrelloList,
+ type TrelloScope,
+} from './trello-mapping';
+
+// The SourceReader for Trello: its REST API with the user's API key and token.
+// docs/dev/trello-import.md has the details.
+
+export interface TrelloCredential {
+ apiKey: string;
+ token: string;
+}
+
+export const TRELLO_API_URL = 'https://api.trello.com/1';
+// Trello returns at most 1000 cards or actions per request.
+const PAGE_SIZE = 1000;
+const REQUEST_TIMEOUT_MS = 15_000;
+// Trello counts a token's requests over 10 seconds.
+const RATE_LIMIT_WAIT_MS = 10_000;
+const TRELLO_HOSTS = new Set(['trello.com', 'api.trello.com']);
+
+const CARD_FIELDS =
+ 'idShort,name,desc,closed,idList,pos,idLabels,idMembers,start,due,dateLastActivity,shortUrl';
+const CARD_PARAMS = {
+ fields: CARD_FIELDS,
+ attachments: 'true',
+ attachment_fields: 'name,url,isUpload,bytes,mimeType',
+ customFieldItems: 'true',
+};
+
+export function trelloAuthorization(credential: TrelloCredential): string {
+ return `OAuth oauth_consumer_key="${credential.apiKey}", oauth_token="${credential.token}"`;
+}
+
+// The key and token go to Trello's own hosts only, never to the storage a download
+// redirects to.
+export function trelloFileHeaders(
+ url: string,
+ credential: TrelloCredential,
+): Record<string, string> | undefined {
+ const parsed = new URL(url);
+ return parsed.protocol === 'https:' && TRELLO_HOSTS.has(parsed.hostname)
+ ? { Authorization: trelloAuthorization(credential) }
+ : undefined;
+}
+
+// Trello pages by creation date: a page holds the newest cards or actions before the
+// given id, so the next page starts before the oldest of this one.
+function oldestId(items: { id: string }[]): string {
+ return items.reduce((oldest, item) => (item.id < oldest ? item.id : oldest), items[0]!.id);
+}
+
+export class TrelloReader implements SourceReader {
+ // One tick reads the board's lists and custom fields and each card once. A reader
+ // lives for one tick.
+ private listsPromise: Promise<TrelloList[]> | null = null;
+ private fieldsPromise: Promise<TrelloCustomFieldDef[]> | null = null;
+ private readonly cards = new Map<string, Promise<TrelloCard>>();
+ private readonly linkedCards = new Map<string, Promise<string | null>>();
+
+ constructor(
+ private readonly credential: TrelloCredential,
+ private readonly scope: TrelloScope,
+ private readonly fetch: typeof pinnedFetch = pinnedFetch,
+ ) {}
+
+ async listStates(): Promise<CanonicalState[]> {
+ return mapTrelloStates(await this.lists());
+ }
+
+ async listLabels(): Promise<CanonicalLabel[]> {
+ const labels = await this.get<TrelloLabel[]>(`${this.boardPath()}/labels`, {
+ fields: 'name,color',
+ limit: String(PAGE_SIZE),
+ });
+ return mapTrelloLabels(labels);
+ }
+
+ async listCycles(): Promise<CanonicalCycle[]> {
+ return [];
+ }
+
+ async listCustomFields(): Promise<CanonicalCustomField[]> {
+ return mapTrelloCustomFields(await this.fieldDefs());
+ }
+
+ // Every card in one page: board order needs all of them, and paging by creation
+ // date would scatter a list across pages.
+ async listIssues(): Promise<Page<CanonicalIssue>> {
+ const filter = this.scope.archivedCards === 'archive' ? 'all' : 'open';
+ const cards = new Map<string, TrelloCard>();
+ let before: string | null = null;
+ do {
+ const page: TrelloCard[] = await this.get<TrelloCard[]>(`${this.boardPath()}/cards`, {
+ ...CARD_PARAMS,
+ filter,
+ limit: String(PAGE_SIZE),
+ ...(before ? { before } : {}),
+ });
+ for (const card of page) cards.set(card.id, card);
+ before = page.length < PAGE_SIZE ? null : oldestId(page);
+ } while (before !== null);
+ const [lists, fieldDefs] = await Promise.all([this.lists(), this.fieldDefs()]);
+ const ordered = trelloCardsToImport([...cards.values()], lists, this.scope.archivedCards);
+ return {
+ items: ordered.map((card) => mapTrelloCard(card, this.scope, lists, fieldDefs)),
+ cursor: null,
+ };
+ }
+
+ async getIssue(sourceId: string): Promise<CanonicalIssue> {
+ const [card, lists, fieldDefs] = await Promise.all([
+ this.card(sourceId),
+ this.lists(),
+ this.fieldDefs(),
+ ]);
+ return mapTrelloCard(card, this.scope, lists, fieldDefs);
+ }
+
+ // A link attachment to another card of this board is a "relates" link.
+ async listIssueRelations(issueSourceId: string): Promise<CanonicalRelation[]> {
+ const card = await this.card(issueSourceId);
+ const shortLinks = new Set(
+ (card.attachments ?? []).flatMap((a) => {
+ const shortLink = a.isUpload ? null : trelloCardShortLink(a.url);
+ return shortLink ? [shortLink] : [];
+ }),
+ );
+ const relations: CanonicalRelation[] = [];
+ for (const shortLink of shortLinks) {
+ const target = await this.cardIdOnBoard(shortLink);
+ if (target && target !== issueSourceId) {
+ relations.push({
+ kind: 'relates',
+ sourceIssueSourceId: issueSourceId,
+ targetIssueSourceId: target,
+ });
+ }
+ }
+ return relations;
+ }
+
+ async listIssueComments(issueSourceId: string): Promise<CanonicalComment[]> {
+ const actions: TrelloCommentAction[] = [];
+ let before: string | null = null;
+ do {
+ const page: TrelloCommentAction[] = await this.get<TrelloCommentAction[]>(
+ `/cards/${encodeURIComponent(issueSourceId)}/actions`,
+ {
+ filter: 'commentCard',
+ limit: String(PAGE_SIZE),
+ memberCreator_fields: 'fullName,username',
+ ...(before ? { before } : {}),
+ },
+ );
+ actions.push(...page);
+ before = page.length < PAGE_SIZE ? null : oldestId(page);
+ } while (before !== null);
+ return mapTrelloComments(actions, this.scope.memberEmails);
+ }
+
+ async listIssueAttachments(issueSourceId: string): Promise<CanonicalAttachment[]> {
+ return trelloUploads(await this.card(issueSourceId));
+ }
+
+ async listIssueChecklists(issueSourceId: string): Promise<CanonicalChecklist[]> {
+ return mapTrelloChecklists((await this.card(issueSourceId)).checklists ?? []);
+ }
+
+ // An upload is served from trello.com with the key and token, usually as a
+ // redirect to signed storage.
+ async resolveAttachmentDownload(
+ issueSourceId: string,
+ attachmentSourceId: string,
+ ): Promise<AttachmentDownload> {
+ const card = await this.card(issueSourceId);
+ const upload = card.attachments?.find((a) => a.id === attachmentSourceId && a.isUpload);
+ if (!upload) throw new AttachmentRejectedError('the file is no longer on the Trello card');
+ return resolveDownloadRedirects(
+ upload.url,
+ {
+ source: 'Trello',
+ headersFor: (url) => trelloFileHeaders(url, this.credential),
+ rateLimitWaitMs: RATE_LIMIT_WAIT_MS,
+ },
+ this.fetch,
+ );
+ }
+
+ private boardPath(): string {
+ return `/boards/${encodeURIComponent(this.scope.boardId)}`;
+ }
+
+ private lists(): Promise<TrelloList[]> {
+ this.listsPromise ??= this.get<TrelloList[]>(`${this.boardPath()}/lists`, {
+ filter: 'all',
+ fields: 'name,closed,pos',
+ });
+ return this.listsPromise;
+ }
+
+ private fieldDefs(): Promise<TrelloCustomFieldDef[]> {
+ this.fieldsPromise ??= this.get<TrelloCustomFieldDef[]>(`${this.boardPath()}/customFields`);
+ return this.fieldsPromise;
+ }
+
+ private card(id: string): Promise<TrelloCard> {
+ let card = this.cards.get(id);
+ if (!card) {
+ card = this.get<TrelloCard>(`/cards/${encodeURIComponent(id)}`, {
+ ...CARD_PARAMS,
+ checklists: 'all',
+ });
+ this.cards.set(id, card);
+ }
+ return card;
+ }
+
+ // The id of a linked card when it is on this board. A card that was deleted, that
+ // the token cannot see, or whose short link is malformed (400) is not linked.
+ private cardIdOnBoard(shortLink: string): Promise<string | null> {
+ let id = this.linkedCards.get(shortLink);
+ if (!id) {
+ id = this.get<{ id: string; idBoard: string } | null>(
+ `/cards/${encodeURIComponent(shortLink)}`,
+ { fields: 'idBoard' },
+ [400, 401, 403, 404],
+ ).then((card) => (card?.idBoard === this.scope.boardId ? card.id : null));
+ this.linkedCards.set(shortLink, id);
+ }
+ return id;
+ }
+
+ // A status in `missing` answers null instead of failing the request.
+ private async get<T>(
+ path: string,
+ params: Record<string, string> = {},
+ missing: number[] = [],
+ ): Promise<T> {
+ const query = new URLSearchParams(params).toString();
+ const res = await this.fetch(`${TRELLO_API_URL}${path}${query ? `?${query}` : ''}`, {
+ headers: { Authorization: trelloAuthorization(this.credential) },
+ timeoutMs: REQUEST_TIMEOUT_MS,
+ });
+ if (res.status === 429) {
+ throw new SourceRateLimitedError(RATE_LIMIT_WAIT_MS, 'Trello rate limit reached');
+ }
+ if (missing.includes(res.status)) return null as T;
+ if (!res.ok) throw new Error(`Trello request failed: HTTP ${res.status}`);
+ return (await res.json()) as T;
+ }
+}
diff --git a/apps/worker/src/trello-mapping.ts b/apps/worker/src/trello-mapping.ts
new file mode 100644
index 00000000..8849e682
--- /dev/null
+++ b/apps/worker/src/trello-mapping.ts
@@ -0,0 +1,323 @@
+import type {
+ CanonicalAttachment,
+ CanonicalChecklist,
+ CanonicalComment,
+ CanonicalCustomField,
+ CanonicalCustomFieldType,
+ CanonicalCustomFieldValue,
+ CanonicalIssue,
+ CanonicalLabel,
+ CanonicalState,
+ CanonicalStateCategory,
+} from './canonical';
+import { contentTypeForFilename, uniqueFilenames } from './attachment-download';
+
+// Pure mapping from Trello's REST shapes (the fields trello-adapter.ts asks for) to
+// the canonical import shapes. No network, no @repo/db.
+
+export interface TrelloList {
+ id: string;
+ name: string;
+ closed: boolean;
+ pos: number;
+}
+
+export interface TrelloLabel {
+ id: string;
+ name: string;
+ color: string | null;
+}
+
+export interface TrelloCustomFieldDef {
+ id: string;
+ name: string;
+ type: string;
+ options?: { id: string; value: { text: string }; pos: number }[];
+}
+
+export interface TrelloCustomFieldItem {
+ idCustomField: string;
+ idValue?: string | null;
+ value?: { text?: string; number?: string; date?: string; checked?: string } | null;
+}
+
+export interface TrelloAttachment {
+ id: string;
+ name: string;
+ url: string;
+ isUpload: boolean;
+ bytes: number | null;
+ mimeType: string | null;
+}
+
+export interface TrelloChecklist {
+ id: string;
+ name: string;
+ pos: number;
+ checkItems: { id: string; name: string; state: string; pos: number }[];
+}
+
+export interface TrelloCard {
+ id: string;
+ idShort: number;
+ name: string;
+ desc: string;
+ closed: boolean;
+ idList: string;
+ pos: number;
+ idLabels: string[];
+ idMembers: string[];
+ start: string | null;
+ due: string | null;
+ dateLastActivity: string;
+ shortUrl: string;
+ attachments?: TrelloAttachment[];
+ checklists?: TrelloChecklist[];
+ customFieldItems?: TrelloCustomFieldItem[];
+}
+
+export interface TrelloCommentAction {
+ id: string;
+ date: string;
+ idMemberCreator: string;
+ data: { text: string };
+ memberCreator?: { fullName?: string; username?: string } | null;
+}
+
+// One import job: a board, what to do with its archived cards, and the board
+// members the user matched with project members.
+export interface TrelloScope {
+ boardId: string;
+ archivedCards: 'archive' | 'skip';
+ // Trello member id -> the email of the project member it was matched with.
+ memberEmails: Record<string, string>;
+}
+
+// A Trello list has no category of its own; the name gives a default the mapping
+// review step can change.
+export function trelloListCategory(name: string): CanonicalStateCategory {
+ if (/\b(done|completed?|finished|closed|shipped|released)\b/i.test(name)) return 'completed';
+ if (/\b(doing|in progress|wip|review|testing|qa)\b/i.test(name)) return 'started';
+ if (/\b(backlog|ideas?|icebox|someday)\b/i.test(name)) return 'backlog';
+ return 'unstarted';
+}
+
+function byPos<T extends { pos: number }>(items: T[]): T[] {
+ return [...items].sort((a, b) => a.pos - b.pos);
+}
+
+// Only open lists become columns. A card of an archived list is imported archived
+// and goes to the first column of the project.
+export function mapTrelloStates(lists: TrelloList[]): CanonicalState[] {
+ return byPos(lists.filter((l) => !l.closed)).map((l) => ({
+ sourceId: l.id,
+ name: l.name,
+ category: trelloListCategory(l.name),
+ }));
+}
+
+const LABEL_COLORS: Record<string, string> = {
+ green: '#61bd4f',
+ yellow: '#f2d600',
+ orange: '#ff9f1a',
+ red: '#eb5a46',
+ purple: '#c377e0',
+ blue: '#0079bf',
+ sky: '#00c2e0',
+ lime: '#51e898',
+ pink: '#ff78cb',
+ black: '#344563',
+};
+
+// Trello names its colors ("green", "green_dark"); itsaplan stores a hex value.
+function trelloLabelColor(color: string | null): string | undefined {
+ return color ? LABEL_COLORS[color.split('_')[0]!] : undefined;
+}
+
+// A Trello label may have no name, only a color; it is named after the color.
+export function mapTrelloLabels(labels: TrelloLabel[]): CanonicalLabel[] {
+ return labels.map((l) => {
+ const colorName = l.color?.split('_')[0];
+ const fallback = colorName ? colorName[0]!.toUpperCase() + colorName.slice(1) : 'Label';
+ return { sourceId: l.id, name: l.name.trim() || fallback, color: trelloLabelColor(l.color) };
+ });
+}
+
+const FIELD_TYPES: Record<string, CanonicalCustomFieldType> = {
+ text: 'text',
+ number: 'number',
+ checkbox: 'boolean',
+ date: 'datetime',
+ list: 'select',
+};
+
+export function mapTrelloCustomFields(defs: TrelloCustomFieldDef[]): CanonicalCustomField[] {
+ return defs.flatMap((d) => {
+ const fieldType = FIELD_TYPES[d.type];
+ if (!fieldType) return [];
+ const options =
+ fieldType === 'select' ? [...new Set(byPos(d.options ?? []).map((o) => o.value.text))] : [];
+ return [{ sourceId: d.id, name: d.name, fieldType, options }];
+ });
+}
+
+function customFieldValue(
+ def: TrelloCustomFieldDef,
+ item: TrelloCustomFieldItem,
+): string | number | boolean | null {
+ switch (def.type) {
+ case 'list':
+ return def.options?.find((o) => o.id === item.idValue)?.value.text ?? null;
+ case 'checkbox':
+ return item.value?.checked === 'true';
+ case 'number': {
+ const raw = item.value?.number;
+ return raw && Number.isFinite(Number(raw)) ? Number(raw) : null;
+ }
+ case 'date':
+ return item.value?.date ?? null;
+ default:
+ return item.value?.text ?? null;
+ }
+}
+
+export function mapTrelloCustomFieldValues(
+ items: TrelloCustomFieldItem[],
+ defs: TrelloCustomFieldDef[],
+): CanonicalCustomFieldValue[] {
+ const byId = new Map(defs.map((d) => [d.id, d]));
+ return items.flatMap((item) => {
+ const def = byId.get(item.idCustomField);
+ const value = def ? customFieldValue(def, item) : null;
+ return value === null ? [] : [{ fieldSourceId: item.idCustomField, value }];
+ });
+}
+
+// A Trello id is a MongoDB ObjectId: its first four bytes are the creation time in seconds.
+export function trelloCreatedAt(id: string): string {
+ return new Date(parseInt(id.slice(0, 8), 16) * 1000).toISOString();
+}
+
+function escapeLinkText(text: string): string {
+ return text.replace(/[\\[\]]/g, '\\$&');
+}
+
+// The description as written, then the link attachments under "Links", then the
+// card's Trello URL, last, so every imported issue can still be found by it.
+function trelloCardDescription(card: TrelloCard): string {
+ const parts: string[] = [];
+ const body = card.desc.trim();
+ if (body) parts.push(body);
+ const links = (card.attachments ?? []).filter((a) => !a.isUpload);
+ if (links.length > 0) {
+ const items = links.map((a) => `- [${escapeLinkText(a.name.trim() || a.url)}](${a.url})`);
+ parts.push(['## Links', '', ...items].join('\n'));
+ }
+ parts.push(`Imported from Trello: ${card.shortUrl}`);
+ return parts.join('\n\n');
+}
+
+function isTrelloCardArchived(card: TrelloCard, lists: TrelloList[]): boolean {
+ return card.closed || lists.some((l) => l.id === card.idList && l.closed);
+}
+
+// The first matched member is the assignee, the others watch the issue.
+export function mapTrelloCard(
+ card: TrelloCard,
+ scope: TrelloScope,
+ lists: TrelloList[],
+ fieldDefs: TrelloCustomFieldDef[],
+): CanonicalIssue {
+ const emails = [
+ ...new Set(card.idMembers.map((id) => scope.memberEmails[id]).filter((e): e is string => !!e)),
+ ];
+ return {
+ sourceId: card.id,
+ sequenceId: card.idShort,
+ title: card.name,
+ descriptionMarkdown: trelloCardDescription(card),
+ stateSourceId: card.idList,
+ assigneeEmail: emails[0] ?? null,
+ watcherEmails: emails.slice(1),
+ labelSourceIds: card.idLabels,
+ cycleSourceId: null,
+ parentSourceId: null,
+ priority: null,
+ startDate: card.start?.slice(0, 10) ?? null,
+ dueDate: card.due?.slice(0, 10) ?? null,
+ customFields: mapTrelloCustomFieldValues(card.customFieldItems ?? [], fieldDefs),
+ createdAt: trelloCreatedAt(card.id),
+ updatedAt: card.dateLastActivity,
+ archivedAt: isTrelloCardArchived(card, lists) ? card.dateLastActivity : null,
+ };
+}
+
+// The cards one job imports, in board order: list by list, each list top to bottom.
+// Create makes the issues in this order, so each column keeps Trello's order.
+export function trelloCardsToImport(
+ cards: TrelloCard[],
+ lists: TrelloList[],
+ archivedCards: TrelloScope['archivedCards'],
+): TrelloCard[] {
+ const listPos = new Map(lists.map((l) => [l.id, l.pos]));
+ return cards
+ .filter((c) => archivedCards === 'archive' || !isTrelloCardArchived(c, lists))
+ .sort(
+ (a, b) =>
+ (listPos.get(a.idList) ?? Infinity) - (listPos.get(b.idList) ?? Infinity) || a.pos - b.pos,
+ );
+}
+
+export function mapTrelloChecklists(checklists: TrelloChecklist[]): CanonicalChecklist[] {
+ return byPos(checklists).map((c) => ({
+ sourceId: c.id,
+ title: c.name,
+ items: byPos(c.checkItems).map((i) => ({ content: i.name, done: i.state === 'complete' })),
+ }));
+}
+
+// Oldest first, the order the Create phase writes comments in. Trello has no replies.
+export function mapTrelloComments(
+ actions: TrelloCommentAction[],
+ memberEmails: Record<string, string>,
+): CanonicalComment[] {
+ return [...actions]
+ .sort((a, b) => Date.parse(a.date) - Date.parse(b.date))
+ .map((a) => ({
+ sourceId: a.id,
+ authorEmail: memberEmails[a.idMemberCreator] ?? null,
+ authorName: a.memberCreator?.fullName || a.memberCreator?.username || 'Trello',
+ bodyMarkdown: a.data.text,
+ createdAt: a.date,
+ replyToSourceId: null,
+ }));
+}
+
+function lastPathSegment(url: string): string {
+ try {
+ return decodeURIComponent(new URL(url).pathname.split('/').filter(Boolean).pop() ?? 'file');
+ } catch {
+ return 'file';
+ }
+}
+
+// Files uploaded to the card. A link attachment is not a file; it is listed in the
+// description instead.
+export function trelloUploads(card: TrelloCard): CanonicalAttachment[] {
+ const uploads = (card.attachments ?? []).filter((a) => a.isUpload);
+ const names = uniqueFilenames(uploads.map((a) => a.name.trim() || lastPathSegment(a.url)));
+ return uploads.map((a, i) => ({
+ sourceId: a.id,
+ filename: names[i]!,
+ contentType: a.mimeType || contentTypeForFilename(names[i]!),
+ sizeBytes: a.bytes ?? 0,
+ }));
+}
+
+const CARD_URL = /^https:\/\/trello\.com\/c\/([A-Za-z0-9]+)(?:[/?#]|$)/;
+
+// The short link of a Trello card URL ("https://trello.com/c/AbCd1234/12-title"), the
+// form a link to another card takes as an attachment.
+export function trelloCardShortLink(url: string): string | null {
+ return CARD_URL.exec(url)?.[1] ?? null;
+}
diff --git a/docs/dev/plane-import.md b/docs/dev/plane-import.md
index 781f02e8..63118591 100644
--- a/docs/dev/plane-import.md
+++ b/docs/dev/plane-import.md
@@ -23,7 +23,8 @@ returns.
- `apps/api/src/modules/import-export/` — create/test-connection/plane-preview/export/status/
pause/resume/cancel routes, and linear-test-connection/linear-preview.
- The Linear source (`linear-adapter.ts`, `linear-mapping.ts`, the api's `linear.ts`, the
- Linear tab) has its own notes: [linear-import.md](linear-import.md).
+ Linear tab) has its own notes: [linear-import.md](linear-import.md). So does the Trello
+ source: [trello-import.md](trello-import.md).
- `apps/web/src/features/settings/components/import-export/` — the Settings page.
## Export: a JSON snapshot, not a live sync
diff --git a/docs/dev/trello-import.md b/docs/dev/trello-import.md
new file mode 100644
index 00000000..a0782d51
--- /dev/null
+++ b/docs/dev/trello-import.md
@@ -0,0 +1,137 @@
+# The Trello import source
+
+How the Trello source plugs into the import pipeline described in
+[plane-import.md](plane-import.md). The phases, resumability, de-duplication and rate-limit
+handling are the same for every source; this file covers what is specific to Trello. The user
+guide is [importing-from-trello.md](../importing-from-trello.md).
+
+## Shape
+
+- `apps/worker/src/trello-mapping.ts` — pure mapping from Trello's REST shapes to the canonical
+ ones (lists, labels, custom fields, cards, checklists, comments, uploads), unit-tested
+ directly.
+- `apps/worker/src/trello-adapter.ts` — `TrelloReader`, the `SourceReader` for Trello: the
+ requests, paging, the rate-limit check, and the upload download.
+- `apps/worker/src/import-sources.ts` — the `trello` entry: credential `{ apiKey, token }`,
+ config `{ boardId, archivedCards: 'archive' | 'skip', memberEmails? }`, and no Rewrite
+ prefix.
+- `apps/api/src/modules/import-export/trello.ts` — the key and token check (the boards they
+ see), the board preview (open lists and members), and the Trello fields of
+ `POST /import-jobs` (`source: 'trello'`).
+- `apps/web/src/features/settings/components/import-export/SettingsImportExportTrello*.tsx` —
+ the Trello tab; the mapping review is shared with Plane and Linear.
+
+## Authorization
+
+The user enters an API key of their own Power-Up, and `useTrelloAuthorize` opens Trello's
+`/1/authorize` page for it in a popup with `scope=read`, `expiration=30days`,
+`callback_method=postMessage` and `return_url` set to the web origin. Trello posts the token to
+the opener, and the hook accepts a message only from `https://trello.com` and from that popup.
+Trello sends it only when the web origin is in the key's allowed origins, so the form shows the
+origin to add. No instance setting is involved: the key and the token reach the api only with
+the test, the preview and the job, and the job stores them encrypted until it ends.
+
+## What Trello adds to the pipeline
+
+Trello is the first source with checklists and custom fields, so the pipeline has them for
+every source:
+
+- `SourceReader.listCustomFields()` is read in Discover with the states, labels and cycles.
+ Create makes each field (`createLocalCustomFieldAndRecord`) before the issues and records it
+ as `custom_field` in `import_record`. `CanonicalIssue.customFields` carries the values, which
+ Create writes with `setIssueCustomFieldValue`.
+- `SourceReader.listIssueChecklists(issue)` is read per issue in Create. Each checklist is
+ written with its items in one transaction and recorded as `checklist`.
+- `CanonicalIssue.watcherEmails` adds watchers, matched by email like the assignee.
+- `CanonicalIssue.archivedAt` creates the issue archived.
+
+Plane and Linear return no checklists, no custom fields, no watchers and no archive time.
+
+## Requests
+
+Every request goes to the fixed `https://api.trello.com/1` through `pinnedFetch`, with
+`Authorization: OAuth oauth_consumer_key="<key>", oauth_token="<token>"`. The api accepts a key,
+a token and a board id made of letters and digits only, so neither can break out of the quoted
+header or the URL path. No user-supplied URL is fetched, except the upload URL Trello gives for
+an attachment; see Uploads.
+
+| Reader method | Request |
+| ---------------------- | ----------------------------------------------------------------------------- |
+| `listStates` | `GET /boards/{id}/lists?filter=all`; the open lists become states |
+| `listLabels` | `GET /boards/{id}/labels?limit=1000` |
+| `listCustomFields` | `GET /boards/{id}/customFields` |
+| `listIssues` | `GET /boards/{id}/cards?filter=open\|all`, with attachments and field values |
+| `getIssue` | `GET /cards/{id}`, with attachments, checklists and field values |
+| `listIssueRelations` | the card, then `GET /cards/{shortLink}?fields=idBoard` per linked card |
+| `listIssueComments` | `GET /cards/{id}/actions?filter=commentCard&limit=1000` |
+| `listIssueAttachments` | the card's attachments with `isUpload` set |
+| `listIssueChecklists` | the card's checklists |
+
+Trello returns at most 1000 cards or actions in one request and pages them by creation date:
+the next page is read with `before` set to the oldest id of the page, until a page holds fewer
+than 1000. `listIssues` reads every page in one call and returns them as one page, sorted by
+list position and then card position, so Create makes the issues of each column in Trello's
+order. A reader lives for one tick and reads the lists, the custom fields and each card once.
+
+## Scope
+
+`archivedCards: 'skip'` reads `filter=open` and also drops the cards of an archived list.
+`'archive'` reads `filter=all`; a card that is archived, or that sits in an archived list, gets
+`archivedAt` set to its `dateLastActivity`. Only open lists become states, so the card of an
+archived list goes to the project's first column.
+
+## People
+
+Trello does not return a member's email, except the token owner's own with the `account`
+scope. The review step lists the board's members, and the user matches each one with a project
+member by hand or skips the matching. The api turns `memberMap` (Trello member id → user id)
+into `config.memberEmails` (Trello member id → that member's email) and refuses a user who is
+not a member of the project. The reader then sets `assigneeEmail` to the first matched member
+of a card, `watcherEmails` to the other matched members, and a comment's `authorEmail` to its
+matched author, so the worker matches people by email as it does for every source.
+
+## Rate limits
+
+Trello allows 100 requests per 10 seconds for each token and 300 for each key, and answers a
+request over the limit with HTTP 429. Any 429 becomes `SourceRateLimitedError` with a 10-second
+wait. The worker reschedules the job, and a rate limit never fails it.
+
+## Text
+
+- The description gets, in order: the card's Markdown, a `## Links` list of the link
+ attachments, and `Imported from Trello: <short URL>` last.
+- A Trello card has no key-style identifier, so the Rewrite phase does nothing for a Trello
+ job. A link to another card stays a link to Trello.
+
+## Relations
+
+A link attachment whose URL is `https://trello.com/c/<shortLink>` points to another card.
+`listIssueRelations` reads that card by its short link (Trello accepts a short link in place of
+an id) and returns a `relates` relation when it is on the same board. A card that is deleted or
+that the token cannot see, or whose short link is malformed (400, 401, 403, 404), is not
+linked.
+
+## Uploads
+
+An upload's URL is on `trello.com` and needs the key and token.
+`resolveDownloadRedirects` (`attachment-download.ts`, shared with Linear) follows the redirect
+to signed storage itself and sends the `Authorization` header only while the host is
+`trello.com` or `api.trello.com` over https. Trello reports the size and type of an upload; when
+the type is empty it comes from the file name.
+
+## Labels
+
+Trello names its label colors (`green`, `green_dark`). The color is stored as the hex value of
+its base color, and a label with no name is named after its color.
+
+## Custom fields
+
+| Trello type | itsaplan type | Value read from |
+| ----------- | ------------- | ------------------------------------------ |
+| `text` | `text` | `value.text` |
+| `number` | `number` | `value.number` |
+| `checkbox` | `boolean` | `value.checked === 'true'` |
+| `date` | `datetime` | `value.date` |
+| `list` | `select` | the text of the option `idValue` names |
+
+A field of another type is not imported.
diff --git a/docs/importing-from-linear.md b/docs/importing-from-linear.md
index 2556f0a5..7182a428 100644
--- a/docs/importing-from-linear.md
+++ b/docs/importing-from-linear.md
@@ -150,5 +150,5 @@ title stay two issues, and two comments with the same text and time stay two com
## Other sources
-[Importing from Plane](importing-from-plane.md) describes the Plane source. Jira and Trello
-are not available.
+[Importing from Plane](importing-from-plane.md) and
+[Importing from Trello](importing-from-trello.md) describe the other sources.
diff --git a/docs/importing-from-plane.md b/docs/importing-from-plane.md
index 2eec8158..ab3581ef 100644
--- a/docs/importing-from-plane.md
+++ b/docs/importing-from-plane.md
@@ -124,5 +124,5 @@ Plane, and nothing is scheduled or kept running.
## Other sources
-[Importing from Linear](importing-from-linear.md) describes the Linear source. Jira and Trello
-are not available.
+[Importing from Linear](importing-from-linear.md) and
+[Importing from Trello](importing-from-trello.md) describe the other sources.
diff --git a/docs/importing-from-trello.md b/docs/importing-from-trello.md
new file mode 100644
index 00000000..a85b66b7
--- /dev/null
+++ b/docs/importing-from-trello.md
@@ -0,0 +1,119 @@
+# Importing from Trello
+
+Project Settings → Import/Export connects a project to Trello with an API key and a token,
+imports one Trello board into the project, and shows the job's progress while it runs. This
+page describes what the import brings over, what it does not, and what to expect while it
+runs.
+
+## What you need
+
+- A Trello API key. Trello gives API keys to Power-Ups: open the
+ [Power-Up admin page](https://trello.com/power-ups/admin), create a Power-Up (any name and
+ workspace), open its **API key** tab and generate a key.
+- On the same tab, add the address of this instance (the form shows it, for example
+ `https://plan.example.com`) to **Allowed origins**. Trello sends the token only to an
+ allowed address; without it the authorization window shows an error.
+- The key and the token are stored encrypted in the import job only, because the job runs in
+ the background. They are deleted when the job finishes or is canceled.
+
+## Steps
+
+1. Open the project's **Settings → Import/Export** and choose **Trello** under Source.
+2. Enter the API key and click **Authorize in Trello**. Trello opens in a small window: allow
+ read access there. The window closes, and the boards you can see are listed, open boards
+ first. Nothing is saved at this point. The token is valid for 30 days.
+3. Pick a board. Its open lists appear for review (see below), with two more choices: what to
+ do with archived cards, and whether to match the board's members with project members.
+4. **Start import.** The job appears in the list below and runs in the background. You can
+ leave the page and come back. You can pause, resume or cancel the job from the same list.
+
+One job imports one board.
+
+## What is imported
+
+- **Cards** become issues: title, description (Trello stores Markdown, so it is kept as
+ written), list, labels, start date, due date, and the dates the card was created and last
+ changed. Each column keeps the order of its Trello list.
+- **The Trello link.** The description of every imported issue ends with a line such as
+ `Imported from Trello: https://trello.com/c/AbCd1234`, so you can still find the card.
+- **Lists** become columns, if a column with that name does not already exist. Only open lists
+ become columns.
+- **Archived cards.** You choose before the import starts: import them as archived issues, or
+ do not import them. The same choice applies to the cards of an archived list. Such a card
+ goes to the first column of the project, because its list does not become a column.
+- **Labels** — created if they do not already exist by that name, with their Trello color. A
+ label with no name is named after its color, for example `Green`. Every label of the board is
+ created, whether or not an imported card uses it.
+- **Members** — see "Matching members" below.
+- **Checklists** — with their items, the order of both, and which items are done.
+- **Custom fields** — text, number, checkbox, date and dropdown fields, with the values of each
+ card. A date field becomes a date-and-time field and a dropdown field becomes a select field
+ with the same options. A project field with the same name and the same type is used instead
+ of a new one, and a select field gets the options it does not have yet. A value that an issue
+ already holds is not changed. Every custom field of the board is created, whether or not an
+ imported card has a value in it.
+- **Comments** — body, author name and date. A comment is attributed to a project member when
+ its author was matched with one.
+- **Links attached to a card** (a URL, a link to another card) are listed at the end of the
+ description under a **Links** heading.
+- **Links to other cards of the same board** that are attached to a card also become "related"
+ links between the two issues.
+- **Files uploaded to a card** are downloaded with your key and token and attached to the same
+ issue. Several files with the same name on one card are kept apart as `image.png`,
+ `image (2).png` and so on. A file is skipped when it is larger than this instance's upload
+ limit, when its type is one this instance does not accept, or when Trello answers the
+ download with an error. A skipped file is noted in the server log only.
+
+## Matching members
+
+Trello does not give out the email addresses of a board's members, so the import cannot match
+them with project members by itself. Before the import starts you choose one of two options:
+
+- **Don't match** — no issue gets an assignee, and every comment shows its Trello author's name.
+- **Match by hand** — the board's members are listed, and for each one you can pick a member of
+ this project or leave it not matched. The first matched member of a card becomes the issue's
+ assignee, and the other matched members watch the issue. A comment by a matched member is
+ attributed to that project member.
+
+## What is not imported
+
+- **Card covers, stickers, votes, comment reactions, and the activity history** other than
+ comments.
+- **The "due date complete" mark.** The issue keeps the due date only.
+- **Due dates and assignees of checklist items.**
+- **Custom fields of other Power-Ups**, and custom field types other than the five above.
+- **Butler automations, board backgrounds, and the board's own settings.**
+- **Mentions of other cards in text.** A Trello card link inside a description or a comment
+ stays a link to Trello.
+- **Images shown inside a description.** The file is imported as an attachment, but the image
+ link in the text still points to Trello, which needs a Trello login to open it.
+
+## Reviewing the mapping before you import
+
+After you pick a board, its open lists are shown with the category each one would get. The
+category comes from the list's name: "Done" or "Completed" gives Completed, "Doing", "In
+progress" or "Review" gives Started, "Backlog" or "Ideas" gives Backlog, and every other list
+gives Unstarted. Change any row that is wrong before you start the import. A list you do not
+change keeps the automatic category.
+
+## Rate limits
+
+Trello allows each token 100 requests every 10 seconds. When the import reaches that limit, it
+waits 10 seconds and continues. The job list then shows "The source's rate limit was reached.
+Retrying in Ns." This is normal, not a failure.
+
+## Pausing, resuming, canceling, and running it again
+
+Pausing and resuming continues from where the job stopped. Canceling stops it where it is:
+issues that were already created stay, and nothing is rolled back.
+
+A new import of the same board uses what an earlier run created instead of making copies: a
+column is matched by name, an issue by title (not case-sensitive), a comment by its exact text
+and time, and a checklist by its title on the matched issue. Nothing about an existing match is
+overwritten. Because this is a match by name and content, an issue you created by hand with
+exactly the title of a card is treated as the same issue.
+
+## Other sources
+
+[Importing from Plane](importing-from-plane.md) and
+[Importing from Linear](importing-from-linear.md) describe the other sources.
diff --git a/packages/db/drizzle/0158_trello_import.sql b/packages/db/drizzle/0158_trello_import.sql
new file mode 100644
index 00000000..c9c0a254
--- /dev/null
+++ b/packages/db/drizzle/0158_trello_import.sql
@@ -0,0 +1,5 @@
+ALTER TABLE "import_job" DROP CONSTRAINT "import_job_source_check";--> statement-breakpoint
+ALTER TABLE "import_record" DROP CONSTRAINT "import_record_source_entity_type_check";--> statement-breakpoint
+ALTER TABLE "import_record" DROP CONSTRAINT "import_record_local_entity_type_check";--> statement-breakpoint
+ALTER TABLE "import_record" ADD CONSTRAINT "import_record_source_entity_type_check" CHECK ("import_record"."source_entity_type" IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment', 'checklist', 'custom_field'));--> statement-breakpoint
+ALTER TABLE "import_record" ADD CONSTRAINT "import_record_local_entity_type_check" CHECK ("import_record"."local_entity_type" IS NULL OR "import_record"."local_entity_type" IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment', 'checklist', 'custom_field'));
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0158_snapshot.json b/packages/db/drizzle/meta/0158_snapshot.json
new file mode 100644
index 00000000..ef23b1c1
--- /dev/null
+++ b/packages/db/drizzle/meta/0158_snapshot.json
@@ -0,0 +1,12594 @@
+{
+ "id": "af9cba4d-415a-4de3-bf2a-9c3a2ad0d1b5",
+ "prevId": "62c1cef3-df16-4a57-a0ad-a01c9e74a71a",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "account_userId_idx": {
+ "name": "account_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.apikey": {
+ "name": "apikey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'default'"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start": {
+ "name": "start",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prefix": {
+ "name": "prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refill_interval": {
+ "name": "refill_interval",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refill_amount": {
+ "name": "refill_amount",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_refill_at": {
+ "name": "last_refill_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "rate_limit_enabled": {
+ "name": "rate_limit_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "rate_limit_time_window": {
+ "name": "rate_limit_time_window",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 1000
+ },
+ "rate_limit_max": {
+ "name": "rate_limit_max",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 100
+ },
+ "request_count": {
+ "name": "request_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "remaining": {
+ "name": "remaining",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_request": {
+ "name": "last_request",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "apikey_configId_idx": {
+ "name": "apikey_configId_idx",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_referenceId_idx": {
+ "name": "apikey_referenceId_idx",
+ "columns": [
+ {
+ "expression": "reference_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_key_idx": {
+ "name": "apikey_key_idx",
+ "columns": [
+ {
+ "expression": "key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.jwks": {
+ "name": "jwks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_key": {
+ "name": "public_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "private_key": {
+ "name": "private_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alg": {
+ "name": "alg",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "crv": {
+ "name": "crv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oauth_access_token": {
+ "name": "oauth_access_token",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authorization_code_id": {
+ "name": "authorization_code_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resources": {
+ "name": "resources",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_user_info_claims": {
+ "name": "requested_user_info_claims",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_id": {
+ "name": "refresh_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked": {
+ "name": "revoked",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmation": {
+ "name": "confirmation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "oauthAccessToken_clientId_idx": {
+ "name": "oauthAccessToken_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthAccessToken_sessionId_idx": {
+ "name": "oauthAccessToken_sessionId_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthAccessToken_userId_idx": {
+ "name": "oauthAccessToken_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthAccessToken_authorizationCodeId_idx": {
+ "name": "oauthAccessToken_authorizationCodeId_idx",
+ "columns": [
+ {
+ "expression": "authorization_code_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthAccessToken_refreshId_idx": {
+ "name": "oauthAccessToken_refreshId_idx",
+ "columns": [
+ {
+ "expression": "refresh_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_access_token_client_id_oauth_client_client_id_fk": {
+ "name": "oauth_access_token_client_id_oauth_client_client_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "oauth_client",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_access_token_session_id_session_id_fk": {
+ "name": "oauth_access_token_session_id_session_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "session",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "oauth_access_token_user_id_user_id_fk": {
+ "name": "oauth_access_token_user_id_user_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_access_token_refresh_id_oauth_refresh_token_id_fk": {
+ "name": "oauth_access_token_refresh_id_oauth_refresh_token_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "oauth_refresh_token",
+ "columnsFrom": [
+ "refresh_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_access_token_token_unique": {
+ "name": "oauth_access_token_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oauth_client": {
+ "name": "oauth_client",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_secret": {
+ "name": "client_secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_discovery_id": {
+ "name": "client_discovery_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "disabled": {
+ "name": "disabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "skip_consent": {
+ "name": "skip_consent",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enable_end_session": {
+ "name": "enable_end_session",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "subject_type": {
+ "name": "subject_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_credentials_scopes": {
+ "name": "client_credentials_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uri": {
+ "name": "uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contacts": {
+ "name": "contacts",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tos": {
+ "name": "tos",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "policy": {
+ "name": "policy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "software_id": {
+ "name": "software_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "software_version": {
+ "name": "software_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "software_statement": {
+ "name": "software_statement",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "redirect_uris": {
+ "name": "redirect_uris",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "post_logout_redirect_uris": {
+ "name": "post_logout_redirect_uris",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backchannel_logout_uri": {
+ "name": "backchannel_logout_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backchannel_logout_session_required": {
+ "name": "backchannel_logout_session_required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_endpoint_auth_method": {
+ "name": "token_endpoint_auth_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "application_type": {
+ "name": "application_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "jwks": {
+ "name": "jwks",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "jwks_uri": {
+ "name": "jwks_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "grant_types": {
+ "name": "grant_types",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_types": {
+ "name": "response_types",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "require_pkce": {
+ "name": "require_pkce",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dpop_bound_access_tokens": {
+ "name": "dpop_bound_access_tokens",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "oauthClient_userId_idx": {
+ "name": "oauthClient_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_client_user_id_user_id_fk": {
+ "name": "oauth_client_user_id_user_id_fk",
+ "tableFrom": "oauth_client",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_client_client_id_unique": {
+ "name": "oauth_client_client_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "client_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oauth_client_assertion": {
+ "name": "oauth_client_assertion",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oauth_client_resource": {
+ "name": "oauth_client_resource",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "oauthClientResource_clientId_resourceId_uidx": {
+ "name": "oauthClientResource_clientId_resourceId_uidx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthClientResource_clientId_idx": {
+ "name": "oauthClientResource_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthClientResource_resourceId_idx": {
+ "name": "oauthClientResource_resourceId_idx",
+ "columns": [
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_client_resource_client_id_oauth_client_client_id_fk": {
+ "name": "oauth_client_resource_client_id_oauth_client_client_id_fk",
+ "tableFrom": "oauth_client_resource",
+ "tableTo": "oauth_client",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_client_resource_resource_id_oauth_resource_identifier_fk": {
+ "name": "oauth_client_resource_resource_id_oauth_resource_identifier_fk",
+ "tableFrom": "oauth_client_resource",
+ "tableTo": "oauth_resource",
+ "columnsFrom": [
+ "resource_id"
+ ],
+ "columnsTo": [
+ "identifier"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oauth_consent": {
+ "name": "oauth_consent",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resources": {
+ "name": "resources",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_user_info_claims": {
+ "name": "requested_user_info_claims",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "oauthConsent_clientId_idx": {
+ "name": "oauthConsent_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthConsent_userId_idx": {
+ "name": "oauthConsent_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_consent_client_id_oauth_client_client_id_fk": {
+ "name": "oauth_consent_client_id_oauth_client_client_id_fk",
+ "tableFrom": "oauth_consent",
+ "tableTo": "oauth_client",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_consent_user_id_user_id_fk": {
+ "name": "oauth_consent_user_id_user_id_fk",
+ "tableFrom": "oauth_consent",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oauth_refresh_token": {
+ "name": "oauth_refresh_token",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authorization_code_id": {
+ "name": "authorization_code_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resources": {
+ "name": "resources",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_user_info_claims": {
+ "name": "requested_user_info_claims",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked": {
+ "name": "revoked",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rotated_at": {
+ "name": "rotated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rotation_replay_response": {
+ "name": "rotation_replay_response",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rotation_replay_expires_at": {
+ "name": "rotation_replay_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auth_time": {
+ "name": "auth_time",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmation": {
+ "name": "confirmation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "oauthRefreshToken_clientId_idx": {
+ "name": "oauthRefreshToken_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthRefreshToken_sessionId_idx": {
+ "name": "oauthRefreshToken_sessionId_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthRefreshToken_userId_idx": {
+ "name": "oauthRefreshToken_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthRefreshToken_authorizationCodeId_idx": {
+ "name": "oauthRefreshToken_authorizationCodeId_idx",
+ "columns": [
+ {
+ "expression": "authorization_code_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_refresh_token_client_id_oauth_client_client_id_fk": {
+ "name": "oauth_refresh_token_client_id_oauth_client_client_id_fk",
+ "tableFrom": "oauth_refresh_token",
+ "tableTo": "oauth_client",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_refresh_token_session_id_session_id_fk": {
+ "name": "oauth_refresh_token_session_id_session_id_fk",
+ "tableFrom": "oauth_refresh_token",
+ "tableTo": "session",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "oauth_refresh_token_user_id_user_id_fk": {
+ "name": "oauth_refresh_token_user_id_user_id_fk",
+ "tableFrom": "oauth_refresh_token",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_refresh_token_token_unique": {
+ "name": "oauth_refresh_token_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oauth_resource": {
+ "name": "oauth_resource",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token_ttl": {
+ "name": "access_token_ttl",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_ttl": {
+ "name": "refresh_token_ttl",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "signing_algorithm": {
+ "name": "signing_algorithm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "signing_key_id": {
+ "name": "signing_key_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "allowed_scopes": {
+ "name": "allowed_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "custom_claims": {
+ "name": "custom_claims",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dpop_bound_access_tokens_required": {
+ "name": "dpop_bound_access_tokens_required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "disabled": {
+ "name": "disabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "policy_version": {
+ "name": "policy_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 1
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_resource_identifier_unique": {
+ "name": "oauth_resource_identifier_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "identifier"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.passkey": {
+ "name": "passkey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "public_key": {
+ "name": "public_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "counter": {
+ "name": "counter",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_type": {
+ "name": "device_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "backed_up": {
+ "name": "backed_up",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transports": {
+ "name": "transports",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "aaguid": {
+ "name": "aaguid",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "passkey_userId_idx": {
+ "name": "passkey_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "passkey_credentialID_idx": {
+ "name": "passkey_credentialID_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "passkey_user_id_user_id_fk": {
+ "name": "passkey_user_id_user_id_fk",
+ "tableFrom": "passkey",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "session_userId_idx": {
+ "name": "session_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "username": {
+ "name": "username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "display_username": {
+ "name": "display_username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'user'"
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ },
+ "user_username_unique": {
+ "name": "user_username_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "username"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verification": {
+ "name": "verification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verification_identifier_idx": {
+ "name": "verification_identifier_idx",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_event": {
+ "name": "agent_chat_event",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_chat_event_message_idx": {
+ "name": "agent_chat_event_message_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_chat_event_message_id_agent_chat_message_id_fk": {
+ "name": "agent_chat_event_message_id_agent_chat_message_id_fk",
+ "tableFrom": "agent_chat_event",
+ "tableTo": "agent_chat_message",
+ "columnsFrom": [
+ "message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_favorite": {
+ "name": "agent_chat_favorite",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "agent_chat_favorite_user_id_user_id_fk": {
+ "name": "agent_chat_favorite_user_id_user_id_fk",
+ "tableFrom": "agent_chat_favorite",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_chat_favorite_agent_id_ai_agent_id_fk": {
+ "name": "agent_chat_favorite_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_chat_favorite",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_chat_favorite_user_id_thread_id_pk": {
+ "name": "agent_chat_favorite_user_id_thread_id_pk",
+ "columns": [
+ "user_id",
+ "thread_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_message": {
+ "name": "agent_chat_message",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_chat_message_thread_idx": {
+ "name": "agent_chat_message_thread_idx",
+ "columns": [
+ {
+ "expression": "thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_chat_message_due_idx": {
+ "name": "agent_chat_message_due_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"agent_chat_message\".\"status\" IN ('pending', 'streaming')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_chat_message_thread_id_agent_chat_thread_id_fk": {
+ "name": "agent_chat_message_thread_id_agent_chat_thread_id_fk",
+ "tableFrom": "agent_chat_message",
+ "tableTo": "agent_chat_thread",
+ "columnsFrom": [
+ "thread_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_chat_message_agent_id_ai_agent_id_fk": {
+ "name": "agent_chat_message_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_chat_message",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_chat_message_role_check": {
+ "name": "agent_chat_message_role_check",
+ "value": "\"agent_chat_message\".\"role\" IN ('user', 'assistant')"
+ },
+ "agent_chat_message_status_check": {
+ "name": "agent_chat_message_status_check",
+ "value": "\"agent_chat_message\".\"status\" IN ('pending', 'streaming', 'success', 'failed', 'canceled')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_thread": {
+ "name": "agent_chat_thread",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_chat_thread_agent_user_idx": {
+ "name": "agent_chat_thread_agent_user_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_chat_thread_agent_id_ai_agent_id_fk": {
+ "name": "agent_chat_thread_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_chat_thread",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_chat_thread_user_id_user_id_fk": {
+ "name": "agent_chat_thread_user_id_user_id_fk",
+ "tableFrom": "agent_chat_thread",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_usage": {
+ "name": "agent_chat_usage",
+ "schema": "",
+ "columns": {
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "input_tokens": {
+ "name": "input_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output_tokens": {
+ "name": "output_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_chat_usage_agent_idx": {
+ "name": "agent_chat_usage_agent_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_chat_usage_agent_id_ai_agent_id_fk": {
+ "name": "agent_chat_usage_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_chat_usage",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_field_trigger": {
+ "name": "agent_field_trigger",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "delay_sec": {
+ "name": "delay_sec",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 120
+ }
+ },
+ "indexes": {
+ "agent_field_trigger_field_idx": {
+ "name": "agent_field_trigger_field_idx",
+ "columns": [
+ {
+ "expression": "field_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_field_trigger_agent_id_ai_agent_id_fk": {
+ "name": "agent_field_trigger_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_field_trigger",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_field_trigger_field_id_custom_field_id_fk": {
+ "name": "agent_field_trigger_field_id_custom_field_id_fk",
+ "tableFrom": "agent_field_trigger",
+ "tableTo": "custom_field",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_field_trigger_agent_id_field_id_pk": {
+ "name": "agent_field_trigger_agent_id_field_id_pk",
+ "columns": [
+ "agent_id",
+ "field_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_field_trigger_delay_check": {
+ "name": "agent_field_trigger_delay_check",
+ "value": "\"agent_field_trigger\".\"delay_sec\" >= 0 AND \"agent_field_trigger\".\"delay_sec\" <= 86400"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_run": {
+ "name": "agent_run",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schedule_id": {
+ "name": "schedule_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trigger": {
+ "name": "trigger",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'delegation'"
+ },
+ "scheduled_for": {
+ "name": "scheduled_for",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_activity_id": {
+ "name": "source_activity_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_document_comment_id": {
+ "name": "source_document_comment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "input_tokens": {
+ "name": "input_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output_tokens": {
+ "name": "output_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "execution_started_at": {
+ "name": "execution_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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"
+ },
+ "agent_run_document_id_project_document_id_fk": {
+ "name": "agent_run_document_id_project_document_id_fk",
+ "tableFrom": "agent_run",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_run_source_document_comment_id_document_comment_id_fk": {
+ "name": "agent_run_source_document_comment_id_document_comment_id_fk",
+ "tableFrom": "agent_run",
+ "tableTo": "document_comment",
+ "columnsFrom": [
+ "source_document_comment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_run_status_check": {
+ "name": "agent_run_status_check",
+ "value": "\"agent_run\".\"status\" IN ('pending', 'success', 'failed', 'canceled')"
+ },
+ "agent_run_trigger_check": {
+ "name": "agent_run_trigger_check",
+ "value": "\"agent_run\".\"trigger\" IN ('mention', 'delegation', 'field', 'schedule', 'manual', 'status', 'event')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_run_trace": {
+ "name": "agent_run_trace",
+ "schema": "",
+ "columns": {
+ "run_id": {
+ "name": "run_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attempt": {
+ "name": "attempt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "events": {
+ "name": "events",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "next_offset": {
+ "name": "next_offset",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "truncated": {
+ "name": "truncated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "agent_run_trace_run_id_agent_run_id_fk": {
+ "name": "agent_run_trace_run_id_agent_run_id_fk",
+ "tableFrom": "agent_run_trace",
+ "tableTo": "agent_run",
+ "columnsFrom": [
+ "run_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_run_trace_run_id_attempt_pk": {
+ "name": "agent_run_trace_run_id_attempt_pk",
+ "columns": [
+ "run_id",
+ "attempt"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_schedule": {
+ "name": "agent_schedule",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cron'"
+ },
+ "cron": {
+ "name": "cron",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "timezone": {
+ "name": "timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "next_run_at": {
+ "name": "next_run_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "column_id": {
+ "name": "column_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "delay_sec": {
+ "name": "delay_sec",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "options": {
+ "name": "options",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "last_run_at": {
+ "name": "last_run_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_schedule_due_idx": {
+ "name": "agent_schedule_due_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_run_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_schedule_agent_idx": {
+ "name": "agent_schedule_agent_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_schedule_project_idx": {
+ "name": "agent_schedule_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_schedule_column_idx": {
+ "name": "agent_schedule_column_idx",
+ "columns": [
+ {
+ "expression": "column_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_schedule_agent_id_ai_agent_id_fk": {
+ "name": "agent_schedule_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_schedule",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_schedule_project_id_project_id_fk": {
+ "name": "agent_schedule_project_id_project_id_fk",
+ "tableFrom": "agent_schedule",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_schedule_column_id_project_column_id_fk": {
+ "name": "agent_schedule_column_id_project_column_id_fk",
+ "tableFrom": "agent_schedule",
+ "tableTo": "project_column",
+ "columnsFrom": [
+ "column_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_schedule_project_id_agent_id_name_unique": {
+ "name": "agent_schedule_project_id_agent_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "agent_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "agent_schedule_status_check": {
+ "name": "agent_schedule_status_check",
+ "value": "\"agent_schedule\".\"status\" IN ('active', 'paused')"
+ },
+ "agent_schedule_type_check": {
+ "name": "agent_schedule_type_check",
+ "value": "(\"agent_schedule\".\"type\" = 'cron' AND \"agent_schedule\".\"cron\" IS NOT NULL AND \"agent_schedule\".\"next_run_at\" IS NOT NULL AND \"agent_schedule\".\"column_id\" IS NULL)\n OR (\"agent_schedule\".\"type\" = 'status' AND \"agent_schedule\".\"column_id\" IS NOT NULL AND \"agent_schedule\".\"cron\" IS NULL AND \"agent_schedule\".\"next_run_at\" IS NULL)\n OR (\"agent_schedule\".\"type\" NOT IN ('cron', 'status') AND \"agent_schedule\".\"cron\" IS NULL AND \"agent_schedule\".\"next_run_at\" IS NULL AND \"agent_schedule\".\"column_id\" IS NULL)"
+ },
+ "agent_schedule_delay_check": {
+ "name": "agent_schedule_delay_check",
+ "value": "\"agent_schedule\".\"delay_sec\" >= 0 AND \"agent_schedule\".\"delay_sec\" <= 86400"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_skill": {
+ "name": "agent_skill",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "s3_prefix": {
+ "name": "s3_prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "files": {
+ "name": "files",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_skill_team_idx": {
+ "name": "agent_skill_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_skill_team_id_team_id_fk": {
+ "name": "agent_skill_team_id_team_id_fk",
+ "tableFrom": "agent_skill",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_skill_team_id_name_unique": {
+ "name": "agent_skill_team_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "team_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "agent_skill_source_check": {
+ "name": "agent_skill_source_check",
+ "value": "\"agent_skill\".\"source\" IN ('upload', 'inline', 'github')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_skill_link": {
+ "name": "agent_skill_link",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "skill_id": {
+ "name": "skill_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "agent_skill_link_skill_idx": {
+ "name": "agent_skill_link_skill_idx",
+ "columns": [
+ {
+ "expression": "skill_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_skill_link_agent_id_ai_agent_id_fk": {
+ "name": "agent_skill_link_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_skill_link",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_skill_link_skill_id_agent_skill_id_fk": {
+ "name": "agent_skill_link_skill_id_agent_skill_id_fk",
+ "tableFrom": "agent_skill_link",
+ "tableTo": "agent_skill",
+ "columnsFrom": [
+ "skill_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_skill_link_agent_id_skill_id_pk": {
+ "name": "agent_skill_link_agent_id_skill_id_pk",
+ "columns": [
+ "agent_id",
+ "skill_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_tool": {
+ "name": "agent_tool",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tool_key": {
+ "name": "tool_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_tool_team_tool_keyless_uq": {
+ "name": "agent_tool_team_tool_keyless_uq",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "tool_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_tool\".\"credential_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_tool_team_idx": {
+ "name": "agent_tool_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_tool_credential_idx": {
+ "name": "agent_tool_credential_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_tool_team_id_team_id_fk": {
+ "name": "agent_tool_team_id_team_id_fk",
+ "tableFrom": "agent_tool",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_tool_credential_id_integration_credential_id_fk": {
+ "name": "agent_tool_credential_id_integration_credential_id_fk",
+ "tableFrom": "agent_tool",
+ "tableTo": "integration_credential",
+ "columnsFrom": [
+ "credential_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_tool_team_id_tool_key_credential_id_unique": {
+ "name": "agent_tool_team_id_tool_key_credential_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "team_id",
+ "tool_key",
+ "credential_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_tool_link": {
+ "name": "agent_tool_link",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_tool_id": {
+ "name": "agent_tool_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "agent_tool_link_tool_idx": {
+ "name": "agent_tool_link_tool_idx",
+ "columns": [
+ {
+ "expression": "agent_tool_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_tool_link_agent_id_ai_agent_id_fk": {
+ "name": "agent_tool_link_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_tool_link",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_tool_link_agent_tool_id_agent_tool_id_fk": {
+ "name": "agent_tool_link_agent_tool_id_agent_tool_id_fk",
+ "tableFrom": "agent_tool_link",
+ "tableTo": "agent_tool",
+ "columnsFrom": [
+ "agent_tool_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_tool_link_agent_id_agent_tool_id_pk": {
+ "name": "agent_tool_link_agent_id_agent_tool_id_pk",
+ "columns": [
+ "agent_id",
+ "agent_tool_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.ai_agent": {
+ "name": "ai_agent",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "username": {
+ "name": "username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model_credential_id": {
+ "name": "model_credential_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instructions": {
+ "name": "instructions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tools": {
+ "name": "tools",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "temperature": {
+ "name": "temperature",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reasoning_effort": {
+ "name": "reasoning_effort",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "max_steps": {
+ "name": "max_steps",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "run_timeout_sec": {
+ "name": "run_timeout_sec",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trigger_on_mention": {
+ "name": "trigger_on_mention",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "trigger_on_assign": {
+ "name": "trigger_on_assign",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "delegation_delay_sec": {
+ "name": "delegation_delay_sec",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 120
+ },
+ "api_key_ciphertext": {
+ "name": "api_key_ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_key_iv": {
+ "name": "api_key_iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_key_auth_tag": {
+ "name": "api_key_auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "memory_enabled": {
+ "name": "memory_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "memory_last_messages": {
+ "name": "memory_last_messages",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "runner_scope": {
+ "name": "runner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'team'"
+ },
+ "last_seen_at": {
+ "name": "last_seen_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invocation_url": {
+ "name": "invocation_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invocation_secret_ciphertext": {
+ "name": "invocation_secret_ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invocation_secret_iv": {
+ "name": "invocation_secret_iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invocation_secret_auth_tag": {
+ "name": "invocation_secret_auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "ai_agent_team_username_uq": {
+ "name": "ai_agent_team_username_uq",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(\"username\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ai_agent_team_idx": {
+ "name": "ai_agent_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "ai_agent_team_id_team_id_fk": {
+ "name": "ai_agent_team_id_team_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ai_agent_user_id_user_id_fk": {
+ "name": "ai_agent_user_id_user_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ai_agent_model_credential_id_integration_credential_id_fk": {
+ "name": "ai_agent_model_credential_id_integration_credential_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "integration_credential",
+ "columnsFrom": [
+ "model_credential_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "ai_agent_owner_user_id_user_id_fk": {
+ "name": "ai_agent_owner_user_id_user_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "ai_agent_user_id_unique": {
+ "name": "ai_agent_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "ai_agent_kind_check": {
+ "name": "ai_agent_kind_check",
+ "value": "\"ai_agent\".\"kind\" IN ('external', 'internal')"
+ },
+ "ai_agent_runner_scope_check": {
+ "name": "ai_agent_runner_scope_check",
+ "value": "\"ai_agent\".\"runner_scope\" IN ('owner', 'team')"
+ },
+ "ai_agent_reasoning_effort_check": {
+ "name": "ai_agent_reasoning_effort_check",
+ "value": "\"ai_agent\".\"reasoning_effort\" IN ('low', 'medium', 'high')"
+ },
+ "ai_agent_delegation_delay_check": {
+ "name": "ai_agent_delegation_delay_check",
+ "value": "\"ai_agent\".\"delegation_delay_sec\" >= 0 AND \"ai_agent\".\"delegation_delay_sec\" <= 86400"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.app_secret": {
+ "name": "app_secret",
+ "schema": "",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "ciphertext": {
+ "name": "ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "iv": {
+ "name": "iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_tag": {
+ "name": "auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redacted": {
+ "name": "redacted",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.app_setting": {
+ "name": "app_setting",
+ "schema": "",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.chat_attachment": {
+ "name": "chat_attachment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_by_user_id": {
+ "name": "uploaded_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content_type": {
+ "name": "content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "chat_attachment_project_idx": {
+ "name": "chat_attachment_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "chat_attachment_project_id_project_id_fk": {
+ "name": "chat_attachment_project_id_project_id_fk",
+ "tableFrom": "chat_attachment",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "chat_attachment_uploaded_by_user_id_user_id_fk": {
+ "name": "chat_attachment_uploaded_by_user_id_user_id_fk",
+ "tableFrom": "chat_attachment",
+ "tableTo": "user",
+ "columnsFrom": [
+ "uploaded_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "chat_attachment_public_id_unique": {
+ "name": "chat_attachment_public_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "public_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.custom_field": {
+ "name": "custom_field",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_type_id": {
+ "name": "issue_type_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_type": {
+ "name": "field_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "member_scope": {
+ "name": "member_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "show_in_body": {
+ "name": "show_in_body",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "custom_field_project_id_project_id_fk": {
+ "name": "custom_field_project_id_project_id_fk",
+ "tableFrom": "custom_field",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "custom_field_issue_type_id_issue_type_id_fk": {
+ "name": "custom_field_issue_type_id_issue_type_id_fk",
+ "tableFrom": "custom_field",
+ "tableTo": "issue_type",
+ "columnsFrom": [
+ "issue_type_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "custom_field_field_type_check": {
+ "name": "custom_field_field_type_check",
+ "value": "\"custom_field\".\"field_type\" IN ('text', 'markdown', 'url', 'number', 'boolean', 'date', 'datetime', 'datetime_range', 'select', 'multi_select', 'member')"
+ },
+ "custom_field_member_scope_check": {
+ "name": "custom_field_member_scope_check",
+ "value": "(\"custom_field\".\"field_type\" = 'member') = (\"custom_field\".\"member_scope\" IS NOT NULL) AND (\"custom_field\".\"member_scope\" IS NULL OR \"custom_field\".\"member_scope\" IN ('all', 'humans', 'agents'))"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.custom_field_option": {
+ "name": "custom_field_option",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#6b7280'"
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "custom_field_option_field_id_custom_field_id_fk": {
+ "name": "custom_field_option_field_id_custom_field_id_fk",
+ "tableFrom": "custom_field_option",
+ "tableTo": "custom_field",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "custom_field_option_field_id_value_unique": {
+ "name": "custom_field_option_field_id_value_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "field_id",
+ "value"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cycle": {
+ "name": "cycle",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "start_date": {
+ "name": "start_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "end_date": {
+ "name": "end_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "cycle_project_idx": {
+ "name": "cycle_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "start_date",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cycle_project_id_project_id_fk": {
+ "name": "cycle_project_id_project_id_fk",
+ "tableFrom": "cycle",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "cycle_dates_check": {
+ "name": "cycle_dates_check",
+ "value": "\"cycle\".\"end_date\" >= \"cycle\".\"start_date\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.document_asset": {
+ "name": "document_asset",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_by_user_id": {
+ "name": "uploaded_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content_type": {
+ "name": "content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "document_asset_document_idx": {
+ "name": "document_asset_document_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "document_asset_document_id_project_document_id_fk": {
+ "name": "document_asset_document_id_project_document_id_fk",
+ "tableFrom": "document_asset",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_asset_uploaded_by_user_id_user_id_fk": {
+ "name": "document_asset_uploaded_by_user_id_user_id_fk",
+ "tableFrom": "document_asset",
+ "tableTo": "user",
+ "columnsFrom": [
+ "uploaded_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "document_asset_public_id_unique": {
+ "name": "document_asset_public_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "public_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.document_collaboration": {
+ "name": "document_collaboration",
+ "schema": "",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epoch": {
+ "name": "epoch",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "content_json": {
+ "name": "content_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "document_collaboration_document_id_project_document_id_fk": {
+ "name": "document_collaboration_document_id_project_document_id_fk",
+ "tableFrom": "document_collaboration",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.document_comment": {
+ "name": "document_comment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "quote": {
+ "name": "quote",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "selection_from": {
+ "name": "selection_from",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "selection_to": {
+ "name": "selection_to",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "orphaned": {
+ "name": "orphaned",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "resolved_at": {
+ "name": "resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "document_comment_document_idx": {
+ "name": "document_comment_document_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "document_comment_document_id_project_document_id_fk": {
+ "name": "document_comment_document_id_project_document_id_fk",
+ "tableFrom": "document_comment",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_comment_parent_id_document_comment_id_fk": {
+ "name": "document_comment_parent_id_document_comment_id_fk",
+ "tableFrom": "document_comment",
+ "tableTo": "document_comment",
+ "columnsFrom": [
+ "parent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_comment_author_id_user_id_fk": {
+ "name": "document_comment_author_id_user_id_fk",
+ "tableFrom": "document_comment",
+ "tableTo": "user",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.document_step": {
+ "name": "document_step",
+ "schema": "",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "step": {
+ "name": "step",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "document_step_document_id_project_document_id_fk": {
+ "name": "document_step_document_id_project_document_id_fk",
+ "tableFrom": "document_step",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "document_step_document_id_version_pk": {
+ "name": "document_step_document_id_version_pk",
+ "columns": [
+ "document_id",
+ "version"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.git_managed_repository": {
+ "name": "git_managed_repository",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "full_name": {
+ "name": "full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "web_url": {
+ "name": "web_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "webhook_external_id": {
+ "name": "webhook_external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'connected'"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "git_managed_repository_project_connection_idx": {
+ "name": "git_managed_repository_project_connection_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "connection_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "git_managed_repository_project_id_project_id_fk": {
+ "name": "git_managed_repository_project_id_project_id_fk",
+ "tableFrom": "git_managed_repository",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "git_managed_repository_connection_id_git_provider_connection_id_fk": {
+ "name": "git_managed_repository_connection_id_git_provider_connection_id_fk",
+ "tableFrom": "git_managed_repository",
+ "tableTo": "git_provider_connection",
+ "columnsFrom": [
+ "connection_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "git_managed_repository_project_connection_external_unique": {
+ "name": "git_managed_repository_project_connection_external_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "connection_id",
+ "external_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.git_provider_connection": {
+ "name": "git_provider_connection",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_url": {
+ "name": "base_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "account_login": {
+ "name": "account_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ciphertext": {
+ "name": "ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "iv": {
+ "name": "iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_tag": {
+ "name": "auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "git_provider_connection_team_idx": {
+ "name": "git_provider_connection_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "git_provider_connection_team_id_team_id_fk": {
+ "name": "git_provider_connection_team_id_team_id_fk",
+ "tableFrom": "git_provider_connection",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.import_job": {
+ "name": "import_job",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "phase": {
+ "name": "phase",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'discover'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "cursor": {
+ "name": "cursor",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "credential_ciphertext": {
+ "name": "credential_ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_iv": {
+ "name": "credential_iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_auth_tag": {
+ "name": "credential_auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "import_job_project_idx": {
+ "name": "import_job_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "import_job_due_idx": {
+ "name": "import_job_due_idx",
+ "columns": [
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"import_job\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "import_job_project_id_project_id_fk": {
+ "name": "import_job_project_id_project_id_fk",
+ "tableFrom": "import_job",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "import_job_created_by_user_id_user_id_fk": {
+ "name": "import_job_created_by_user_id_user_id_fk",
+ "tableFrom": "import_job",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "import_job_phase_check": {
+ "name": "import_job_phase_check",
+ "value": "\"import_job\".\"phase\" IN ('discover', 'create', 'link', 'rewrite', 'attachments', 'done')"
+ },
+ "import_job_status_check": {
+ "name": "import_job_status_check",
+ "value": "\"import_job\".\"status\" IN ('pending', 'running', 'paused', 'completed', 'failed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.import_record": {
+ "name": "import_record",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "import_job_id": {
+ "name": "import_job_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_entity_type": {
+ "name": "source_entity_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_display_id": {
+ "name": "source_display_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "local_entity_type": {
+ "name": "local_entity_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "local_id": {
+ "name": "local_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "import_record_job_source_uq": {
+ "name": "import_record_job_source_uq",
+ "columns": [
+ {
+ "expression": "import_job_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_entity_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "import_record_job_local_idx": {
+ "name": "import_record_job_local_idx",
+ "columns": [
+ {
+ "expression": "import_job_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "local_entity_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "local_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "import_record_job_display_idx": {
+ "name": "import_record_job_display_idx",
+ "columns": [
+ {
+ "expression": "import_job_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_entity_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_display_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "import_record_import_job_id_import_job_id_fk": {
+ "name": "import_record_import_job_id_import_job_id_fk",
+ "tableFrom": "import_record",
+ "tableTo": "import_job",
+ "columnsFrom": [
+ "import_job_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "import_record_source_entity_type_check": {
+ "name": "import_record_source_entity_type_check",
+ "value": "\"import_record\".\"source_entity_type\" IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment', 'checklist', 'custom_field')"
+ },
+ "import_record_local_entity_type_check": {
+ "name": "import_record_local_entity_type_check",
+ "value": "\"import_record\".\"local_entity_type\" IS NULL OR \"import_record\".\"local_entity_type\" IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment', 'checklist', 'custom_field')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.initiative": {
+ "name": "initiative",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'planned'"
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start_date": {
+ "name": "start_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_date": {
+ "name": "target_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "initiative_project_idx": {
+ "name": "initiative_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "initiative_project_id_project_id_fk": {
+ "name": "initiative_project_id_project_id_fk",
+ "tableFrom": "initiative",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "initiative_owner_user_id_user_id_fk": {
+ "name": "initiative_owner_user_id_user_id_fk",
+ "tableFrom": "initiative",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "initiative_status_check": {
+ "name": "initiative_status_check",
+ "value": "\"initiative\".\"status\" IN ('proposed', 'planned', 'active', 'completed', 'canceled')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.initiative_attachment": {
+ "name": "initiative_attachment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "initiative_id": {
+ "name": "initiative_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content_type": {
+ "name": "content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "initiative_attachment_initiative_idx": {
+ "name": "initiative_attachment_initiative_idx",
+ "columns": [
+ {
+ "expression": "initiative_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "initiative_attachment_initiative_id_initiative_id_fk": {
+ "name": "initiative_attachment_initiative_id_initiative_id_fk",
+ "tableFrom": "initiative_attachment",
+ "tableTo": "initiative",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "initiative_attachment_public_id_unique": {
+ "name": "initiative_attachment_public_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "public_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.initiative_label": {
+ "name": "initiative_label",
+ "schema": "",
+ "columns": {
+ "initiative_id": {
+ "name": "initiative_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label_id": {
+ "name": "label_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "initiative_label_initiative_id_initiative_id_fk": {
+ "name": "initiative_label_initiative_id_initiative_id_fk",
+ "tableFrom": "initiative_label",
+ "tableTo": "initiative",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "initiative_label_label_id_label_id_fk": {
+ "name": "initiative_label_label_id_label_id_fk",
+ "tableFrom": "initiative_label",
+ "tableTo": "label",
+ "columnsFrom": [
+ "label_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "initiative_label_initiative_id_label_id_pk": {
+ "name": "initiative_label_initiative_id_label_id_pk",
+ "columns": [
+ "initiative_id",
+ "label_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.integration_credential": {
+ "name": "integration_credential",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "integration_key": {
+ "name": "integration_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label": {
+ "name": "label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ciphertext": {
+ "name": "ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "iv": {
+ "name": "iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_tag": {
+ "name": "auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redacted": {
+ "name": "redacted",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "integration_credential_team_idx": {
+ "name": "integration_credential_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "integration_credential_team_id_team_id_fk": {
+ "name": "integration_credential_team_id_team_id_fk",
+ "tableFrom": "integration_credential",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue": {
+ "name": "issue",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence_number": {
+ "name": "sequence_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type_id": {
+ "name": "type_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "initiative_id": {
+ "name": "initiative_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cycle_id": {
+ "name": "cycle_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "column_id": {
+ "name": "column_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assignee_user_id": {
+ "name": "assignee_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "delegate_user_id": {
+ "name": "delegate_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimate_points": {
+ "name": "estimate_points",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimate_minutes": {
+ "name": "estimate_minutes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start_date": {
+ "name": "start_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "due_date": {
+ "name": "due_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "share_token": {
+ "name": "share_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "share_extended": {
+ "name": "share_extended",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "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.model_price": {
+ "name": "model_price",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "input": {
+ "name": "input",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "output": {
+ "name": "output",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cache_read": {
+ "name": "cache_read",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cache_write": {
+ "name": "cache_write",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "model_price_workspace_id_workspace_id_fk": {
+ "name": "model_price_workspace_id_workspace_id_fk",
+ "tableFrom": "model_price",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "model_price_workspace_id_provider_model_unique": {
+ "name": "model_price_workspace_id_provider_model_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "workspace_id",
+ "provider",
+ "model"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "model_price_rates_check": {
+ "name": "model_price_rates_check",
+ "value": "\"model_price\".\"input\" >= 0 AND \"model_price\".\"output\" >= 0 AND coalesce(\"model_price\".\"cache_read\", 0) >= 0 AND coalesce(\"model_price\".\"cache_write\", 0) >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.note_board": {
+ "name": "note_board",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "canvas": {
+ "name": "canvas",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "note_board_project_idx": {
+ "name": "note_board_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "note_board_project_id_project_id_fk": {
+ "name": "note_board_project_id_project_id_fk",
+ "tableFrom": "note_board",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "note_board_owner_user_id_user_id_fk": {
+ "name": "note_board_owner_user_id_user_id_fk",
+ "tableFrom": "note_board",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "note_board_created_by_user_id_user_id_fk": {
+ "name": "note_board_created_by_user_id_user_id_fk",
+ "tableFrom": "note_board",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.note_board_member": {
+ "name": "note_board_member",
+ "schema": "",
+ "columns": {
+ "board_id": {
+ "name": "board_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "note_board_member_user_idx": {
+ "name": "note_board_member_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "note_board_member_board_id_note_board_id_fk": {
+ "name": "note_board_member_board_id_note_board_id_fk",
+ "tableFrom": "note_board_member",
+ "tableTo": "note_board",
+ "columnsFrom": [
+ "board_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "note_board_member_user_id_user_id_fk": {
+ "name": "note_board_member_user_id_user_id_fk",
+ "tableFrom": "note_board_member",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "note_board_member_board_id_user_id_pk": {
+ "name": "note_board_member_board_id_user_id_pk",
+ "columns": [
+ "board_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.notification": {
+ "name": "notification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_activity_id": {
+ "name": "source_activity_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "document_comment_id": {
+ "name": "document_comment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "read_at": {
+ "name": "read_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "snoozed_until": {
+ "name": "snoozed_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "notification_user_idx": {
+ "name": "notification_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "notification_user_unread_idx": {
+ "name": "notification_user_unread_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"notification\".\"read_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "notification_user_id_user_id_fk": {
+ "name": "notification_user_id_user_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "notification_project_id_project_id_fk": {
+ "name": "notification_project_id_project_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "notification_issue_id_issue_id_fk": {
+ "name": "notification_issue_id_issue_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "notification_source_activity_id_issue_activity_id_fk": {
+ "name": "notification_source_activity_id_issue_activity_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "issue_activity",
+ "columnsFrom": [
+ "source_activity_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "notification_document_id_project_document_id_fk": {
+ "name": "notification_document_id_project_document_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "notification_document_comment_id_document_comment_id_fk": {
+ "name": "notification_document_comment_id_document_comment_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "document_comment",
+ "columnsFrom": [
+ "document_comment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "notification_actor_user_id_user_id_fk": {
+ "name": "notification_actor_user_id_user_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "user",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "notification_type_check": {
+ "name": "notification_type_check",
+ "value": "\"notification\".\"type\" IN ('assigned', 'mentioned', 'commented', 'state_changed')"
+ },
+ "notification_target_check": {
+ "name": "notification_target_check",
+ "value": "(\"notification\".\"issue_id\" IS NULL) <> (\"notification\".\"document_id\" IS NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.notification_delivery": {
+ "name": "notification_delivery",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel": {
+ "name": "channel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recipient": {
+ "name": "recipient",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "notification_delivery_due_idx": {
+ "name": "notification_delivery_due_idx",
+ "columns": [
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"notification_delivery\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "notification_delivery_project_id_project_id_fk": {
+ "name": "notification_delivery_project_id_project_id_fk",
+ "tableFrom": "notification_delivery",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "notification_delivery_channel_check": {
+ "name": "notification_delivery_channel_check",
+ "value": "\"notification_delivery\".\"channel\" IN ('email', 'telegram')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project": {
+ "name": "project",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "next_sequence": {
+ "name": "next_sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "mcp_enabled": {
+ "name": "mcp_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "initiatives_enabled": {
+ "name": "initiatives_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "dashboards_enabled": {
+ "name": "dashboards_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "documents_enabled": {
+ "name": "documents_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "notes_enabled": {
+ "name": "notes_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "cycles_enabled": {
+ "name": "cycles_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "subtasks_enabled": {
+ "name": "subtasks_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "checklists_enabled": {
+ "name": "checklists_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "issue_stats_enabled": {
+ "name": "issue_stats_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "points_estimate_enabled": {
+ "name": "points_estimate_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "time_estimate_enabled": {
+ "name": "time_estimate_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "time_logging_enabled": {
+ "name": "time_logging_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_team_id_team_id_fk": {
+ "name": "project_team_id_team_id_fk",
+ "tableFrom": "project",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_team_key_uq": {
+ "name": "project_team_key_uq",
+ "nullsNotDistinct": false,
+ "columns": [
+ "team_id",
+ "key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_action": {
+ "name": "project_action",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "condition": {
+ "name": "condition",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "effect": {
+ "name": "effect",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_action_project_idx": {
+ "name": "project_action_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_action_project_id_project_id_fk": {
+ "name": "project_action_project_id_project_id_fk",
+ "tableFrom": "project_action",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_column": {
+ "name": "project_column",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_type": {
+ "name": "state_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unstarted'"
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#6b7280'"
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wip_limit": {
+ "name": "wip_limit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wip_mode": {
+ "name": "wip_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'soft'"
+ },
+ "auto_assign_user_id": {
+ "name": "auto_assign_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_column_project_id_project_id_fk": {
+ "name": "project_column_project_id_project_id_fk",
+ "tableFrom": "project_column",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_column_auto_assign_user_id_user_id_fk": {
+ "name": "project_column_auto_assign_user_id_user_id_fk",
+ "tableFrom": "project_column",
+ "tableTo": "user",
+ "columnsFrom": [
+ "auto_assign_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_column_project_id_position_unique": {
+ "name": "project_column_project_id_position_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "position"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "project_column_state_type_check": {
+ "name": "project_column_state_type_check",
+ "value": "\"project_column\".\"state_type\" IN ('backlog', 'unstarted', 'started', 'completed', 'canceled')"
+ },
+ "project_column_wip_mode_check": {
+ "name": "project_column_wip_mode_check",
+ "value": "\"project_column\".\"wip_mode\" IN ('soft', 'hard')"
+ },
+ "project_column_wip_limit_check": {
+ "name": "project_column_wip_limit_check",
+ "value": "\"project_column\".\"wip_limit\" IS NULL OR \"project_column\".\"wip_limit\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_dashboard": {
+ "name": "project_dashboard",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "layout": {
+ "name": "layout",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_dashboard_project_idx": {
+ "name": "project_dashboard_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_dashboard_project_id_project_id_fk": {
+ "name": "project_dashboard_project_id_project_id_fk",
+ "tableFrom": "project_dashboard",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_document": {
+ "name": "project_document",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "content_json": {
+ "name": "content_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "full_width": {
+ "name": "full_width",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_private": {
+ "name": "is_private",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_locked": {
+ "name": "is_locked",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_by_ancestor_id": {
+ "name": "archived_by_ancestor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_by_user_id": {
+ "name": "updated_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_document_project_tree_idx": {
+ "name": "project_document_project_tree_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_document_owner_idx": {
+ "name": "project_document_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_document_project_archive_idx": {
+ "name": "project_document_project_archive_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "archived_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_document_project_id_project_id_fk": {
+ "name": "project_document_project_id_project_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_parent_id_project_document_id_fk": {
+ "name": "project_document_parent_id_project_document_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "parent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_document_archived_by_ancestor_id_project_document_id_fk": {
+ "name": "project_document_archived_by_ancestor_id_project_document_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "archived_by_ancestor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_document_owner_user_id_user_id_fk": {
+ "name": "project_document_owner_user_id_user_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_document_created_by_user_id_user_id_fk": {
+ "name": "project_document_created_by_user_id_user_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_document_updated_by_user_id_user_id_fk": {
+ "name": "project_document_updated_by_user_id_user_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "user",
+ "columnsFrom": [
+ "updated_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "project_document_version_check": {
+ "name": "project_document_version_check",
+ "value": "\"project_document\".\"version\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_document_initiative": {
+ "name": "project_document_initiative",
+ "schema": "",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "initiative_id": {
+ "name": "initiative_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_document_initiative_initiative_idx": {
+ "name": "project_document_initiative_initiative_idx",
+ "columns": [
+ {
+ "expression": "initiative_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_document_initiative_document_id_project_document_id_fk": {
+ "name": "project_document_initiative_document_id_project_document_id_fk",
+ "tableFrom": "project_document_initiative",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_initiative_initiative_id_initiative_id_fk": {
+ "name": "project_document_initiative_initiative_id_initiative_id_fk",
+ "tableFrom": "project_document_initiative",
+ "tableTo": "initiative",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_initiative_created_by_user_id_user_id_fk": {
+ "name": "project_document_initiative_created_by_user_id_user_id_fk",
+ "tableFrom": "project_document_initiative",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_document_initiative_document_id_initiative_id_pk": {
+ "name": "project_document_initiative_document_id_initiative_id_pk",
+ "columns": [
+ "document_id",
+ "initiative_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_document_issue": {
+ "name": "project_document_issue",
+ "schema": "",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_document_issue_issue_idx": {
+ "name": "project_document_issue_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_document_issue_document_id_project_document_id_fk": {
+ "name": "project_document_issue_document_id_project_document_id_fk",
+ "tableFrom": "project_document_issue",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_issue_issue_id_issue_id_fk": {
+ "name": "project_document_issue_issue_id_issue_id_fk",
+ "tableFrom": "project_document_issue",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_issue_created_by_user_id_user_id_fk": {
+ "name": "project_document_issue_created_by_user_id_user_id_fk",
+ "tableFrom": "project_document_issue",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_document_issue_document_id_issue_id_pk": {
+ "name": "project_document_issue_document_id_issue_id_pk",
+ "columns": [
+ "document_id",
+ "issue_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_document_preference": {
+ "name": "project_document_preference",
+ "schema": "",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_favorite": {
+ "name": "is_favorite",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_document_preference_user_idx": {
+ "name": "project_document_preference_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_document_preference_document_id_project_document_id_fk": {
+ "name": "project_document_preference_document_id_project_document_id_fk",
+ "tableFrom": "project_document_preference",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_preference_user_id_user_id_fk": {
+ "name": "project_document_preference_user_id_user_id_fk",
+ "tableFrom": "project_document_preference",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_document_preference_document_id_user_id_pk": {
+ "name": "project_document_preference_document_id_user_id_pk",
+ "columns": [
+ "document_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_document_revision": {
+ "name": "project_document_revision",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content_json": {
+ "name": "content_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "full_width": {
+ "name": "full_width",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_private": {
+ "name": "is_private",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_locked": {
+ "name": "is_locked",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_document_revision_document_idx": {
+ "name": "project_document_revision_document_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "version",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_document_revision_document_id_project_document_id_fk": {
+ "name": "project_document_revision_document_id_project_document_id_fk",
+ "tableFrom": "project_document_revision",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_revision_owner_user_id_user_id_fk": {
+ "name": "project_document_revision_owner_user_id_user_id_fk",
+ "tableFrom": "project_document_revision",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_document_revision_created_by_user_id_user_id_fk": {
+ "name": "project_document_revision_created_by_user_id_user_id_fk",
+ "tableFrom": "project_document_revision",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_document_revision_document_version_unique": {
+ "name": "project_document_revision_document_version_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "document_id",
+ "version"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_member": {
+ "name": "project_member",
+ "schema": "",
+ "columns": {
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "role_id": {
+ "name": "role_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'invite'"
+ },
+ "is_favorite": {
+ "name": "is_favorite",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_hidden": {
+ "name": "is_hidden",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_member_user_idx": {
+ "name": "project_member_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_member_project_id_project_id_fk": {
+ "name": "project_member_project_id_project_id_fk",
+ "tableFrom": "project_member",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_member_user_id_user_id_fk": {
+ "name": "project_member_user_id_user_id_fk",
+ "tableFrom": "project_member",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_member_role_id_team_role_id_fk": {
+ "name": "project_member_role_id_team_role_id_fk",
+ "tableFrom": "project_member",
+ "tableTo": "team_role",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_member_project_id_user_id_pk": {
+ "name": "project_member_project_id_user_id_pk",
+ "columns": [
+ "project_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "project_member_role_check": {
+ "name": "project_member_role_check",
+ "value": "\"project_member\".\"role\" IN ('owner', 'member')"
+ },
+ "project_member_source_check": {
+ "name": "project_member_source_check",
+ "value": "\"project_member\".\"source\" IN ('invite', 'scim')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_setting": {
+ "name": "project_setting",
+ "schema": "",
+ "columns": {
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_setting_project_id_project_id_fk": {
+ "name": "project_setting_project_id_project_id_fk",
+ "tableFrom": "project_setting",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_setting_project_id_key_pk": {
+ "name": "project_setting_project_id_key_pk",
+ "columns": [
+ "project_id",
+ "key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_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": false
+ },
+ "display_name": {
+ "name": "display_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "scim_group_instance_display_name_uq": {
+ "name": "scim_group_instance_display_name_uq",
+ "columns": [
+ {
+ "expression": "display_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"scim_group\".\"workspace_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scim_group_workspace_id_workspace_id_fk": {
+ "name": "scim_group_workspace_id_workspace_id_fk",
+ "tableFrom": "scim_group",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "scim_group_workspace_id_display_name_unique": {
+ "name": "scim_group_workspace_id_display_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "workspace_id",
+ "display_name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scim_group_mapping": {
+ "name": "scim_group_mapping",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "role_id": {
+ "name": "role_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "scim_group_mapping_project_idx": {
+ "name": "scim_group_mapping_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scim_group_mapping_group_id_scim_group_id_fk": {
+ "name": "scim_group_mapping_group_id_scim_group_id_fk",
+ "tableFrom": "scim_group_mapping",
+ "tableTo": "scim_group",
+ "columnsFrom": [
+ "group_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "scim_group_mapping_project_id_project_id_fk": {
+ "name": "scim_group_mapping_project_id_project_id_fk",
+ "tableFrom": "scim_group_mapping",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "scim_group_mapping_role_id_team_role_id_fk": {
+ "name": "scim_group_mapping_role_id_team_role_id_fk",
+ "tableFrom": "scim_group_mapping",
+ "tableTo": "team_role",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "scim_group_mapping_group_id_project_id_unique": {
+ "name": "scim_group_mapping_group_id_project_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "group_id",
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "scim_group_mapping_role_check": {
+ "name": "scim_group_mapping_role_check",
+ "value": "\"scim_group_mapping\".\"role\" IN ('owner', 'member')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.scim_group_member": {
+ "name": "scim_group_member",
+ "schema": "",
+ "columns": {
+ "group_id": {
+ "name": "group_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "scim_group_member_user_idx": {
+ "name": "scim_group_member_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scim_group_member_group_id_scim_group_id_fk": {
+ "name": "scim_group_member_group_id_scim_group_id_fk",
+ "tableFrom": "scim_group_member",
+ "tableTo": "scim_group",
+ "columnsFrom": [
+ "group_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "scim_group_member_user_id_user_id_fk": {
+ "name": "scim_group_member_user_id_user_id_fk",
+ "tableFrom": "scim_group_member",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "scim_group_member_group_id_user_id_pk": {
+ "name": "scim_group_member_group_id_user_id_pk",
+ "columns": [
+ "group_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scim_user": {
+ "name": "scim_user",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "scim_user_instance_user_uq": {
+ "name": "scim_user_instance_user_uq",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"scim_user\".\"workspace_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scim_user_user_idx": {
+ "name": "scim_user_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scim_user_workspace_id_workspace_id_fk": {
+ "name": "scim_user_workspace_id_workspace_id_fk",
+ "tableFrom": "scim_user",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "scim_user_user_id_user_id_fk": {
+ "name": "scim_user_user_id_user_id_fk",
+ "tableFrom": "scim_user",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "scim_user_workspace_id_user_id_unique": {
+ "name": "scim_user_workspace_id_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.json
index c0d97f2f..6238d1c0 100644
--- a/packages/db/drizzle/meta/_journal.json
+++ b/packages/db/drizzle/meta/_journal.json
@@ -1107,6 +1107,13 @@
"when": 1792948521460,
"tag": "0157_document_mentions",
"breakpoints": true
+ },
+ {
+ "idx": 158,
+ "version": "7",
+ "when": 1793058294770,
+ "tag": "0158_trello_import",
+ "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 20dada96..37107d53 100644
--- a/packages/db/src/schema/app.ts
+++ b/packages/db/src/schema/app.ts
@@ -2326,8 +2326,8 @@ export const webhookDelivery = pgTable(
// worker claims due rows the same way as webhook_delivery, and cursor is the
// job's own per-phase resumability checkpoint, not the source API's pagination
// cursor. The credential columns are cleared once the job reaches a terminal
-// status. One source adapter per value (apps/worker/src/import-sources.ts).
-export type ImportSource = 'plane' | 'linear';
+// status. `source` names a source adapter of the worker (apps/worker/src/import-sources.ts);
+// the database takes any name, so a build can add sources of its own.
export const importJob = pgTable(
'import_job',
@@ -2354,7 +2354,6 @@ export const importJob = pgTable(
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
},
(t) => [
- check('import_job_source_check', sql`${t.source} IN ('plane', 'linear')`),
check(
'import_job_phase_check',
sql`${t.phase} IN ('discover', 'create', 'link', 'rewrite', 'attachments', 'done')`,
@@ -2396,11 +2395,11 @@ export const importRecord = pgTable(
(t) => [
check(
'import_record_source_entity_type_check',
- sql`${t.sourceEntityType} IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment')`,
+ sql`${t.sourceEntityType} IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment', 'checklist', 'custom_field')`,
),
check(
'import_record_local_entity_type_check',
- sql`${t.localEntityType} IS NULL OR ${t.localEntityType} IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment')`,
+ sql`${t.localEntityType} IS NULL OR ${t.localEntityType} IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment', 'checklist', 'custom_field')`,
),
uniqueIndex('import_record_job_source_uq').on(t.importJobId, t.sourceEntityType, t.sourceId),
index('import_record_job_local_idx').on(t.importJobId, t.localEntityType, t.localId),