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(notes): add sticky-note boards (#18)

Croff7fe7a4a28a55
diff --git a/apps/api/src/app.ts b/apps/api/src/app.ts
index 1b34f268..68efb5aa 100644
--- a/apps/api/src/app.ts
+++ b/apps/api/src/app.ts
@@ -79,6 +79,7 @@ export const app = new Elysia()
{ name: 'Webhooks', description: 'Outgoing webhook subscriptions' },
{ name: 'Agent Schedules', description: 'Recurring tasks for internal agents' },
{ name: 'Dashboards', description: 'Saved analytics dashboards' },
+ { name: 'Note boards', description: 'Freeform canvases of sticky notes' },
{ name: 'Notifications', description: "The session user's inbox notifications" },
{
name: 'Telegram',
diff --git a/apps/api/src/note-boards/routes.ts b/apps/api/src/note-boards/routes.ts
new file mode 100644
index 00000000..c78c73ea
--- /dev/null
+++ b/apps/api/src/note-boards/routes.ts
@@ -0,0 +1,187 @@
+import { Elysia, t } from 'elysia';
+import { noContent } from '../shared/http';
+import { guards } from '../shared/guards';
+import { authContext } from '../shared/auth-context';
+import { requireUser } from '../shared/access';
+import { HttpError } from '../shared/lib';
+import { mcpTool } from '../mcp/generate';
+import { ErrorResponse } from '../shared/responses';
+import {
+ listNoteBoards,
+ createNoteBoard,
+ getNoteBoard,
+ updateNoteBoard,
+ deleteNoteBoard,
+ type NoteBoardRow,
+} from './store';
+
+const boardParams = t.Object({ projectKey: t.String(), boardId: t.Numeric() });
+
+// A note board DTO (NoteBoardRow from the store). canvas is a jsonb blob owned by
+// the UI (React Flow nodes/edges) and returned verbatim, so it is typed t.Any().
+const NoteBoardResponse = t.Object({
+ id: t.Number(),
+ projectId: t.Number(),
+ ownerUserId: t.Nullable(t.String()),
+ name: t.String(),
+ canvas: t.Any(),
+ createdAt: t.String(),
+ updatedAt: t.String(),
+});
+
+// The list/switcher DTO: the board without its canvas.
+const NoteBoardSummaryResponse = t.Omit(NoteBoardResponse, ['canvas']);
+
+// Load a board that belongs to this project and that the user may access: a
+// public board (no owner) is open to any member; a personal board only to its
+// owner. Anything else is a 404 so a personal board's existence does not leak.
+async function loadAccessibleBoard(
+ boardId: number,
+ projectId: number,
+ userId: string,
+): Promise<NoteBoardRow> {
+ const board = await getNoteBoard(boardId);
+ if (!board || board.projectId !== projectId) throw new HttpError(404, 'Board not found');
+ if (board.ownerUserId !== null && board.ownerUserId !== userId) {
+ throw new HttpError(404, 'Board not found');
+ }
+ return board;
+}
+
+export const noteBoardRoutes = new Elysia({
+ name: 'note-boards',
+ detail: { tags: ['Note boards'] },
+})
+ .use(authContext)
+ .use(guards)
+ .get(
+ '/projects/:projectKey/note-boards',
+ async ({ project, user, query }) => {
+ return listNoteBoards(project.id, requireUser(user).id, {
+ q: query.q,
+ limit: query.limit ?? 10,
+ offset: query.offset ?? 0,
+ });
+ },
+ {
+ projectMember: true,
+ // Paged for the board switcher: `q` filters by name, `limit`/`offset` page
+ // the result. Canvas is omitted; open a board to load its canvas.
+ query: t.Object({
+ q: t.Optional(t.String()),
+ limit: t.Optional(t.Numeric({ minimum: 1, maximum: 50 })),
+ offset: t.Optional(t.Numeric({ minimum: 0 })),
+ }),
+ response: {
+ 200: t.Array(NoteBoardSummaryResponse),
+ 401: ErrorResponse,
+ 403: ErrorResponse,
+ 404: ErrorResponse,
+ },
+ detail: { summary: "List a project's note boards", ...mcpTool('list_note_boards') },
+ },
+ )
+
+ .get(
+ '/projects/:projectKey/note-boards/:boardId',
+ async ({ project, user, params }) => {
+ return loadAccessibleBoard(params.boardId, project.id, requireUser(user).id);
+ },
+ {
+ projectMember: true,
+ params: boardParams,
+ response: {
+ 200: NoteBoardResponse,
+ 401: ErrorResponse,
+ 403: ErrorResponse,
+ 404: ErrorResponse,
+ },
+ detail: { summary: 'Get a note board with its canvas', ...mcpTool('get_note_board') },
+ },
+ )
+
+ .post(
+ '/projects/:projectKey/note-boards',
+ async ({ project, user, body, set }) => {
+ const userId = requireUser(user).id;
+ set.status = 201;
+ return createNoteBoard({
+ projectId: project.id,
+ ownerUserId: body.personal ? userId : null,
+ name: body.name,
+ canvas: body.canvas,
+ });
+ },
+ {
+ projectMember: true,
+ body: t.Object({
+ name: t.String({ minLength: 1 }),
+ // true creates a personal board owned by the caller; false/omitted a
+ // public board visible to every member.
+ personal: t.Optional(t.Boolean()),
+ canvas: t.Optional(t.Any()),
+ }),
+ response: {
+ 201: NoteBoardResponse,
+ 400: ErrorResponse,
+ 401: ErrorResponse,
+ 403: ErrorResponse,
+ 404: ErrorResponse,
+ },
+ detail: { summary: 'Create a note board', ...mcpTool('create_note_board') },
+ },
+ )
+
+ .patch(
+ '/projects/:projectKey/note-boards/:boardId',
+ async ({ project, user, params, body }) => {
+ const userId = requireUser(user).id;
+ await loadAccessibleBoard(params.boardId, project.id, userId);
+ const patch: { name?: string; canvas?: unknown; ownerUserId?: string | null } = {};
+ if (body.name !== undefined) patch.name = body.name;
+ if (body.canvas !== undefined) patch.canvas = body.canvas;
+ // personal true makes the board owned by (private to) the caller; false makes
+ // it public. Only a user who can already access the board reaches here.
+ if (body.personal !== undefined) patch.ownerUserId = body.personal ? userId : null;
+ const board = await updateNoteBoard(params.boardId, patch);
+ if (!board) throw new HttpError(404, 'Board not found');
+ return board;
+ },
+ {
+ projectMember: true,
+ params: boardParams,
+ body: t.Object({
+ name: t.Optional(t.String({ minLength: 1 })),
+ canvas: t.Optional(t.Any()),
+ personal: t.Optional(t.Boolean()),
+ }),
+ response: {
+ 200: NoteBoardResponse,
+ 400: ErrorResponse,
+ 401: ErrorResponse,
+ 403: ErrorResponse,
+ 404: ErrorResponse,
+ },
+ detail: { summary: 'Update a note board', ...mcpTool('update_note_board') },
+ },
+ )
+
+ .delete(
+ '/projects/:projectKey/note-boards/:boardId',
+ async ({ project, user, params }) => {
+ await loadAccessibleBoard(params.boardId, project.id, requireUser(user).id);
+ await deleteNoteBoard(params.boardId);
+ return noContent();
+ },
+ {
+ projectMember: true,
+ params: boardParams,
+ response: {
+ 204: t.Void(),
+ 401: ErrorResponse,
+ 403: ErrorResponse,
+ 404: ErrorResponse,
+ },
+ detail: { summary: 'Delete a note board', ...mcpTool('delete_note_board') },
+ },
+ );
diff --git a/apps/api/src/note-boards/store.ts b/apps/api/src/note-boards/store.ts
new file mode 100644
index 00000000..17027387
--- /dev/null
+++ b/apps/api/src/note-boards/store.ts
@@ -0,0 +1,112 @@
+import { db, noteBoard } from '@repo/db';
+import { and, desc, eq, ilike, isNull, or, sql } from 'drizzle-orm';
+import { iso } from '../shared/lib';
+
+// Note boards: a freeform canvas of sticky notes. canvas is a jsonb blob owned by
+// the UI (React Flow nodes + edges + viewport); this layer stores and returns it
+// without inspecting its shape. ownerUserId NULL is a public board (every member
+// sees it); a set ownerUserId is a personal board only its owner sees.
+
+export interface NoteBoardRow {
+ id: number;
+ projectId: number;
+ ownerUserId: string | null;
+ name: string;
+ canvas: unknown;
+ createdAt: string;
+ updatedAt: string;
+}
+
+// The board without its canvas — what the board switcher and MRU tabs need. The
+// canvas can be large, so the list omits it; the full board (with canvas) is
+// fetched one at a time via getNoteBoard when a board is opened.
+export type NoteBoardSummary = Omit<NoteBoardRow, 'canvas'>;
+
+function mapNoteBoard(row: typeof noteBoard.$inferSelect): NoteBoardRow {
+ return {
+ id: row.id,
+ projectId: row.projectId,
+ ownerUserId: row.ownerUserId,
+ name: row.name,
+ canvas: row.canvas,
+ createdAt: iso(row.createdAt),
+ updatedAt: iso(row.updatedAt),
+ };
+}
+
+// The boards a user may see in a project, paged for the switcher: every public
+// board plus the user's own personal boards, optionally filtered by a name
+// substring, most-recently-updated first. Canvas is omitted from the list.
+export async function listNoteBoards(
+ projectId: number,
+ userId: string,
+ opts: { q?: string; limit: number; offset: number },
+): Promise<NoteBoardSummary[]> {
+ const visible = and(
+ eq(noteBoard.projectId, projectId),
+ or(isNull(noteBoard.ownerUserId), eq(noteBoard.ownerUserId, userId)),
+ );
+ const where = opts.q ? and(visible, ilike(noteBoard.name, `%${opts.q}%`)) : visible;
+ const rows = await db
+ .select({
+ id: noteBoard.id,
+ projectId: noteBoard.projectId,
+ ownerUserId: noteBoard.ownerUserId,
+ name: noteBoard.name,
+ createdAt: noteBoard.createdAt,
+ updatedAt: noteBoard.updatedAt,
+ })
+ .from(noteBoard)
+ .where(where)
+ .orderBy(desc(noteBoard.updatedAt), noteBoard.id)
+ .limit(opts.limit)
+ .offset(opts.offset);
+ return rows.map((row) => ({
+ id: row.id,
+ projectId: row.projectId,
+ ownerUserId: row.ownerUserId,
+ name: row.name,
+ createdAt: iso(row.createdAt),
+ updatedAt: iso(row.updatedAt),
+ }));
+}
+
+export async function getNoteBoard(id: number): Promise<NoteBoardRow | null> {
+ const [row] = await db.select().from(noteBoard).where(eq(noteBoard.id, id));
+ return row ? mapNoteBoard(row) : null;
+}
+
+// ownerUserId set makes the board personal to that user; null makes it public.
+export async function createNoteBoard(input: {
+ projectId: number;
+ ownerUserId: string | null;
+ name: string;
+ canvas?: unknown;
+}): Promise<NoteBoardRow> {
+ const [row] = await db
+ .insert(noteBoard)
+ .values({
+ projectId: input.projectId,
+ ownerUserId: input.ownerUserId,
+ name: input.name,
+ canvas: input.canvas ?? {},
+ })
+ .returning();
+ return mapNoteBoard(row);
+}
+
+export async function updateNoteBoard(
+ id: number,
+ patch: { name?: string; canvas?: unknown; ownerUserId?: string | null },
+): Promise<NoteBoardRow | null> {
+ const [row] = await db
+ .update(noteBoard)
+ .set({ ...patch, updatedAt: sql`now()` })
+ .where(eq(noteBoard.id, id))
+ .returning();
+ return row ? mapNoteBoard(row) : null;
+}
+
+export async function deleteNoteBoard(id: number): Promise<void> {
+ await db.delete(noteBoard).where(eq(noteBoard.id, id));
+}
diff --git a/apps/api/src/planner.ts b/apps/api/src/planner.ts
index b98ba30a..b2abae01 100644
--- a/apps/api/src/planner.ts
+++ b/apps/api/src/planner.ts
@@ -21,6 +21,7 @@ import { viewRoutes } from './views/routes';
import { actionRoutes } from './actions/routes';
import { webhookRoutes } from './webhooks/routes';
import { dashboardRoutes } from './dashboards/routes';
+import { noteBoardRoutes } from './note-boards/routes';
import { analyticsRoutes } from './analytics/routes';
import { settingsRoutes } from './settings/routes';
import { godRoutes } from './god/routes';
@@ -89,6 +90,7 @@ export const planner = new Elysia({ name: 'planner' })
.use(webhookRoutes)
.use(agentScheduleRoutes)
.use(dashboardRoutes)
+ .use(noteBoardRoutes)
.use(analyticsRoutes)
.use(notificationRoutes)
.use(notificationSettingsRoutes)
diff --git a/apps/web/package.json b/apps/web/package.json
index b9eeb264..c6b66a1d 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -38,10 +38,13 @@
"@tiptap/extension-image": "^3.27.3",
"@tiptap/extension-link": "^3.27.3",
"@tiptap/extension-placeholder": "^3.27.3",
+ "@tiptap/extension-task-item": "^3.27.3",
+ "@tiptap/extension-task-list": "^3.27.3",
"@tiptap/pm": "^3.27.3",
"@tiptap/react": "^3.27.3",
"@tiptap/starter-kit": "^3.27.3",
"@uiw/react-color": "^2.10.3",
+ "@xyflow/react": "^12.11.2",
"better-auth": "^1.3.4",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
diff --git a/apps/web/src/app/globals.css b/apps/web/src/app/globals.css
index 810d967b..9d534516 100644
--- a/apps/web/src/app/globals.css
+++ b/apps/web/src/app/globals.css
@@ -268,6 +268,43 @@
.md-content ol {
list-style: decimal;
}
+/* Task lists render a checkbox per item, not a bullet — drop the list marker and
+ lay each item out as [checkbox] [text]. */
+.md-content ul[data-type='taskList'] {
+ list-style: none;
+ padding-left: 0;
+}
+.md-content ul[data-type='taskList'] li {
+ display: flex;
+ align-items: flex-start;
+ gap: 0.5em;
+}
+.md-content ul[data-type='taskList'] li > label {
+ margin-top: 0.2em;
+}
+.md-content ul[data-type='taskList'] input[type='checkbox'] {
+ cursor: pointer;
+}
+/* Sticky notes always sit on a light pastel background, so their placeholder and
+ checkboxes are keyed to dark regardless of the app theme. */
+.sticker-note .md-content p.is-editor-empty:first-child::before {
+ color: rgba(0, 0, 0, 0.4);
+}
+.sticker-note .md-content ul[data-type='taskList'] input[type='checkbox'] {
+ accent-color: #000;
+}
+/* React Flow's default edge stroke is too dark on the dark canvas. On light it
+ matches the muted foreground; on dark that is still too dim against the near-black
+ canvas, so lift it to a brighter grey. */
+.react-flow__edge-path,
+.react-flow__connection-path {
+ stroke: var(--muted-foreground);
+ stroke-width: 1.5;
+}
+.dark .react-flow__edge-path,
+.dark .react-flow__connection-path {
+ stroke: oklch(0.85 0 0);
+}
.md-content img {
max-width: 100%;
height: auto;
diff --git a/apps/web/src/app/layout.tsx b/apps/web/src/app/layout.tsx
index 3c31df84..4d92c5a0 100644
--- a/apps/web/src/app/layout.tsx
+++ b/apps/web/src/app/layout.tsx
@@ -22,6 +22,10 @@ export default function RootLayout({
defaultTheme="system"
enableSystem
disableTransitionOnChange
+ // A distinct key: next-themes defaults to "theme", which collides with any
+ // other app sharing the same localhost origin. A shared key makes two such
+ // apps fight over the value through cross-tab storage events.
+ storageKey="itsaplan-theme"
>
<Providers>{children}</Providers>
</ThemeProvider>
diff --git a/apps/web/src/app/project/[projectKey]/notes/[boardId]/page.tsx b/apps/web/src/app/project/[projectKey]/notes/[boardId]/page.tsx
new file mode 100644
index 00000000..5446f293
--- /dev/null
+++ b/apps/web/src/app/project/[projectKey]/notes/[boardId]/page.tsx
@@ -0,0 +1,5 @@
+import NotesPage from '@/features/notes/NotesPage';
+
+export default function Page() {
+ return <NotesPage />;
+}
diff --git a/apps/web/src/app/project/[projectKey]/notes/page.tsx b/apps/web/src/app/project/[projectKey]/notes/page.tsx
new file mode 100644
index 00000000..5446f293
--- /dev/null
+++ b/apps/web/src/app/project/[projectKey]/notes/page.tsx
@@ -0,0 +1,5 @@
+import NotesPage from '@/features/notes/NotesPage';
+
+export default function Page() {
+ return <NotesPage />;
+}
diff --git a/apps/web/src/components/layout/SidebarWorkNav.tsx b/apps/web/src/components/layout/SidebarWorkNav.tsx
index 4b020b3c..04be1fe8 100644
--- a/apps/web/src/components/layout/SidebarWorkNav.tsx
+++ b/apps/web/src/components/layout/SidebarWorkNav.tsx
@@ -1,6 +1,6 @@
import { usePathname } from 'next/navigation';
-import { Inbox, LayoutDashboard, SquareKanban, Target } from 'lucide-react';
-import { dashboardsPath, inboxPath, initiativesPath, projectPath } from '@/utils/paths';
+import { Inbox, LayoutDashboard, SquareKanban, StickyNote, Target } from 'lucide-react';
+import { dashboardsPath, inboxPath, initiativesPath, notesPath, projectPath } from '@/utils/paths';
import { usePermissions } from '@/hooks/usePermissions';
import { useInboxUnread } from '@/hooks/useInboxUnread';
import { SidebarGroup, SidebarGroupContent, SidebarMenu } from '@/components/ui/sidebar';
@@ -64,6 +64,13 @@ export default function SidebarWorkNav({
disabled={disabled}
/>
)}
+ <SidebarNavItem
+ href={projectKey ? notesPath(projectKey) : '#'}
+ icon={StickyNote}
+ label="Notes"
+ active={pathname.includes('/notes')}
+ disabled={disabled}
+ />
</SidebarMenu>
</SidebarGroupContent>
</SidebarGroup>
diff --git a/apps/web/src/components/layout/UserMenu.tsx b/apps/web/src/components/layout/UserMenu.tsx
index 2954e460..d32846bd 100644
--- a/apps/web/src/components/layout/UserMenu.tsx
+++ b/apps/web/src/components/layout/UserMenu.tsx
@@ -1,5 +1,6 @@
'use client';
+import { useEffect, useState } from 'react';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { LogOut } from 'lucide-react';
@@ -25,7 +26,13 @@ export default function UserMenu() {
const router = useRouter();
const { data: session, isPending } = useSession();
- if (isPending) return <Skeleton className="size-7 rounded-full" />;
+ // better-auth reads the session on the client, so the server renders no user and
+ // the client may already have a cached session. Render the placeholder until
+ // mounted so the first client render matches the server and hydration succeeds.
+ const [mounted, setMounted] = useState(false);
+ useEffect(() => setMounted(true), []);
+
+ if (!mounted || isPending) return <Skeleton className="size-7 rounded-full" />;
if (!session) return null;
const { user } = session;
diff --git a/apps/web/src/components/preferences-sync.tsx b/apps/web/src/components/preferences-sync.tsx
index 197358b9..b6e8df25 100644
--- a/apps/web/src/components/preferences-sync.tsx
+++ b/apps/web/src/components/preferences-sync.tsx
@@ -1,6 +1,6 @@
'use client';
-import { useEffect } from 'react';
+import { useEffect, useRef } from 'react';
import { useTheme } from 'next-themes';
import {
useAccountPreferencesQuery,
@@ -27,8 +27,18 @@ export default function PreferencesSync() {
if (timezone) setDisplayTimezone(timezone);
}, [timezone]);
+ // Apply the account theme only when the stored value itself changes (initial load,
+ // or another device changing it). Do not reconcile against next-themes' live state:
+ // next-themes keeps its own localStorage copy and syncs it across tabs, so diffing
+ // against it turns two open tabs into a write loop through that shared key. The ref
+ // also makes the effect idempotent, which matters because next-themes rebuilds
+ // setTheme on every theme change and so re-triggers this effect.
+ const appliedTheme = useRef<string | undefined>(undefined);
useEffect(() => {
- if (theme) setTheme(theme);
+ if (theme && theme !== appliedTheme.current) {
+ appliedTheme.current = theme;
+ setTheme(theme);
+ }
}, [theme, setTheme]);
useEffect(() => {
diff --git a/apps/web/src/features/notes/NotesPage.tsx b/apps/web/src/features/notes/NotesPage.tsx
new file mode 100644
index 00000000..9b7aec58
--- /dev/null
+++ b/apps/web/src/features/notes/NotesPage.tsx
@@ -0,0 +1,146 @@
+'use client';
+
+import { useEffect, useMemo } from 'react';
+import { useParams, useRouter } from 'next/navigation';
+import { useQueryClient } from '@tanstack/react-query';
+import { ReactFlowProvider } from '@xyflow/react';
+import { useShell } from '@/context/shellContext';
+import { ApiError } from '@/lib/api';
+import { notePath, notesPath } from '@/utils/paths';
+import { qk } from '@/services/queryKeys';
+import { Skeleton } from '@/components/ui/skeleton';
+import {
+ useNoteBoardSearch,
+ useNoteBoardQuery,
+ useCreateNoteBoard,
+ useRenameNoteBoard,
+ useSetNoteBoardVisibility,
+ useDeleteNoteBoard,
+ flattenBoardPages,
+} from './services/noteBoards.service';
+import { useNoteBoardMru, type MruEntry } from './hooks/useNoteBoardMru';
+import NoteBoardBar from './components/NoteBoardBar';
+import NoteCanvas from './components/NoteCanvas';
+import NotesEmptyState from './components/NotesEmptyState';
+
+// The maximum number of tabs shown (matches the MRU cap).
+const MAX_TABS = 5;
+
+// The notes section: a tab strip of recently-used boards over a freeform canvas of
+// sticky notes. The active board comes from the route, falling back to the first
+// tab. Tabs are the recently-used boards, topped up from the first page of the
+// switcher list when fewer than MAX_TABS have been opened. Opening a board loads
+// it fresh (its full canvas) and moves it to the front of the tab strip.
+export default function NotesPage() {
+ const { project } = useShell();
+ const params = useParams<{ projectKey: string; boardId?: string }>();
+ const router = useRouter();
+ const qc = useQueryClient();
+ const projectKey = params.projectKey;
+
+ const { entries: mru, record, remove: removeMru } = useNoteBoardMru(projectKey);
+ // The first page of the switcher list, reused to top up the tabs. Shares its
+ // cache with the switcher's empty-query page.
+ const seedQuery = useNoteBoardSearch(projectKey, '');
+ const seed = flattenBoardPages(seedQuery.data?.pages);
+
+ const createBoard = useCreateNoteBoard(projectKey);
+ const renameBoard = useRenameNoteBoard(projectKey);
+ const setVisibility = useSetNoteBoardVisibility(projectKey);
+ const deleteBoard = useDeleteNoteBoard(projectKey);
+
+ const tabs = useMemo<MruEntry[]>(() => {
+ const result = [...mru];
+ const seen = new Set(mru.map((e) => e.id));
+ for (const b of seed) {
+ if (result.length >= MAX_TABS) break;
+ if (seen.has(b.id)) continue;
+ result.push({ id: b.id, name: b.name, personal: b.ownerUserId != null });
+ seen.add(b.id);
+ }
+ return result;
+ }, [mru, seed]);
+
+ const routeId = params.boardId ? Number(params.boardId) : null;
+ const activeBoardId = routeId ?? tabs[0]?.id ?? null;
+
+ const { data: activeBoard, isError, error } = useNoteBoardQuery(projectKey, activeBoardId);
+
+ // Record the opened board as most-recent once it loads. Also refreshes its cached
+ // tab label and visibility, healing a stale MRU entry (renamed elsewhere).
+ useEffect(() => {
+ if (activeBoard) {
+ record({
+ id: activeBoard.id,
+ name: activeBoard.name,
+ personal: activeBoard.ownerUserId != null,
+ });
+ }
+ }, [activeBoard, record]);
+
+ // A board that is gone or no longer accessible: drop it from the MRU tabs, drop
+ // it from the switcher lists (it may still be in a stale seed page), and fall
+ // back to the board list.
+ useEffect(() => {
+ if (isError && error instanceof ApiError && error.status === 404 && activeBoardId != null) {
+ removeMru(activeBoardId);
+ void qc.invalidateQueries({ queryKey: [...qk.noteBoardsForProject(projectKey), 'search'] });
+ router.replace(notesPath(projectKey));
+ }
+ }, [isError, error, activeBoardId, removeMru, qc, router, projectKey]);
+
+ if (!project || seedQuery.isLoading) {
+ return (
+ <div className="flex-1 space-y-4 p-6">
+ <Skeleton className="h-8 w-full max-w-md" />
+ <Skeleton className="h-96 w-full" />
+ </div>
+ );
+ }
+
+ async function create(name: string, personal: boolean) {
+ const board = await createBoard.mutateAsync({ name, personal });
+ router.push(notePath(projectKey, board.id));
+ }
+
+ function remove(boardId: number) {
+ deleteBoard.mutate(boardId, {
+ onSuccess: () => {
+ removeMru(boardId);
+ if (boardId === activeBoardId) router.push(notesPath(projectKey));
+ },
+ });
+ }
+
+ function renderContent() {
+ if (activeBoard) {
+ return (
+ <ReactFlowProvider key={activeBoard.id}>
+ <NoteCanvas projectKey={projectKey} board={activeBoard} />
+ </ReactFlowProvider>
+ );
+ }
+ // A board is selected but its canvas is still loading.
+ if (activeBoardId != null && !isError) {
+ return <Skeleton className="m-6 flex-1" />;
+ }
+ return <NotesEmptyState projectKey={projectKey} onCreate={create} />;
+ }
+
+ return (
+ <div className="flex flex-1 flex-col overflow-hidden">
+ <NoteBoardBar
+ projectKey={projectKey}
+ tabs={tabs}
+ activeBoardId={activeBoardId}
+ onSelect={(id) => router.push(notePath(projectKey, id))}
+ onCreate={create}
+ onRename={(id, name) => renameBoard.mutate({ boardId: id, name })}
+ onToggleVisibility={(id, personal) => setVisibility.mutate({ boardId: id, personal })}
+ onDelete={remove}
+ />
+
+ {renderContent()}
+ </div>
+ );
+}
diff --git a/apps/web/src/features/notes/components/BoardSwitcher.tsx b/apps/web/src/features/notes/components/BoardSwitcher.tsx
new file mode 100644
index 00000000..555c5d76
--- /dev/null
+++ b/apps/web/src/features/notes/components/BoardSwitcher.tsx
@@ -0,0 +1,112 @@
+import { useState, type UIEvent } from 'react';
+import { Check, ChevronsUpDown, Layers, Loader2, Lock, StickyNote } from 'lucide-react';
+import type { NoteBoardSummary } from '@/lib/api';
+import { useDebouncedValue } from '@/hooks/useDebouncedValue';
+import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
+import {
+ Command,
+ CommandEmpty,
+ CommandGroup,
+ CommandInput,
+ CommandItem,
+ CommandList,
+} from '@/components/ui/command';
+import { useNoteBoardSearch, flattenBoardPages } from '../services/noteBoards.service';
+
+// Load the next page when the list is scrolled near the bottom.
+const SCROLL_THRESHOLD = 48;
+
+// The board switcher: a searchable, paged list of every board the user can see.
+// Search runs on the server (filtering by name) and loads a page at a time, so the
+// whole set is never fetched at once. Selecting a board hands its id to the host,
+// which loads the board fresh.
+export default function BoardSwitcher({
+ projectKey,
+ activeBoardId,
+ onSelect,
+}: {
+ projectKey: string;
+ activeBoardId: number | null;
+ onSelect: (id: number) => void;
+}) {
+ const [open, setOpen] = useState(false);
+ const [query, setQuery] = useState('');
+ const debounced = useDebouncedValue(query, 250);
+ const { data, isLoading, hasNextPage, isFetchingNextPage, fetchNextPage } = useNoteBoardSearch(
+ projectKey,
+ debounced,
+ );
+
+ const boards = flattenBoardPages(data?.pages);
+ const publicBoards = boards.filter((b) => !b.ownerUserId);
+ const personalBoards = boards.filter((b) => b.ownerUserId);
+
+ function onScroll(e: UIEvent<HTMLDivElement>) {
+ const el = e.currentTarget;
+ if (el.scrollHeight - el.scrollTop - el.clientHeight < SCROLL_THRESHOLD) {
+ if (hasNextPage && !isFetchingNextPage) void fetchNextPage();
+ }
+ }
+
+ function select(id: number) {
+ onSelect(id);
+ setOpen(false);
+ }
+
+ const renderRow = (b: NoteBoardSummary) => (
+ <CommandItem key={b.id} value={`board-${b.id}`} onSelect={() => select(b.id)}>
+ {b.ownerUserId ? <Lock className="size-3.5" /> : <StickyNote className="size-3.5" />}
+ <span className="truncate">{b.name}</span>
+ {b.id === activeBoardId && <Check className="ml-auto size-3.5" />}
+ </CommandItem>
+ );
+
+ return (
+ <Popover
+ // Modal so a click on the React Flow canvas (which captures pointer events)
+ // reliably dismisses the switcher instead of being swallowed by the canvas.
+ modal
+ open={open}
+ onOpenChange={(next) => {
+ setOpen(next);
+ if (next) setQuery('');
+ }}
+ >
+ <PopoverTrigger
+ aria-label="All boards"
+ className="flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-sm text-muted-foreground hover:bg-accent hover:text-foreground"
+ >
+ <Layers className="size-3.5" />
+ <span className="hidden sm:inline">All boards</span>
+ <ChevronsUpDown className="size-3.5" />
+ </PopoverTrigger>
+ <PopoverContent align="start" className="w-72 p-0">
+ <Command shouldFilter={false}>
+ <CommandInput placeholder="Search boards…" value={query} onValueChange={setQuery} />
+ <CommandList onScroll={onScroll}>
+ {isLoading ? (
+ <div className="flex items-center justify-center py-6 text-muted-foreground">
+ <Loader2 className="size-4 animate-spin" />
+ </div>
+ ) : (
+ <>
+ <CommandEmpty>No boards found.</CommandEmpty>
+ {publicBoards.length > 0 && (
+ <CommandGroup heading="Public">{publicBoards.map(renderRow)}</CommandGroup>
+ )}
+ {personalBoards.length > 0 && (
+ <CommandGroup heading="Personal">{personalBoards.map(renderRow)}</CommandGroup>
+ )}
+ {isFetchingNextPage && (
+ <div className="flex items-center justify-center py-2 text-muted-foreground">
+ <Loader2 className="size-3.5 animate-spin" />
+ </div>
+ )}
+ </>
+ )}
+ </CommandList>
+ </Command>
+ </PopoverContent>
+ </Popover>
+ );
+}
diff --git a/apps/web/src/features/notes/components/NoteBoardBar.tsx b/apps/web/src/features/notes/components/NoteBoardBar.tsx
new file mode 100644
index 00000000..31e5f4da
--- /dev/null
+++ b/apps/web/src/features/notes/components/NoteBoardBar.tsx
@@ -0,0 +1,132 @@
+import { useState } from 'react';
+import { Globe, Lock, MoreHorizontal, Pencil, Plus, StickyNote, Trash2 } from 'lucide-react';
+import { cn } from '@/lib/utils';
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu';
+import type { MruEntry } from '../hooks/useNoteBoardMru';
+import NoteBoardNameDialog from './NoteBoardNameDialog';
+import BoardSwitcher from './BoardSwitcher';
+
+// The notes header: a fixed "+" create button on the left edge, a strip of the
+// recently-used boards as tabs, and a board switcher (searchable, paged) on the
+// right. A personal board carries a lock; the active tab exposes rename, a
+// public/personal toggle, and delete. The tab set is the MRU list from the host.
+export default function NoteBoardBar({
+ projectKey,
+ tabs,
+ activeBoardId,
+ onSelect,
+ onCreate,
+ onRename,
+ onToggleVisibility,
+ onDelete,
+}: {
+ projectKey: string;
+ tabs: MruEntry[];
+ activeBoardId: number | null;
+ onSelect: (id: number) => void;
+ onCreate: (name: string, personal: boolean) => void;
+ onRename: (id: number, name: string) => void;
+ onToggleVisibility: (id: number, personal: boolean) => void;
+ onDelete: (id: number) => void;
+}) {
+ // 'create' to open the new-board dialog, an MRU entry to rename, or null (closed).
+ const [dialog, setDialog] = useState<'create' | MruEntry | null>(null);
+ const renaming = dialog && typeof dialog === 'object' ? dialog : null;
+
+ // A stable remount key for the name dialog so its input resets per open.
+ function dialogKey() {
+ if (renaming) return `rename-${renaming.id}`;
+ return dialog === 'create' ? 'create' : 'closed';
+ }
+
+ return (
+ <div className="flex items-center gap-1 border-b px-2 py-1.5 sm:px-3">
+ <button
+ type="button"
+ aria-label="New board"
+ onClick={() => setDialog('create')}
+ className="flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground"
+ >
+ <Plus className="size-4" />
+ </button>
+
+ <BoardSwitcher projectKey={projectKey} activeBoardId={activeBoardId} onSelect={onSelect} />
+
+ <div className="flex min-w-0 flex-1 items-center gap-1 overflow-x-auto">
+ {tabs.map((tab) => {
+ const active = activeBoardId === tab.id;
+ return (
+ <div
+ key={tab.id}
+ className={cn(
+ 'flex shrink-0 items-center gap-1.5 rounded-md px-2 py-1 text-sm',
+ active
+ ? 'bg-secondary font-medium text-foreground'
+ : 'text-muted-foreground hover:bg-accent hover:text-foreground',
+ )}
+ >
+ <button
+ type="button"
+ onClick={() => onSelect(tab.id)}
+ className="flex items-center gap-1.5"
+ >
+ {tab.personal ? <Lock className="size-3.5" /> : <StickyNote className="size-3.5" />}
+ {tab.name}
+ </button>
+ {active && (
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ aria-label="Board options"
+ className="text-muted-foreground hover:text-foreground"
+ >
+ <MoreHorizontal className="size-3.5" />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start">
+ <DropdownMenuItem onClick={() => setDialog(tab)}>
+ <Pencil className="size-4" /> Rename
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={() => onToggleVisibility(tab.id, !tab.personal)}>
+ {tab.personal ? (
+ <>
+ <Globe className="size-4" /> Make public
+ </>
+ ) : (
+ <>
+ <Lock className="size-4" /> Make private
+ </>
+ )}
+ </DropdownMenuItem>
+ <DropdownMenuItem variant="destructive" onClick={() => onDelete(tab.id)}>
+ <Trash2 className="size-4" /> Delete
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ </div>
+ );
+ })}
+ </div>
+
+ <NoteBoardNameDialog
+ key={dialogKey()}
+ open={dialog != null}
+ title={renaming ? 'Rename board' : 'New board'}
+ description={renaming ? undefined : 'A freeform canvas for sticky notes.'}
+ projectKey={projectKey}
+ initial={renaming?.name ?? ''}
+ withVisibility={dialog === 'create'}
+ onClose={() => setDialog(null)}
+ onSubmit={(name, personal) => {
+ if (renaming) onRename(renaming.id, name);
+ else onCreate(name, personal);
+ setDialog(null);
+ }}
+ />
+ </div>
+ );
+}
diff --git a/apps/web/src/features/notes/components/NoteBoardNameDialog.tsx b/apps/web/src/features/notes/components/NoteBoardNameDialog.tsx
new file mode 100644
index 00000000..e876a922
--- /dev/null
+++ b/apps/web/src/features/notes/components/NoteBoardNameDialog.tsx
@@ -0,0 +1,92 @@
+import { useState } from 'react';
+import { Globe, Lock } from 'lucide-react';
+import Modal from '@/components/common/overlay/Modal';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { Label } from '@/components/ui/label';
+
+// A name prompt used for creating and renaming a note board. When `withVisibility`
+// is set (creating), it also picks whether the board is public or personal.
+export default function NoteBoardNameDialog({
+ open,
+ title,
+ description,
+ projectKey,
+ initial,
+ withVisibility = false,
+ onClose,
+ onSubmit,
+}: {
+ open: boolean;
+ title: string;
+ description?: string;
+ projectKey?: string;
+ initial: string;
+ withVisibility?: boolean;
+ onClose: () => void;
+ onSubmit: (name: string, personal: boolean) => void;
+}) {
+ const [name, setName] = useState(initial);
+ const [personal, setPersonal] = useState(false);
+
+ if (!open) return null;
+
+ const isValid = name.trim().length > 0;
+
+ return (
+ <Modal title={title} description={description} projectKey={projectKey} onClose={onClose}>
+ <form
+ className="space-y-5"
+ onSubmit={(e) => {
+ e.preventDefault();
+ if (isValid) onSubmit(name.trim(), personal);
+ }}
+ >
+ <div className="space-y-1.5">
+ <Label htmlFor="board-name">Name</Label>
+ <div className="flex gap-2">
+ {withVisibility && (
+ <button
+ type="button"
+ aria-label={personal ? 'Make public' : 'Make personal'}
+ title={
+ personal ? 'Personal — click to make public' : 'Public — click to make personal'
+ }
+ onClick={() => setPersonal((p) => !p)}
+ className="flex size-9 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground"
+ >
+ {personal ? <Lock className="size-4" /> : <Globe className="size-4" />}
+ </button>
+ )}
+ <Input
+ id="board-name"
+ autoFocus
+ required
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ placeholder="Board name"
+ className="h-9"
+ />
+ </div>
+ </div>
+
+ {withVisibility && (
+ <p className="text-sm text-muted-foreground">
+ {personal
+ ? 'Only you can see this board.'
+ : 'Everyone in the project can see this board.'}
+ </p>
+ )}
+
+ <div className="flex justify-end gap-2">
+ <Button type="button" variant="ghost" onClick={onClose}>
+ Cancel
+ </Button>
+ <Button type="submit" disabled={!isValid}>
+ {withVisibility ? 'Create board' : 'Save'}
+ </Button>
+ </div>
+ </form>
+ </Modal>
+ );
+}
diff --git a/apps/web/src/features/notes/components/NoteCanvas.tsx b/apps/web/src/features/notes/components/NoteCanvas.tsx
new file mode 100644
index 00000000..0897991f
--- /dev/null
+++ b/apps/web/src/features/notes/components/NoteCanvas.tsx
@@ -0,0 +1,181 @@
+import { useCallback, useEffect, useMemo, useState, type MouseEvent } from 'react';
+import {
+ ReactFlow,
+ Background,
+ Controls,
+ addEdge,
+ useNodesState,
+ useEdgesState,
+ useReactFlow,
+ type Connection,
+ type Edge,
+} from '@xyflow/react';
+import '@xyflow/react/dist/style.css';
+import { useTheme } from 'next-themes';
+import { Globe, Lock, Maximize2, Minimize2, Plus } from 'lucide-react';
+import type { NoteBoard } from '@/lib/api';
+import { Button } from '@/components/ui/button';
+import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
+import { cn } from '@/lib/utils';
+import { useSetNoteBoardVisibility } from '../services/noteBoards.service';
+import StickerNode, { type StickerNodeType } from './StickerNode';
+import { toFlowNodes, toFlowEdges, newSticker } from '../utils/noteCanvas';
+import { useCanvasAutosave, type SaveStatus } from '../hooks/useCanvasAutosave';
+
+const SAVE_STATUS_LABEL: Record<SaveStatus, string> = {
+ unsaved: 'Unsaved changes',
+ saving: 'Saving…',
+ saved: 'Saved',
+ error: 'Save failed',
+};
+
+// The board canvas: a React Flow surface of sticky-note nodes. Double-click empty
+// space (or the Add note button) drops a sticker; dragging between node handles
+// connects them. Changes autosave (see useCanvasAutosave). Keyed by board id by
+// the host, so the state resets when the board changes.
+export default function NoteCanvas({
+ projectKey,
+ board,
+}: {
+ projectKey: string;
+ board: NoteBoard;
+}) {
+ const nodeTypes = useMemo(() => ({ sticker: StickerNode }), []);
+ const [nodes, setNodes, onNodesChange] = useNodesState<StickerNodeType>(
+ toFlowNodes(board.canvas),
+ );
+ const [edges, setEdges, onEdgesChange] = useEdgesState<Edge>(toFlowEdges(board.canvas));
+ const [fullscreen, setFullscreen] = useState(false);
+
+ // Leave fullscreen on Escape.
+ useEffect(() => {
+ if (!fullscreen) return;
+ const onKey = (e: KeyboardEvent) => {
+ if (e.key === 'Escape') setFullscreen(false);
+ };
+ window.addEventListener('keydown', onKey);
+ return () => window.removeEventListener('keydown', onKey);
+ }, [fullscreen]);
+
+ const { screenToFlowPosition } = useReactFlow();
+ const { resolvedTheme } = useTheme();
+
+ const setVisibility = useSetNoteBoardVisibility(projectKey);
+ const personal = board.ownerUserId != null;
+
+ // The canvas autosave and the visibility toggle report through one status line
+ // after the board name, so toggling public/personal shows Saving…/Saved too.
+ const canvasStatus = useCanvasAutosave(projectKey, board.id, nodes, edges);
+ let saveStatus: SaveStatus = 'saved';
+ if (canvasStatus === 'saving' || setVisibility.isPending) saveStatus = 'saving';
+ else if (canvasStatus === 'error' || setVisibility.isError) saveStatus = 'error';
+ else if (canvasStatus === 'unsaved') saveStatus = 'unsaved';
+
+ // The status stays visible while there are unsaved edits, a save is in flight, or
+ // a save failed; a successful "Saved" hides a few seconds later. An open board
+ // that has not been edited shows nothing (its initial state is already "saved").
+ const [showStatus, setShowStatus] = useState(false);
+ useEffect(() => {
+ if (saveStatus === 'saved') {
+ const timer = setTimeout(() => setShowStatus(false), 3000);
+ return () => clearTimeout(timer);
+ }
+ setShowStatus(true);
+ }, [saveStatus]);
+
+ const onConnect = useCallback(
+ (conn: Connection) => setEdges((eds) => addEdge(conn, eds)),
+ [setEdges],
+ );
+
+ const addAt = useCallback(
+ (x: number, y: number) => {
+ setNodes((nds) => [...nds, newSticker(screenToFlowPosition({ x, y }))]);
+ },
+ [screenToFlowPosition, setNodes],
+ );
+
+ // Only a double-click on empty canvas adds a note; double-clicking a node must not.
+ const onDoubleClick = (e: MouseEvent<HTMLDivElement>) => {
+ if ((e.target as HTMLElement).classList.contains('react-flow__pane')) {
+ addAt(e.clientX, e.clientY);
+ }
+ };
+
+ return (
+ <div
+ className={cn('relative flex-1', fullscreen && 'fixed inset-0 z-50 bg-background')}
+ onDoubleClick={onDoubleClick}
+ >
+ <div className="absolute top-3 left-3 z-10 flex items-center gap-2">
+ <Tooltip>
+ <TooltipTrigger
+ aria-label={personal ? 'Make public' : 'Make private'}
+ onClick={() => setVisibility.mutate({ boardId: board.id, personal: !personal })}
+ className="flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground"
+ >
+ {personal ? <Lock className="size-3.5" /> : <Globe className="size-3.5" />}
+ </TooltipTrigger>
+ <TooltipContent>
+ {personal
+ ? 'Make public — visible to every project member'
+ : 'Make private — visible only to you'}
+ </TooltipContent>
+ </Tooltip>
+ <span className="text-sm leading-none font-medium text-foreground">{board.name}</span>
+ {showStatus && (
+ <span
+ className={cn(
+ 'text-xs leading-none',
+ saveStatus === 'error' ? 'text-destructive' : 'text-muted-foreground',
+ )}
+ >
+ {SAVE_STATUS_LABEL[saveStatus]}
+ </span>
+ )}
+ </div>
+
+ <div className="absolute top-3 right-3 z-10 flex items-center gap-2">
+ <Button
+ variant="secondary"
+ size="sm"
+ onClick={() => {
+ const el = document.querySelector('.react-flow');
+ const r = el?.getBoundingClientRect();
+ addAt((r?.left ?? 0) + (r?.width ?? 0) / 2, (r?.top ?? 0) + (r?.height ?? 0) / 2);
+ }}
+ >
+ <Plus className="size-4" /> Add note
+ </Button>
+ <Button
+ variant="secondary"
+ size="icon-sm"
+ aria-label={fullscreen ? 'Exit fullscreen' : 'Fullscreen'}
+ onClick={() => setFullscreen((v) => !v)}
+ >
+ {fullscreen ? <Minimize2 className="size-4" /> : <Maximize2 className="size-4" />}
+ </Button>
+ </div>
+
+ <ReactFlow
+ nodes={nodes}
+ edges={edges}
+ nodeTypes={nodeTypes}
+ onNodesChange={onNodesChange}
+ onEdgesChange={onEdgesChange}
+ onConnect={onConnect}
+ fitView
+ // Cap the fit zoom at 1:1 so a board with a single small note is not
+ // blown up to fill the viewport.
+ fitViewOptions={{ maxZoom: 1, padding: 0.3 }}
+ // Theme the built-in controls/background to match the app theme.
+ colorMode={resolvedTheme === 'light' ? 'light' : 'dark'}
+ proOptions={{ hideAttribution: true }}
+ className="bg-background"
+ >
+ <Background />
+ <Controls />
+ </ReactFlow>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/notes/components/NotesEmptyState.tsx b/apps/web/src/features/notes/components/NotesEmptyState.tsx
new file mode 100644
index 00000000..4e6d1300
--- /dev/null
+++ b/apps/web/src/features/notes/components/NotesEmptyState.tsx
@@ -0,0 +1,44 @@
+import { useState } from 'react';
+import { Plus } from 'lucide-react';
+import { Button } from '@/components/ui/button';
+import NoteBoardNameDialog from './NoteBoardNameDialog';
+
+// Shown when a project has no note boards. Names what a board is and offers to
+// create the first one, so it is a click away instead of hidden behind the "+".
+export default function NotesEmptyState({
+ projectKey,
+ onCreate,
+}: {
+ projectKey: string;
+ onCreate: (name: string, personal: boolean) => void;
+}) {
+ const [open, setOpen] = useState(false);
+
+ return (
+ <div className="flex flex-1 flex-col items-center justify-center px-6 text-center">
+ <h2 className="text-base font-medium text-foreground">No boards yet</h2>
+ <p className="mt-1.5 max-w-xs text-sm text-muted-foreground">
+ A board is a freeform canvas for sticky notes. Create one to start jotting things down.
+ </p>
+
+ <Button className="mt-6" onClick={() => setOpen(true)}>
+ <Plus className="size-4" /> New board
+ </Button>
+
+ <NoteBoardNameDialog
+ key={open ? 'open' : 'closed'}
+ open={open}
+ title="New board"
+ description="A freeform canvas for sticky notes."
+ projectKey={projectKey}
+ initial=""
+ withVisibility
+ onClose={() => setOpen(false)}
+ onSubmit={(name, personal) => {
+ onCreate(name, personal);
+ setOpen(false);
+ }}
+ />
+ </div>
+ );
+}
diff --git a/apps/web/src/features/notes/components/StickerColorPicker.tsx b/apps/web/src/features/notes/components/StickerColorPicker.tsx
new file mode 100644
index 00000000..5cb3f4ec
--- /dev/null
+++ b/apps/web/src/features/notes/components/StickerColorPicker.tsx
@@ -0,0 +1,37 @@
+import { Circle } from '@uiw/react-color';
+import { Palette } from 'lucide-react';
+import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
+import { STICKER_PALETTE, stickerColorValue } from '../utils/stickerColors';
+
+// The background-color control in a sticker's toolbar: a palette button that opens
+// the shared color picker (@uiw/react-color) over the sticky-note palette.
+// Selecting a swatch calls onChange with the hex.
+export default function StickerColorPicker({
+ value,
+ onChange,
+}: {
+ value: string;
+ onChange: (hex: string) => void;
+}) {
+ return (
+ // Modal so an outside click on the React Flow canvas (which captures pointer
+ // events) dismisses the picker instead of being swallowed by the canvas.
+ <Popover modal>
+ <PopoverTrigger
+ aria-label="Background color"
+ title="Background color"
+ className="nodrag flex size-7 cursor-pointer items-center justify-center rounded text-black/50 hover:bg-black/10 hover:text-black/80 [&_svg]:size-3.5"
+ >
+ <Palette />
+ </PopoverTrigger>
+ <PopoverContent align="start" className="w-auto">
+ <p className="mb-2 text-sm font-medium">Background colors</p>
+ <Circle
+ colors={STICKER_PALETTE}
+ color={stickerColorValue(value)}
+ onChange={(color) => onChange(color.hex)}
+ />
+ </PopoverContent>
+ </Popover>
+ );
+}
diff --git a/apps/web/src/features/notes/components/StickerEditor.tsx b/apps/web/src/features/notes/components/StickerEditor.tsx
new file mode 100644
index 00000000..ff400551
--- /dev/null
+++ b/apps/web/src/features/notes/components/StickerEditor.tsx
@@ -0,0 +1,41 @@
+import { useEffect } from 'react';
+import { useEditor, EditorContent, type Editor } from '@tiptap/react';
+import StarterKit from '@tiptap/starter-kit';
+import Placeholder from '@tiptap/extension-placeholder';
+import TaskList from '@tiptap/extension-task-list';
+import TaskItem from '@tiptap/extension-task-item';
+import { Markdown } from 'tiptap-markdown';
+
+// The markdown body of a sticky note. Unlike the issue editor there is no bubble
+// menu — a persistent toolbar (StickerToolbar) drives the commands — and task
+// lists are enabled so a note can mix text with checkable items. Content in and
+// out is markdown, matching how it is stored on the board canvas.
+export default function StickerEditor({
+ value,
+ onChange,
+ onReady,
+}: {
+ value: string;
+ onChange: (markdown: string) => void;
+ onReady?: (editor: Editor | null) => void;
+}) {
+ const editor = useEditor({
+ extensions: [
+ StarterKit,
+ Placeholder.configure({ placeholder: 'Write a note…' }),
+ TaskList,
+ TaskItem.configure({ nested: true }),
+ Markdown.configure({ html: false, breaks: true }),
+ ],
+ content: value,
+ editorProps: { attributes: { class: 'md-content focus:outline-none' } },
+ onUpdate: ({ editor }) => onChange(editor.storage.markdown.getMarkdown()),
+ });
+
+ useEffect(() => {
+ onReady?.(editor);
+ }, [editor, onReady]);
+
+ if (!editor) return null;
+ return <EditorContent editor={editor} />;
+}
diff --git a/apps/web/src/features/notes/components/StickerNode.tsx b/apps/web/src/features/notes/components/StickerNode.tsx
new file mode 100644
index 00000000..47797929
--- /dev/null
+++ b/apps/web/src/features/notes/components/StickerNode.tsx
@@ -0,0 +1,80 @@
+import { useState } from 'react';
+import { type Editor } from '@tiptap/react';
+import { GripHorizontal } from 'lucide-react';
+import {
+ Handle,
+ Position,
+ NodeResizer,
+ useReactFlow,
+ type Node,
+ type NodeProps,
+} from '@xyflow/react';
+import type { NoteSticker } from '@/lib/api';
+import { stickerColorValue } from '../utils/stickerColors';
+import StickerEditor from './StickerEditor';
+import StickerToolbar from './StickerToolbar';
+
+export type StickerNodeType = Node<NoteSticker, 'sticker'>;
+
+// One sticky note on the canvas: a draggable, resizable card with a title, a
+// markdown body (text and checklists), and a bottom toolbar (color, bold, italic,
+// checklist, delete). Edits are written straight back into the React Flow node;
+// the canvas persists the whole board.
+export default function StickerNode({ id, data, selected }: NodeProps<StickerNodeType>) {
+ const { setNodes, setEdges } = useReactFlow();
+ const [editor, setEditor] = useState<Editor | null>(null);
+
+ const update = (patch: Partial<NoteSticker>) => {
+ setNodes((nodes) =>
+ nodes.map((n) => (n.id === id ? { ...n, data: { ...n.data, ...patch } } : n)),
+ );
+ };
+
+ const remove = () => {
+ setNodes((nodes) => nodes.filter((n) => n.id !== id));
+ setEdges((edges) => edges.filter((e) => e.source !== id && e.target !== id));
+ };
+
+ return (
+ <div
+ className="sticker-note flex h-full w-full cursor-default flex-col rounded-xl border border-black/10 p-3 text-neutral-900 shadow-lg"
+ style={{ backgroundColor: stickerColorValue(data.color) }}
+ >
+ <NodeResizer isVisible={selected} minWidth={200} minHeight={160} />
+ <Handle type="target" position={Position.Left} className="!size-2 !bg-black/40" />
+ <Handle type="source" position={Position.Right} className="!size-2 !bg-black/40" />
+
+ <div className="mb-1 flex items-center gap-2">
+ <input
+ value={data.title}
+ onChange={(e) => update({ title: e.target.value })}
+ placeholder="Title"
+ className="nodrag min-w-0 flex-1 cursor-text bg-transparent text-base font-semibold outline-none placeholder:text-black/40"
+ />
+ <span
+ className="sticker-drag cursor-grab text-black/30 hover:text-black/60 active:cursor-grabbing"
+ title="Drag note"
+ >
+ <GripHorizontal className="size-4" />
+ </span>
+ </div>
+
+ <div className="nodrag nowheel flex-1 cursor-text overflow-y-auto text-sm">
+ <StickerEditor
+ value={data.body}
+ onChange={(md) => update({ body: md })}
+ onReady={setEditor}
+ />
+ </div>
+
+ <div className="sticker-drag mt-2 cursor-grab border-t border-black/10 pt-2 active:cursor-grabbing">
+ <StickerToolbar
+ editor={editor}
+ color={data.color}
+ onColorChange={(key) => update({ color: key })}
+ onDelete={remove}
+ />
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/notes/components/StickerToolbar.tsx b/apps/web/src/features/notes/components/StickerToolbar.tsx
new file mode 100644
index 00000000..361c82c1
--- /dev/null
+++ b/apps/web/src/features/notes/components/StickerToolbar.tsx
@@ -0,0 +1,79 @@
+import { type Editor } from '@tiptap/react';
+import { Bold, Italic, ListChecks, Trash2 } from 'lucide-react';
+import { cn } from '@/lib/utils';
+import StickerColorPicker from './StickerColorPicker';
+
+function ToolbarButton({
+ active,
+ onClick,
+ label,
+ children,
+}: {
+ active?: boolean;
+ onClick: () => void;
+ label: string;
+ children: React.ReactNode;
+}) {
+ return (
+ <button
+ type="button"
+ aria-label={label}
+ title={label}
+ // Keep the editor selection when the toolbar is clicked.
+ onMouseDown={(e) => e.preventDefault()}
+ onClick={onClick}
+ className={cn(
+ 'nodrag flex size-7 cursor-pointer items-center justify-center rounded text-black/50 hover:bg-black/10 hover:text-black/80 [&_svg]:size-3.5',
+ active && 'bg-black/15 text-black',
+ )}
+ >
+ {children}
+ </button>
+ );
+}
+
+// The persistent bottom toolbar of a sticky note: background color, bold, italic,
+// a checklist toggle, and delete.
+export default function StickerToolbar({
+ editor,
+ color,
+ onColorChange,
+ onDelete,
+}: {
+ editor: Editor | null;
+ color: string;
+ onColorChange: (key: string) => void;
+ onDelete: () => void;
+}) {
+ return (
+ <div className="flex items-center justify-between">
+ <div className="flex items-center gap-0.5">
+ <StickerColorPicker value={color} onChange={onColorChange} />
+ <ToolbarButton
+ label="Bold"
+ active={editor?.isActive('bold')}
+ onClick={() => editor?.chain().focus().toggleBold().run()}
+ >
+ <Bold />
+ </ToolbarButton>
+ <ToolbarButton
+ label="Italic"
+ active={editor?.isActive('italic')}
+ onClick={() => editor?.chain().focus().toggleItalic().run()}
+ >
+ <Italic />
+ </ToolbarButton>
+ <ToolbarButton
+ label="Checklist"
+ active={editor?.isActive('taskList')}
+ onClick={() => editor?.chain().focus().toggleTaskList().run()}
+ >
+ <ListChecks />
+ </ToolbarButton>
+ </div>
+ <ToolbarButton label="Delete note" onClick={onDelete}>
+ <Trash2 />
+ </ToolbarButton>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/notes/hooks/useCanvasAutosave.ts b/apps/web/src/features/notes/hooks/useCanvasAutosave.ts
new file mode 100644
index 00000000..40a8341d
--- /dev/null
+++ b/apps/web/src/features/notes/hooks/useCanvasAutosave.ts
@@ -0,0 +1,74 @@
+import { useEffect, useMemo, useRef, useState } from 'react';
+import type { Edge } from '@xyflow/react';
+import { useSaveNoteCanvas } from '../services/noteBoards.service';
+import type { StickerNodeType } from '../components/StickerNode';
+import { toCanvas } from '../utils/noteCanvas';
+
+// 'unsaved' — edits made, not yet persisted (waiting out the debounce);
+// 'saving' — the save request is in flight; 'saved'/'error' — its result.
+export type SaveStatus = 'saved' | 'unsaved' | 'saving' | 'error';
+
+// The debounce between the last edit and the save request.
+const AUTOSAVE_DELAY = 2000;
+
+// Persist the board a while after the last change, reporting the save state so the
+// UI can show it. A change first marks the canvas 'unsaved', then after the debounce
+// the request goes out ('saving') and its result is 'saved' or 'error'. Opening a
+// board does not save it (the initial canvas matches the saved snapshot). The host
+// keys the canvas by board id, so one hook instance covers one board.
+export function useCanvasAutosave(
+ projectKey: string,
+ boardId: number,
+ nodes: StickerNodeType[],
+ edges: Edge[],
+): SaveStatus {
+ const save = useSaveNoteCanvas(projectKey);
+ const saveRef = useRef(save);
+ saveRef.current = save;
+
+ const serialized = useMemo(() => JSON.stringify(toCanvas(nodes, edges)), [nodes, edges]);
+
+ // The last canvas that was loaded or saved. A save fires only when the current
+ // canvas differs from it — so opening a board does not save (the effect running
+ // twice under StrictMode, or React Flow's post-mount node normalization, both
+ // leave the serialized canvas unchanged and are ignored).
+ const savedSnapshot = useRef(serialized);
+ const [status, setStatus] = useState<SaveStatus>('saved');
+
+ // The latest canvas, read by the unmount flush below.
+ const latest = useRef({ serialized, boardId });
+ latest.current = { serialized, boardId };
+
+ useEffect(() => {
+ if (serialized === savedSnapshot.current) return;
+ setStatus('unsaved');
+ const timer = setTimeout(() => {
+ setStatus('saving');
+ saveRef.current.mutate(
+ { boardId, canvas: JSON.parse(serialized) },
+ {
+ onSuccess: () => {
+ savedSnapshot.current = serialized;
+ setStatus('saved');
+ },
+ onError: () => setStatus('error'),
+ },
+ );
+ }, AUTOSAVE_DELAY);
+ return () => clearTimeout(timer);
+ }, [serialized, boardId]);
+
+ // Flush a still-pending edit on unmount (switching board, or leaving the page)
+ // so a change made inside the debounce window is not dropped. The debounce
+ // effect above clears its timer on unmount, so without this the save never fires.
+ useEffect(() => {
+ return () => {
+ const { serialized, boardId } = latest.current;
+ if (serialized !== savedSnapshot.current) {
+ saveRef.current.mutate({ boardId, canvas: JSON.parse(serialized) });
+ }
+ };
+ }, []);
+
+ return status;
+}
diff --git a/apps/web/src/features/notes/hooks/useNoteBoardMru.ts b/apps/web/src/features/notes/hooks/useNoteBoardMru.ts
new file mode 100644
index 00000000..04bd8ca8
--- /dev/null
+++ b/apps/web/src/features/notes/hooks/useNoteBoardMru.ts
@@ -0,0 +1,74 @@
+import { useCallback, useEffect, useState } from 'react';
+
+// The recently-opened boards backing the tab strip. Kept per project in
+// localStorage (per browser, not synced): a lightweight most-recently-used list so
+// the tabs show the last few boards without loading every board. The cached name
+// and visibility only label the tab; opening a board fetches its fresh state and
+// re-records it, which self-heals a stale label.
+export interface MruEntry {
+ id: number;
+ name: string;
+ personal: boolean;
+}
+
+const MAX = 5;
+
+function storageKey(projectKey: string) {
+ return `noteBoards:mru:${projectKey}`;
+}
+
+function isEntry(v: unknown): v is MruEntry {
+ return typeof v === 'object' && v !== null && typeof (v as MruEntry).id === 'number';
+}
+
+function read(projectKey: string): MruEntry[] {
+ if (typeof window === 'undefined') return [];
+ try {
+ const raw = window.localStorage.getItem(storageKey(projectKey));
+ const parsed: unknown = raw ? JSON.parse(raw) : [];
+ return Array.isArray(parsed) ? parsed.filter(isEntry).slice(0, MAX) : [];
+ } catch {
+ return [];
+ }
+}
+
+export function useNoteBoardMru(projectKey: string) {
+ const [entries, setEntries] = useState<MruEntry[]>(() => read(projectKey));
+
+ // Reload when switching projects — the hook instance may outlive the route.
+ useEffect(() => setEntries(read(projectKey)), [projectKey]);
+
+ const persist = useCallback(
+ (next: MruEntry[]) => {
+ if (typeof window !== 'undefined') {
+ window.localStorage.setItem(storageKey(projectKey), JSON.stringify(next));
+ }
+ return next;
+ },
+ [projectKey],
+ );
+
+ // Record an opened board. A board already in the list keeps its tab position (its
+ // label/visibility is refreshed in place, so re-opening it does not reshuffle the
+ // tabs); a new board is added to the front, capped at MAX.
+ const record = useCallback(
+ (entry: MruEntry) =>
+ setEntries((prev) => {
+ const idx = prev.findIndex((e) => e.id === entry.id);
+ if (idx !== -1) {
+ const next = [...prev];
+ next[idx] = entry;
+ return persist(next);
+ }
+ return persist([entry, ...prev].slice(0, MAX));
+ }),
+ [persist],
+ );
+
+ const remove = useCallback(
+ (id: number) => setEntries((prev) => persist(prev.filter((e) => e.id !== id))),
+ [persist],
+ );
+
+ return { entries, record, remove };
+}
diff --git a/apps/web/src/features/notes/services/noteBoards.service.ts b/apps/web/src/features/notes/services/noteBoards.service.ts
new file mode 100644
index 00000000..5022a500
--- /dev/null
+++ b/apps/web/src/features/notes/services/noteBoards.service.ts
@@ -0,0 +1,122 @@
+import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
+import {
+ api,
+ type NewNoteBoardInput,
+ type NoteBoard,
+ type NoteBoardSummary,
+ type NoteCanvas,
+} from '@/lib/api';
+import { qk } from '@/services/queryKeys';
+
+// How many boards the switcher loads per page.
+export const NOTE_BOARDS_PAGE = 10;
+
+// Invalidate every switcher/search list (but not open boards' canvases): renaming,
+// creating, deleting, or changing a board's visibility all reorder or refilter the
+// list. Scoped to the 'search' subtree so it never re-fetches (and clobbers) the
+// canvas of a board being edited.
+function invalidateSearch(qc: ReturnType<typeof useQueryClient>, projectKey: string) {
+ void qc.invalidateQueries({ queryKey: [...qk.noteBoardsForProject(projectKey), 'search'] });
+}
+
+// The board switcher list: name-filtered, paged, most-recently-updated first.
+export function useNoteBoardSearch(projectKey: string | null, q: string) {
+ return useInfiniteQuery({
+ queryKey: qk.noteBoardsSearch(projectKey ?? '', q),
+ queryFn: ({ pageParam }) =>
+ api.listNoteBoards(projectKey!, {
+ q: q || undefined,
+ limit: NOTE_BOARDS_PAGE,
+ offset: pageParam,
+ }),
+ initialPageParam: 0,
+ getNextPageParam: (lastPage, allPages) =>
+ lastPage.length < NOTE_BOARDS_PAGE ? undefined : allPages.reduce((n, p) => n + p.length, 0),
+ enabled: projectKey != null,
+ });
+}
+
+// One board with its canvas. Always refetched when opened so the canvas reflects
+// the latest server state, even after edits on another device.
+export function useNoteBoardQuery(projectKey: string | null, boardId: number | null) {
+ return useQuery({
+ queryKey: qk.noteBoard(projectKey ?? '', boardId ?? 0),
+ queryFn: () => api.getNoteBoard(projectKey!, boardId!),
+ enabled: projectKey != null && boardId != null,
+ refetchOnMount: 'always',
+ });
+}
+
+export function useCreateNoteBoard(projectKey: string | null) {
+ const qc = useQueryClient();
+ return useMutation({
+ mutationFn: (input: NewNoteBoardInput) => api.createNoteBoard(projectKey!, input),
+ onSuccess: () => {
+ if (projectKey) invalidateSearch(qc, projectKey);
+ },
+ });
+}
+
+// Renaming changes the tab/switcher list, so invalidate the search lists and write
+// the new name into the open board's cache. Canvas autosave uses useSaveNoteCanvas
+// instead, which must not refetch mid-edit.
+export function useRenameNoteBoard(projectKey: string | null) {
+ const qc = useQueryClient();
+ return useMutation({
+ mutationFn: ({ boardId, name }: { boardId: number; name: string }) =>
+ api.updateNoteBoard(projectKey!, boardId, { name }),
+ onSuccess: (updated) => {
+ if (!projectKey) return;
+ qc.setQueryData<NoteBoard>(qk.noteBoard(projectKey, updated.id), updated);
+ invalidateSearch(qc, projectKey);
+ },
+ });
+}
+
+// Toggle a board between public and personal (owned by the caller). Changes both
+// the lock icon and which list section it falls under, so refresh the lists.
+export function useSetNoteBoardVisibility(projectKey: string | null) {
+ const qc = useQueryClient();
+ return useMutation({
+ mutationFn: ({ boardId, personal }: { boardId: number; personal: boolean }) =>
+ api.updateNoteBoard(projectKey!, boardId, { personal }),
+ onSuccess: (updated) => {
+ if (!projectKey) return;
+ qc.setQueryData<NoteBoard>(qk.noteBoard(projectKey, updated.id), updated);
+ invalidateSearch(qc, projectKey);
+ },
+ });
+}
+
+export function useDeleteNoteBoard(projectKey: string | null) {
+ const qc = useQueryClient();
+ return useMutation({
+ mutationFn: (boardId: number) => api.deleteNoteBoard(projectKey!, boardId),
+ onSuccess: (_res, boardId) => {
+ if (!projectKey) return;
+ qc.removeQueries({ queryKey: qk.noteBoard(projectKey, boardId) });
+ invalidateSearch(qc, projectKey);
+ },
+ });
+}
+
+// Persist the canvas without invalidating: the editor holds the live canvas, so a
+// refetch would clobber unsaved edits. The saved canvas is written back into the
+// board's cache so a later remount reads the current state.
+export function useSaveNoteCanvas(projectKey: string | null) {
+ const qc = useQueryClient();
+ return useMutation({
+ mutationFn: ({ boardId, canvas }: { boardId: number; canvas: NoteCanvas }) =>
+ api.updateNoteBoard(projectKey!, boardId, { canvas }),
+ onSuccess: (updated) => {
+ if (!projectKey) return;
+ qc.setQueryData<NoteBoard>(qk.noteBoard(projectKey, updated.id), updated);
+ },
+ });
+}
+
+// Flatten the switcher's paged result into a single board list, so a consumer can
+// read the boards without threading useInfiniteQuery's page shape.
+export function flattenBoardPages(pages: NoteBoardSummary[][] | undefined): NoteBoardSummary[] {
+ return pages?.flat() ?? [];
+}
diff --git a/apps/web/src/features/notes/utils/noteCanvas.ts b/apps/web/src/features/notes/utils/noteCanvas.ts
new file mode 100644
index 00000000..445e7304
--- /dev/null
+++ b/apps/web/src/features/notes/utils/noteCanvas.ts
@@ -0,0 +1,57 @@
+import type { Edge } from '@xyflow/react';
+import type { NoteCanvas, NoteNode } from '@/lib/api';
+import type { StickerNodeType } from '../components/StickerNode';
+import { DEFAULT_STICKER_COLOR } from './stickerColors';
+
+// A dropped sticker drags only by its handle (see StickerNode), so text and the
+// toolbar stay interactive.
+const DRAG_HANDLE = '.sticker-drag';
+
+const DEFAULT_WIDTH = 260;
+const DEFAULT_HEIGHT = 220;
+
+// Build the React Flow nodes for a stored board. Runtime-only fields (dragHandle)
+// are re-applied here rather than persisted.
+export function toFlowNodes(canvas: NoteCanvas | undefined): StickerNodeType[] {
+ return (canvas?.nodes ?? []).map((n) => ({
+ id: n.id,
+ type: 'sticker',
+ position: n.position,
+ width: n.width ?? DEFAULT_WIDTH,
+ height: n.height ?? DEFAULT_HEIGHT,
+ dragHandle: DRAG_HANDLE,
+ data: n.data,
+ }));
+}
+
+export function toFlowEdges(canvas: NoteCanvas | undefined): Edge[] {
+ return (canvas?.edges ?? []).map((e) => ({ id: e.id, source: e.source, target: e.target }));
+}
+
+// Reduce the live React Flow state to the persisted shape, dropping runtime fields
+// (selection, drag state, measured sizes) so saves stay stable.
+export function toCanvas(nodes: StickerNodeType[], edges: Edge[]): NoteCanvas {
+ return {
+ nodes: nodes.map((n): NoteNode => ({
+ id: n.id,
+ type: 'sticker',
+ position: n.position,
+ width: n.width ?? DEFAULT_WIDTH,
+ height: n.height ?? DEFAULT_HEIGHT,
+ data: n.data,
+ })),
+ edges: edges.map((e) => ({ id: e.id, source: e.source, target: e.target })),
+ };
+}
+
+export function newSticker(position: { x: number; y: number }): StickerNodeType {
+ return {
+ id: crypto.randomUUID(),
+ type: 'sticker',
+ position,
+ width: DEFAULT_WIDTH,
+ height: DEFAULT_HEIGHT,
+ dragHandle: DRAG_HANDLE,
+ data: { title: '', body: '', color: DEFAULT_STICKER_COLOR },
+ };
+}
diff --git a/apps/web/src/features/notes/utils/stickerColors.ts b/apps/web/src/features/notes/utils/stickerColors.ts
new file mode 100644
index 00000000..9b418de9
--- /dev/null
+++ b/apps/web/src/features/notes/utils/stickerColors.ts
@@ -0,0 +1,21 @@
+// Sticky-note background colors, Miro-style: light pastels on the dark canvas.
+// The sticker stores the hex directly; a new note defaults to yellow. Legacy or
+// empty values fall back to the default so old data keeps rendering.
+export const STICKER_PALETTE = [
+ '#FFF9B1', // yellow (default)
+ '#D5F692', // green
+ '#A6D3F5', // blue
+ '#F7C1D9', // pink
+ '#FFD59E', // orange
+ '#D0BFFF', // purple
+ '#A8E6D8', // teal
+ '#E4E4E7', // grey
+];
+
+export const DEFAULT_STICKER_COLOR = STICKER_PALETTE[0];
+
+// The color a sticker renders with. Only a hex is honored; anything else (empty,
+// or a legacy key) falls back to the default.
+export function stickerColorValue(color: string): string {
+ return /^#[0-9a-fA-F]{6}$/.test(color) ? color : DEFAULT_STICKER_COLOR;
+}
diff --git a/apps/web/src/lib/api.ts b/apps/web/src/lib/api.ts
index c5dad79e..5d9f59c2 100644
--- a/apps/web/src/lib/api.ts
+++ b/apps/web/src/lib/api.ts
@@ -915,6 +915,77 @@ export interface DashboardPatch {
layout?: DashboardLayout;
}
+// --- Note board DTOs -------------------------------------------------------------
+
+// One sticky note on the canvas. body is markdown (may contain task-list items).
+// color keys a background swatch defined by the UI. Declared as a type alias (not
+// an interface) so it carries an implicit index signature and satisfies React
+// Flow's Node data constraint (Record<string, unknown>).
+export type NoteSticker = {
+ title: string;
+ body: string;
+ color: string;
+};
+
+// A React Flow node holding a sticker. Kept structurally compatible with React
+// Flow's Node so the canvas can use it directly.
+export interface NoteNode {
+ id: string;
+ type: 'sticker';
+ position: { x: number; y: number };
+ width?: number;
+ height?: number;
+ data: NoteSticker;
+}
+
+// A connection between two stickers (React Flow edge).
+export interface NoteEdge {
+ id: string;
+ source: string;
+ target: string;
+}
+
+// The board canvas, stored verbatim as jsonb on the server.
+export interface NoteCanvas {
+ nodes: NoteNode[];
+ edges: NoteEdge[];
+}
+
+export interface NoteBoard {
+ id: number;
+ projectId: number;
+ // null for a public board (every member sees it); a user id for a personal
+ // board only its owner sees.
+ ownerUserId: string | null;
+ name: string;
+ canvas: NoteCanvas;
+ createdAt: string;
+ updatedAt: string;
+}
+
+// A board without its canvas — what the switcher and MRU tabs list. The canvas is
+// loaded one board at a time via getNoteBoard when the board is opened.
+export type NoteBoardSummary = Omit<NoteBoard, 'canvas'>;
+
+export interface NewNoteBoardInput {
+ name: string;
+ personal?: boolean;
+ canvas?: NoteCanvas;
+}
+
+export interface NoteBoardPatch {
+ name?: string;
+ canvas?: NoteCanvas;
+ // Sets the board's visibility: true makes it personal to the caller, false public.
+ personal?: boolean;
+}
+
+export interface NoteBoardListParams {
+ q?: string;
+ limit?: number;
+ offset?: number;
+}
+
// --- Analytics DTOs (project metrics behind the dashboard widgets) ---------------
export interface AnalyticsStats {
@@ -1802,6 +1873,32 @@ export const api = {
body: JSON.stringify({ orderedIds }),
}),
+ // Note boards — all ops are project-scoped (a personal board is filtered to its
+ // owner server-side), so board ops take projectKey plus the board id. The list
+ // is paged and searchable (switcher); a single board carries its canvas.
+ listNoteBoards: (projectKey: string, params: NoteBoardListParams = {}) => {
+ const qs = new URLSearchParams();
+ if (params.q) qs.set('q', params.q);
+ if (params.limit != null) qs.set('limit', String(params.limit));
+ if (params.offset != null) qs.set('offset', String(params.offset));
+ const suffix = qs.toString() ? `?${qs}` : '';
+ return request<NoteBoardSummary[]>(`/projects/${projectKey}/note-boards${suffix}`);
+ },
+ getNoteBoard: (projectKey: string, boardId: number) =>
+ request<NoteBoard>(`/projects/${projectKey}/note-boards/${boardId}`),
+ createNoteBoard: (projectKey: string, input: NewNoteBoardInput) =>
+ request<NoteBoard>(`/projects/${projectKey}/note-boards`, {
+ method: 'POST',
+ body: JSON.stringify(input),
+ }),
+ updateNoteBoard: (projectKey: string, boardId: number, patch: NoteBoardPatch) =>
+ request<NoteBoard>(`/projects/${projectKey}/note-boards/${boardId}`, {
+ method: 'PATCH',
+ body: JSON.stringify(patch),
+ }),
+ deleteNoteBoard: (projectKey: string, boardId: number) =>
+ request<void>(`/projects/${projectKey}/note-boards/${boardId}`, { method: 'DELETE' }),
+
// Analytics — read-only project metrics behind the dashboard widgets.
getStats: (projectKey: string) =>
request<AnalyticsStats>(`/projects/${projectKey}/analytics/stats`),
diff --git a/apps/web/src/services/queryKeys.ts b/apps/web/src/services/queryKeys.ts
index 94d9a6f7..1e603a93 100644
--- a/apps/web/src/services/queryKeys.ts
+++ b/apps/web/src/services/queryKeys.ts
@@ -24,6 +24,14 @@ export const qk = {
// widgets. `kind` names the metric (stats/pulse/throughput/breakdown/...) and
// `params` scopes it to the widget's query (window, filters).
dashboards: (projectKey: string) => ['dashboards', projectKey] as const,
+ // Note boards (the notes canvases). `noteBoardsForProject` is the invalidation
+ // base for every list/search variant; `noteBoardsSearch` is one paged switcher
+ // query (scoped by search text); `noteBoard` is a single board with its canvas.
+ noteBoardsForProject: (projectKey: string) => ['noteBoards', projectKey] as const,
+ noteBoardsSearch: (projectKey: string, q: string) =>
+ ['noteBoards', projectKey, 'search', q] as const,
+ noteBoard: (projectKey: string, boardId: number) =>
+ ['noteBoards', projectKey, 'board', boardId] as const,
analytics: (projectKey: string, kind: string, params?: unknown) =>
['analytics', projectKey, kind, params ?? {}] as const,
analyticsForProject: (projectKey: string) => ['analytics', projectKey] as const,
diff --git a/apps/web/src/utils/paths.ts b/apps/web/src/utils/paths.ts
index bfe89a30..ae7df104 100644
--- a/apps/web/src/utils/paths.ts
+++ b/apps/web/src/utils/paths.ts
@@ -13,6 +13,10 @@ export const dashboardsPath = (key: string) => `${projectPath(key)}/dashboard`;
export const dashboardPath = (key: string, dashboardId: number) =>
`${dashboardsPath(key)}/${dashboardId}`;
+export const notesPath = (key: string) => `${projectPath(key)}/notes`;
+
+export const notePath = (key: string, boardId: number) => `${notesPath(key)}/${boardId}`;
+
export const settingsPath = (key: string, section: string) =>
`${projectPath(key)}/settings/${section}`;
diff --git a/bun.lock b/bun.lock
index 4da4a2cc..1d4f026c 100644
--- a/bun.lock
+++ b/bun.lock
@@ -87,10 +87,13 @@
"@tiptap/extension-image": "^3.27.3",
"@tiptap/extension-link": "^3.27.3",
"@tiptap/extension-placeholder": "^3.27.3",
+ "@tiptap/extension-task-item": "^3.27.3",
+ "@tiptap/extension-task-list": "^3.27.3",
"@tiptap/pm": "^3.27.3",
"@tiptap/react": "^3.27.3",
"@tiptap/starter-kit": "^3.27.3",
"@uiw/react-color": "^2.10.3",
+ "@xyflow/react": "^12.11.2",
"better-auth": "^1.3.4",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
@@ -987,6 +990,10 @@
"@tiptap/extension-strike": ["@tiptap/[email protected]", "", { "peerDependencies": { "@tiptap/core": "3.27.3" } }, "sha512-dp6Rs3I4zLVJPvAw2Q9yrNuYKcX5LTONH3/oyULvGsrqq5DKz7pqscfwhwnDSzrgm/3aCz6B9r1BVHlYI/DXlA=="],
+ "@tiptap/extension-task-item": ["@tiptap/[email protected]", "", { "peerDependencies": { "@tiptap/extension-list": "3.28.0" } }, "sha512-jLOk+CaPR8DzTFe+qdB78OxCPyb2TLISNWGL3zZvDSvngwCuQYYibcAa2L6yYN3bpooNKc3nY+kCfdevI/v21w=="],
+
+ "@tiptap/extension-task-list": ["@tiptap/[email protected]", "", { "peerDependencies": { "@tiptap/extension-list": "3.28.0" } }, "sha512-j13v2WoGVOGrkM5sXibos/ojUPila+yLQwduqI3+bFstsOXied224atL/76db5Y4vGnwwc4V5Kiqj7DMV7Ypiw=="],
+
"@tiptap/extension-text": ["@tiptap/[email protected]", "", { "peerDependencies": { "@tiptap/core": "3.27.3" } }, "sha512-wSatZ/bop0pleeC18nF90zvWWEoRe/ewZncvm8LjcMrXwq41kTEs3j7nZflMYAh7X8fZvu00UIMeEyCNJl+5Yg=="],
"@tiptap/extension-underline": ["@tiptap/[email protected]", "", { "peerDependencies": { "@tiptap/core": "3.27.3" } }, "sha512-YH7ka/Rp7ZwlzTuQCcs0OZ4CMSx/P/MzbseQKxKebEIZreWaKMZAaED97Fnu0dA66VlreD4/1C7xHJy84ovamg=="],
@@ -1021,6 +1028,8 @@
"@types/d3-color": ["@types/[email protected]", "", {}, "sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A=="],
+ "@types/d3-drag": ["@types/[email protected]", "", { "dependencies": { "@types/d3-selection": "*" } }, "sha512-HE3jVKlzU9AaMazNufooRJ5ZpWmLIoc90A37WU2JMmeq28w1FQqCZswHZ3xR+SuxYftzHq6WU6KJHvqxKzTxxQ=="],
+
"@types/d3-ease": ["@types/[email protected]", "", {}, "sha512-NcV1JjO5oDzoK26oMzbILE6HW7uVXOHLQvHshBUW4UMdZGfiY6v5BeQwh9a9tCzv+CeefZQHJt5SRgK154RtiA=="],
"@types/d3-interpolate": ["@types/[email protected]", "", { "dependencies": { "@types/d3-color": "*" } }, "sha512-mgLPETlrpVV1YRJIglr4Ez47g7Yxjl1lj7YKsiMCb27VJH9W8NVM6Bb9d8kkpG/uAQS5AmbA48q2IAolKKo1MA=="],
@@ -1029,12 +1038,18 @@
"@types/d3-scale": ["@types/[email protected]", "", { "dependencies": { "@types/d3-time": "*" } }, "sha512-dLmtwB8zkAeO/juAMfnV+sItKjlsw2lKdZVVy6LRr0cBmegxSABiLEpGVmSJJ8O08i4+sGR6qQtb6WtuwJdvVw=="],
+ "@types/d3-selection": ["@types/[email protected]", "", {}, "sha512-bhAXu23DJWsrI45xafYpkQ4NtcKMwWnAC/vKrd2l+nxMFuvOT3XMYTIj2opv8vq8AO5Yh7Qac/nSeP/3zjTK0w=="],
+
"@types/d3-shape": ["@types/[email protected]", "", { "dependencies": { "@types/d3-path": "*" } }, "sha512-lae0iWfcDeR7qt7rA88BNiqdvPS5pFVPpo5OfjElwNaT2yyekbM0C9vK+yqBqEmHr6lDkRnYNoTBYlAgJa7a4w=="],
"@types/d3-time": ["@types/[email protected]", "", {}, "sha512-yuzZug1nkAAaBlBBikKZTgzCeA+k1uy4ZFwWANOfKw5z5LRhV0gNA7gNkKm7HoK+HRN0wX3EkxGk0fpbWhmB7g=="],
"@types/d3-timer": ["@types/[email protected]", "", {}, "sha512-Ps3T8E8dZDam6fUyNiMkekK3XUsaUEik+idO9/YjPtfj2qruF8tFBXS7XhtE4iIXBLxhmLjP3SXpLhVf21I9Lw=="],
+ "@types/d3-transition": ["@types/[email protected]", "", { "dependencies": { "@types/d3-selection": "*" } }, "sha512-uZS5shfxzO3rGlu0cC3bjmMFKsXv+SmZZcgp0KD22ts4uGXp5EVYGzu/0YdwZeKmddhcAccYtREJKkPfXkZuCg=="],
+
+ "@types/d3-zoom": ["@types/[email protected]", "", { "dependencies": { "@types/d3-interpolate": "*", "@types/d3-selection": "*" } }, "sha512-iqMC4/YlFCSlO8+2Ii1GGGliCAY4XdeG748w5vQUbevlbDu0zSjH/+jojorQVBK/se0j6DUFNPBGSqD3YWYnDw=="],
+
"@types/debug": ["@types/[email protected]", "", { "dependencies": { "@types/ms": "*" } }, "sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw=="],
"@types/estree": ["@types/[email protected]", "", {}, "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg=="],
@@ -1171,6 +1186,10 @@
"@workflow/serde": ["@workflow/[email protected]", "", {}, "sha512-pav4F2BoirECWR7Nf1TKt+2eETcBj7jj4cBefQ8VXQCA6NPkaKeLfj/zMgi+3zYV5ZIBT4GuUiphsj0/b9hPQQ=="],
+ "@xyflow/react": ["@xyflow/[email protected]", "", { "dependencies": { "@xyflow/system": "0.0.79", "classcat": "^5.0.3", "zustand": "^4.4.0" }, "peerDependencies": { "@types/react": ">=17", "@types/react-dom": ">=17", "react": ">=17", "react-dom": ">=17" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-eLAlDWJfWnQEhJwGMjlWdAXO9eYllKpliUmPQlAmOLxz6mExXuzMVDUKLMquixgkrtmMFFtug3jGKmYYld12cA=="],
+
+ "@xyflow/system": ["@xyflow/[email protected]", "", { "dependencies": { "@types/d3-drag": "^3.0.7", "@types/d3-interpolate": "^3.0.4", "@types/d3-selection": "^3.0.10", "@types/d3-transition": "^3.0.8", "@types/d3-zoom": "^3.0.8", "d3-drag": "^3.0.0", "d3-interpolate": "^3.0.1", "d3-selection": "^3.0.0", "d3-zoom": "^3.0.0" } }, "sha512-czLyOh91NF0hIzbNzwi8I6GlqG23BHh2435OddfI6uiaLH3xdrdygO93gqgH1Bv9mhy8XPFQJOBn1FTq4LvEWA=="],
+
"abort-controller": ["[email protected]", "", { "dependencies": { "event-target-shim": "^5.0.0" } }, "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg=="],
"accepts": ["[email protected]", "", { "dependencies": { "mime-types": "^3.0.0", "negotiator": "^1.0.0" } }, "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng=="],
@@ -1265,6 +1284,8 @@
"class-variance-authority": ["[email protected]", "", { "dependencies": { "clsx": "^2.1.1" } }, "sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg=="],
+ "classcat": ["[email protected]", "", {}, "sha512-JhZUT7JFcQy/EzW605k/ktHtncoo9vnyW/2GspNYwFlN1C/WmjuV/xtS04e9SOkL2sTdw0VAZ2UGCcQ9lR6p6w=="],
+
"client-only": ["[email protected]", "", {}, "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA=="],
"clsx": ["[email protected]", "", {}, "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA=="],
@@ -1311,6 +1332,10 @@
"d3-color": ["[email protected]", "", {}, "sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA=="],
+ "d3-dispatch": ["[email protected]", "", {}, "sha512-rzUyPU/S7rwUflMyLc1ETDeBj0NRuHKKAcvukozwhshr6g6c5d8zh4c2gQjY2bZ0dXeGLWc1PF174P2tVvKhfg=="],
+
+ "d3-drag": ["[email protected]", "", { "dependencies": { "d3-dispatch": "1 - 3", "d3-selection": "3" } }, "sha512-pWbUJLdETVA8lQNJecMxoXfH6x+mO2UQo8rSmZ+QqxcbyA3hfeprFgIT//HW2nlHChWeIIMwS2Fq+gEARkhTkg=="],
+
"d3-ease": ["[email protected]", "", {}, "sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w=="],
"d3-format": ["[email protected]", "", {}, "sha512-AJDdYOdnyRDV5b6ArilzCPPwc1ejkHcoyFarqlPqT7zRYjhavcT3uSrqcMvsgh2CgoPbK3RCwyHaVyxYcP2Arg=="],
@@ -1321,6 +1346,8 @@
"d3-scale": ["[email protected]", "", { "dependencies": { "d3-array": "2.10.0 - 3", "d3-format": "1 - 3", "d3-interpolate": "1.2.0 - 3", "d3-time": "2.1.1 - 3", "d3-time-format": "2 - 4" } }, "sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ=="],
+ "d3-selection": ["[email protected]", "", {}, "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ=="],
+
"d3-shape": ["[email protected]", "", { "dependencies": { "d3-path": "^3.1.0" } }, "sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA=="],
"d3-time": ["[email protected]", "", { "dependencies": { "d3-array": "2 - 3" } }, "sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q=="],
@@ -1329,6 +1356,10 @@
"d3-timer": ["[email protected]", "", {}, "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA=="],
+ "d3-transition": ["[email protected]", "", { "dependencies": { "d3-color": "1 - 3", "d3-dispatch": "1 - 3", "d3-ease": "1 - 3", "d3-interpolate": "1 - 3", "d3-timer": "1 - 3" }, "peerDependencies": { "d3-selection": "2 - 3" } }, "sha512-ApKvfjsSR6tg06xrL434C0WydLr7JewBB3V+/39RMHsaXTOG0zmt/OAXeng5M5LBm0ojmxJrpomQVZ1aPvBL4w=="],
+
+ "d3-zoom": ["[email protected]", "", { "dependencies": { "d3-dispatch": "1 - 3", "d3-drag": "2 - 3", "d3-interpolate": "1 - 3", "d3-selection": "2 - 3", "d3-transition": "2 - 3" } }, "sha512-b8AmV3kfQaqWAuacbPuNbL6vahnOJflOhexLzMMNLga62+/nh0JzvJ0aO/5a5MVgUFGS7Hu1P9P03o3fJkDCyw=="],
+
"data-urls": ["[email protected]", "", { "dependencies": { "whatwg-mimetype": "^5.0.0", "whatwg-url": "^16.0.0" } }, "sha512-23XHcCF+coGYevirZceTVD7NdJOqVn+49IHyxgszm+JIiHLoB2TkmPtsYkNWT1pvRSGkc35L6NHs0yHkN2SumA=="],
"data-view-buffer": ["[email protected]", "", { "dependencies": { "call-bound": "^1.0.3", "es-errors": "^1.3.0", "is-data-view": "^1.0.2" } }, "sha512-EmKO5V3OLXh1rtK2wgXRansaK1/mtVdTUEiEI0W8RkvgT05kfxaH29PliLnpLP73yYO6142Q72QNa8Wx/A5CqQ=="],
@@ -2505,6 +2536,8 @@
"zod-to-json-schema": ["[email protected]", "", { "peerDependencies": { "zod": "^3.25.28 || ^4" } }, "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA=="],
+ "zustand": ["[email protected]", "", { "dependencies": { "use-sync-external-store": "^1.2.2" }, "peerDependencies": { "@types/react": ">=16.8", "immer": ">=9.0.6", "react": ">=16.8" }, "optionalPeers": ["@types/react", "immer", "react"] }, "sha512-CHOUy7mu3lbD6o6LJLfllpjkzhHXSBlX8B9+qPddUsIfeF5S/UZ5q0kmCsnRqT1UHFQZchNFDDzMbQsuesHWlw=="],
+
"zwitch": ["[email protected]", "", {}, "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A=="],
"@ai-sdk/gateway/@ai-sdk/provider": ["@ai-sdk/[email protected]", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-HrEmNt/BH/hkQ7zpi2o6N3k1ZR1QTb7z85WYhYygiTxOQuaml4CMtHCWRbric5WPU+RNsYI7r1EpyVQMKO1pYw=="],
diff --git a/packages/db/drizzle/0048_gigantic_starjammers.sql b/packages/db/drizzle/0048_gigantic_starjammers.sql
new file mode 100644
index 00000000..00124659
--- /dev/null
+++ b/packages/db/drizzle/0048_gigantic_starjammers.sql
@@ -0,0 +1,13 @@
+CREATE TABLE "note_board" (
+ "id" serial PRIMARY KEY NOT NULL,
+ "project_id" integer NOT NULL,
+ "owner_user_id" text,
+ "name" text NOT NULL,
+ "canvas" jsonb DEFAULT '{}'::jsonb NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
+);
+--> statement-breakpoint
+ALTER TABLE "note_board" ADD CONSTRAINT "note_board_project_id_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "note_board" ADD CONSTRAINT "note_board_owner_user_id_user_id_fk" FOREIGN KEY ("owner_user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+CREATE INDEX "note_board_project_idx" ON "note_board" USING btree ("project_id","updated_at");
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0048_snapshot.json b/packages/db/drizzle/meta/0048_snapshot.json
new file mode 100644
index 00000000..a79f4908
--- /dev/null
+++ b/packages/db/drizzle/meta/0048_snapshot.json
@@ -0,0 +1,5203 @@
+{
+ "id": "493ed42a-d68c-4850-a57a-c2694897cbb0",
+ "prevId": "56b95064-ff4e-4b15-a3b2-c9a487b1c3b6",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "account_userId_idx": {
+ "name": "account_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.apikey": {
+ "name": "apikey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'default'"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start": {
+ "name": "start",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prefix": {
+ "name": "prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refill_interval": {
+ "name": "refill_interval",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refill_amount": {
+ "name": "refill_amount",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_refill_at": {
+ "name": "last_refill_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "rate_limit_enabled": {
+ "name": "rate_limit_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "rate_limit_time_window": {
+ "name": "rate_limit_time_window",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 86400000
+ },
+ "rate_limit_max": {
+ "name": "rate_limit_max",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 10
+ },
+ "request_count": {
+ "name": "request_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "remaining": {
+ "name": "remaining",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_request": {
+ "name": "last_request",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "apikey_configId_idx": {
+ "name": "apikey_configId_idx",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_referenceId_idx": {
+ "name": "apikey_referenceId_idx",
+ "columns": [
+ {
+ "expression": "reference_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_key_idx": {
+ "name": "apikey_key_idx",
+ "columns": [
+ {
+ "expression": "key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.passkey": {
+ "name": "passkey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "public_key": {
+ "name": "public_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "counter": {
+ "name": "counter",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_type": {
+ "name": "device_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "backed_up": {
+ "name": "backed_up",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transports": {
+ "name": "transports",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "aaguid": {
+ "name": "aaguid",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "passkey_userId_idx": {
+ "name": "passkey_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "passkey_credentialID_idx": {
+ "name": "passkey_credentialID_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "passkey_user_id_user_id_fk": {
+ "name": "passkey_user_id_user_id_fk",
+ "tableFrom": "passkey",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "session_userId_idx": {
+ "name": "session_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'user'"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verification": {
+ "name": "verification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verification_identifier_idx": {
+ "name": "verification_identifier_idx",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_run": {
+ "name": "agent_run",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schedule_id": {
+ "name": "schedule_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trigger": {
+ "name": "trigger",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'delegation'"
+ },
+ "scheduled_for": {
+ "name": "scheduled_for",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_activity_id": {
+ "name": "source_activity_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_run_schedule_fire_uq": {
+ "name": "agent_run_schedule_fire_uq",
+ "columns": [
+ {
+ "expression": "schedule_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scheduled_for",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_run_due_idx": {
+ "name": "agent_run_due_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_run_schedule_idx": {
+ "name": "agent_run_schedule_idx",
+ "columns": [
+ {
+ "expression": "schedule_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_run_agent_id_ai_agent_id_fk": {
+ "name": "agent_run_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_run",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_run_issue_id_issue_id_fk": {
+ "name": "agent_run_issue_id_issue_id_fk",
+ "tableFrom": "agent_run",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_run_schedule_id_agent_schedule_id_fk": {
+ "name": "agent_run_schedule_id_agent_schedule_id_fk",
+ "tableFrom": "agent_run",
+ "tableTo": "agent_schedule",
+ "columnsFrom": [
+ "schedule_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_run_source_activity_id_issue_activity_id_fk": {
+ "name": "agent_run_source_activity_id_issue_activity_id_fk",
+ "tableFrom": "agent_run",
+ "tableTo": "issue_activity",
+ "columnsFrom": [
+ "source_activity_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_run_status_check": {
+ "name": "agent_run_status_check",
+ "value": "\"agent_run\".\"status\" IN ('pending', 'success', 'failed')"
+ },
+ "agent_run_trigger_check": {
+ "name": "agent_run_trigger_check",
+ "value": "\"agent_run\".\"trigger\" IN ('mention', 'delegation', 'schedule', 'manual')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_schedule": {
+ "name": "agent_schedule",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cron": {
+ "name": "cron",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "timezone": {
+ "name": "timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "next_run_at": {
+ "name": "next_run_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_run_at": {
+ "name": "last_run_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_schedule_due_idx": {
+ "name": "agent_schedule_due_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_run_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_schedule_agent_idx": {
+ "name": "agent_schedule_agent_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_schedule_agent_id_ai_agent_id_fk": {
+ "name": "agent_schedule_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_schedule",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_schedule_agent_id_name_unique": {
+ "name": "agent_schedule_agent_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "agent_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "agent_schedule_status_check": {
+ "name": "agent_schedule_status_check",
+ "value": "\"agent_schedule\".\"status\" IN ('active', 'paused')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_skill": {
+ "name": "agent_skill",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "s3_prefix": {
+ "name": "s3_prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "files": {
+ "name": "files",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_skill_project_idx": {
+ "name": "agent_skill_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_skill_project_id_project_id_fk": {
+ "name": "agent_skill_project_id_project_id_fk",
+ "tableFrom": "agent_skill",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_skill_project_id_name_unique": {
+ "name": "agent_skill_project_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "agent_skill_source_check": {
+ "name": "agent_skill_source_check",
+ "value": "\"agent_skill\".\"source\" IN ('upload', 'inline', 'github')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_skill_link": {
+ "name": "agent_skill_link",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "skill_id": {
+ "name": "skill_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "agent_skill_link_skill_idx": {
+ "name": "agent_skill_link_skill_idx",
+ "columns": [
+ {
+ "expression": "skill_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_skill_link_agent_id_ai_agent_id_fk": {
+ "name": "agent_skill_link_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_skill_link",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_skill_link_skill_id_agent_skill_id_fk": {
+ "name": "agent_skill_link_skill_id_agent_skill_id_fk",
+ "tableFrom": "agent_skill_link",
+ "tableTo": "agent_skill",
+ "columnsFrom": [
+ "skill_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_skill_link_agent_id_skill_id_pk": {
+ "name": "agent_skill_link_agent_id_skill_id_pk",
+ "columns": [
+ "agent_id",
+ "skill_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_tool": {
+ "name": "agent_tool",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tool_key": {
+ "name": "tool_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_tool_project_idx": {
+ "name": "agent_tool_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_tool_credential_idx": {
+ "name": "agent_tool_credential_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_tool_project_id_project_id_fk": {
+ "name": "agent_tool_project_id_project_id_fk",
+ "tableFrom": "agent_tool",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_tool_credential_id_integration_credential_id_fk": {
+ "name": "agent_tool_credential_id_integration_credential_id_fk",
+ "tableFrom": "agent_tool",
+ "tableTo": "integration_credential",
+ "columnsFrom": [
+ "credential_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_tool_project_id_tool_key_credential_id_unique": {
+ "name": "agent_tool_project_id_tool_key_credential_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "tool_key",
+ "credential_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_tool_link": {
+ "name": "agent_tool_link",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_tool_id": {
+ "name": "agent_tool_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "agent_tool_link_tool_idx": {
+ "name": "agent_tool_link_tool_idx",
+ "columns": [
+ {
+ "expression": "agent_tool_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_tool_link_agent_id_ai_agent_id_fk": {
+ "name": "agent_tool_link_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_tool_link",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_tool_link_agent_tool_id_agent_tool_id_fk": {
+ "name": "agent_tool_link_agent_tool_id_agent_tool_id_fk",
+ "tableFrom": "agent_tool_link",
+ "tableTo": "agent_tool",
+ "columnsFrom": [
+ "agent_tool_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_tool_link_agent_id_agent_tool_id_pk": {
+ "name": "agent_tool_link_agent_id_agent_tool_id_pk",
+ "columns": [
+ "agent_id",
+ "agent_tool_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.ai_agent": {
+ "name": "ai_agent",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "username": {
+ "name": "username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model_credential_id": {
+ "name": "model_credential_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instructions": {
+ "name": "instructions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tools": {
+ "name": "tools",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "temperature": {
+ "name": "temperature",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "max_steps": {
+ "name": "max_steps",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trigger_on_mention": {
+ "name": "trigger_on_mention",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "trigger_on_assign": {
+ "name": "trigger_on_assign",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "role_id": {
+ "name": "role_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_key_ciphertext": {
+ "name": "api_key_ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_key_iv": {
+ "name": "api_key_iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_key_auth_tag": {
+ "name": "api_key_auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "memory_enabled": {
+ "name": "memory_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "memory_last_messages": {
+ "name": "memory_last_messages",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "ai_agent_project_idx": {
+ "name": "ai_agent_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "ai_agent_project_id_project_id_fk": {
+ "name": "ai_agent_project_id_project_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ai_agent_user_id_user_id_fk": {
+ "name": "ai_agent_user_id_user_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ai_agent_model_credential_id_integration_credential_id_fk": {
+ "name": "ai_agent_model_credential_id_integration_credential_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "integration_credential",
+ "columnsFrom": [
+ "model_credential_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "ai_agent_role_id_project_role_id_fk": {
+ "name": "ai_agent_role_id_project_role_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "project_role",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "ai_agent_project_id_username_unique": {
+ "name": "ai_agent_project_id_username_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "username"
+ ]
+ },
+ "ai_agent_user_id_unique": {
+ "name": "ai_agent_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "ai_agent_kind_check": {
+ "name": "ai_agent_kind_check",
+ "value": "\"ai_agent\".\"kind\" IN ('external', 'internal')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.app_secret": {
+ "name": "app_secret",
+ "schema": "",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "ciphertext": {
+ "name": "ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "iv": {
+ "name": "iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_tag": {
+ "name": "auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redacted": {
+ "name": "redacted",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.app_setting": {
+ "name": "app_setting",
+ "schema": "",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.custom_field": {
+ "name": "custom_field",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_type_id": {
+ "name": "issue_type_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_type": {
+ "name": "field_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "show_in_body": {
+ "name": "show_in_body",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "custom_field_project_id_project_id_fk": {
+ "name": "custom_field_project_id_project_id_fk",
+ "tableFrom": "custom_field",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "custom_field_issue_type_id_issue_type_id_fk": {
+ "name": "custom_field_issue_type_id_issue_type_id_fk",
+ "tableFrom": "custom_field",
+ "tableTo": "issue_type",
+ "columnsFrom": [
+ "issue_type_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "custom_field_field_type_check": {
+ "name": "custom_field_field_type_check",
+ "value": "\"custom_field\".\"field_type\" IN ('text', 'markdown', 'url', 'number', 'boolean', 'date', 'select', 'multi_select')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.custom_field_option": {
+ "name": "custom_field_option",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#6b7280'"
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "custom_field_option_field_id_custom_field_id_fk": {
+ "name": "custom_field_option_field_id_custom_field_id_fk",
+ "tableFrom": "custom_field_option",
+ "tableTo": "custom_field",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "custom_field_option_field_id_value_unique": {
+ "name": "custom_field_option_field_id_value_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "field_id",
+ "value"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.initiative": {
+ "name": "initiative",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'planned'"
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start_date": {
+ "name": "start_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_date": {
+ "name": "target_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "initiative_project_idx": {
+ "name": "initiative_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "initiative_project_id_project_id_fk": {
+ "name": "initiative_project_id_project_id_fk",
+ "tableFrom": "initiative",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "initiative_owner_user_id_user_id_fk": {
+ "name": "initiative_owner_user_id_user_id_fk",
+ "tableFrom": "initiative",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "initiative_status_check": {
+ "name": "initiative_status_check",
+ "value": "\"initiative\".\"status\" IN ('proposed', 'planned', 'active', 'completed', 'canceled')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.initiative_label": {
+ "name": "initiative_label",
+ "schema": "",
+ "columns": {
+ "initiative_id": {
+ "name": "initiative_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label_id": {
+ "name": "label_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "initiative_label_initiative_id_initiative_id_fk": {
+ "name": "initiative_label_initiative_id_initiative_id_fk",
+ "tableFrom": "initiative_label",
+ "tableTo": "initiative",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "initiative_label_label_id_label_id_fk": {
+ "name": "initiative_label_label_id_label_id_fk",
+ "tableFrom": "initiative_label",
+ "tableTo": "label",
+ "columnsFrom": [
+ "label_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "initiative_label_initiative_id_label_id_pk": {
+ "name": "initiative_label_initiative_id_label_id_pk",
+ "columns": [
+ "initiative_id",
+ "label_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.integration_credential": {
+ "name": "integration_credential",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "integration_key": {
+ "name": "integration_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label": {
+ "name": "label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ciphertext": {
+ "name": "ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "iv": {
+ "name": "iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_tag": {
+ "name": "auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redacted": {
+ "name": "redacted",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "integration_credential_project_idx": {
+ "name": "integration_credential_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "integration_credential_project_id_project_id_fk": {
+ "name": "integration_credential_project_id_project_id_fk",
+ "tableFrom": "integration_credential",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue": {
+ "name": "issue",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence_number": {
+ "name": "sequence_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type_id": {
+ "name": "type_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "initiative_id": {
+ "name": "initiative_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "column_id": {
+ "name": "column_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "assignee_user_id": {
+ "name": "assignee_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "delegate_user_id": {
+ "name": "delegate_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start_date": {
+ "name": "start_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "due_date": {
+ "name": "due_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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": {}
+ }
+ },
+ "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_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_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_project_id_sequence_number_unique": {
+ "name": "issue_project_id_sequence_number_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "sequence_number"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_activity": {
+ "name": "issue_activity",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "initiative_id": {
+ "name": "initiative_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "subject": {
+ "name": "subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "from_text": {
+ "name": "from_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "to_text": {
+ "name": "to_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_activity_issue_idx": {
+ "name": "issue_activity_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_activity_initiative_idx": {
+ "name": "issue_activity_initiative_idx",
+ "columns": [
+ {
+ "expression": "initiative_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_activity_issue_id_issue_id_fk": {
+ "name": "issue_activity_issue_id_issue_id_fk",
+ "tableFrom": "issue_activity",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_activity_initiative_id_initiative_id_fk": {
+ "name": "issue_activity_initiative_id_initiative_id_fk",
+ "tableFrom": "issue_activity",
+ "tableTo": "initiative",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_activity_actor_user_id_user_id_fk": {
+ "name": "issue_activity_actor_user_id_user_id_fk",
+ "tableFrom": "issue_activity",
+ "tableTo": "user",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "issue_activity_kind_check": {
+ "name": "issue_activity_kind_check",
+ "value": "\"issue_activity\".\"kind\" IN ('comment', 'activity')"
+ },
+ "issue_activity_owner_check": {
+ "name": "issue_activity_owner_check",
+ "value": "(\"issue_activity\".\"issue_id\" IS NOT NULL) <> (\"issue_activity\".\"initiative_id\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.issue_attachment": {
+ "name": "issue_attachment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content_type": {
+ "name": "content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_attachment_issue_idx": {
+ "name": "issue_attachment_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_attachment_issue_id_issue_id_fk": {
+ "name": "issue_attachment_issue_id_issue_id_fk",
+ "tableFrom": "issue_attachment",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_attachment_public_id_unique": {
+ "name": "issue_attachment_public_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "public_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_field_option": {
+ "name": "issue_field_option",
+ "schema": "",
+ "columns": {
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "option_id": {
+ "name": "option_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_field_option_issue_id_issue_id_fk": {
+ "name": "issue_field_option_issue_id_issue_id_fk",
+ "tableFrom": "issue_field_option",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_field_option_field_id_custom_field_id_fk": {
+ "name": "issue_field_option_field_id_custom_field_id_fk",
+ "tableFrom": "issue_field_option",
+ "tableTo": "custom_field",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_field_option_option_id_custom_field_option_id_fk": {
+ "name": "issue_field_option_option_id_custom_field_option_id_fk",
+ "tableFrom": "issue_field_option",
+ "tableTo": "custom_field_option",
+ "columnsFrom": [
+ "option_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "issue_field_option_issue_id_field_id_option_id_pk": {
+ "name": "issue_field_option_issue_id_field_id_option_id_pk",
+ "columns": [
+ "issue_id",
+ "field_id",
+ "option_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_field_value": {
+ "name": "issue_field_value",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value_text": {
+ "name": "value_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_number": {
+ "name": "value_number",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_bool": {
+ "name": "value_bool",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_date": {
+ "name": "value_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_field_value_issue_id_issue_id_fk": {
+ "name": "issue_field_value_issue_id_issue_id_fk",
+ "tableFrom": "issue_field_value",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_field_value_field_id_custom_field_id_fk": {
+ "name": "issue_field_value_field_id_custom_field_id_fk",
+ "tableFrom": "issue_field_value",
+ "tableTo": "custom_field",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_field_value_issue_id_field_id_unique": {
+ "name": "issue_field_value_issue_id_field_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "issue_id",
+ "field_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_label": {
+ "name": "issue_label",
+ "schema": "",
+ "columns": {
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label_id": {
+ "name": "label_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_label_issue_id_issue_id_fk": {
+ "name": "issue_label_issue_id_issue_id_fk",
+ "tableFrom": "issue_label",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_label_label_id_label_id_fk": {
+ "name": "issue_label_label_id_label_id_fk",
+ "tableFrom": "issue_label",
+ "tableTo": "label",
+ "columnsFrom": [
+ "label_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "issue_label_issue_id_label_id_pk": {
+ "name": "issue_label_issue_id_label_id_pk",
+ "columns": [
+ "issue_id",
+ "label_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_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.label": {
+ "name": "label",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#6b7280'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "label_project_id_project_id_fk": {
+ "name": "label_project_id_project_id_fk",
+ "tableFrom": "label",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "label_group_id_label_group_id_fk": {
+ "name": "label_group_id_label_group_id_fk",
+ "tableFrom": "label",
+ "tableTo": "label_group",
+ "columnsFrom": [
+ "group_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "label_project_id_name_unique": {
+ "name": "label_project_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.label_group": {
+ "name": "label_group",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#6b7280'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "label_group_project_id_project_id_fk": {
+ "name": "label_group_project_id_project_id_fk",
+ "tableFrom": "label_group",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "label_group_project_id_name_unique": {
+ "name": "label_group_project_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.note_board": {
+ "name": "note_board",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.notification": {
+ "name": "notification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_activity_id": {
+ "name": "source_activity_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "read_at": {
+ "name": "read_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "snoozed_until": {
+ "name": "snoozed_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "notification_user_idx": {
+ "name": "notification_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "notification_user_unread_idx": {
+ "name": "notification_user_unread_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"notification\".\"read_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "notification_user_id_user_id_fk": {
+ "name": "notification_user_id_user_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "notification_project_id_project_id_fk": {
+ "name": "notification_project_id_project_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "notification_issue_id_issue_id_fk": {
+ "name": "notification_issue_id_issue_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "notification_source_activity_id_issue_activity_id_fk": {
+ "name": "notification_source_activity_id_issue_activity_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "issue_activity",
+ "columnsFrom": [
+ "source_activity_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "notification_actor_user_id_user_id_fk": {
+ "name": "notification_actor_user_id_user_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "user",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "notification_type_check": {
+ "name": "notification_type_check",
+ "value": "\"notification\".\"type\" IN ('assigned', 'mentioned', 'commented', 'state_changed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.notification_delivery": {
+ "name": "notification_delivery",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel": {
+ "name": "channel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recipient": {
+ "name": "recipient",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "notification_delivery_due_idx": {
+ "name": "notification_delivery_due_idx",
+ "columns": [
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"notification_delivery\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "notification_delivery_project_id_project_id_fk": {
+ "name": "notification_delivery_project_id_project_id_fk",
+ "tableFrom": "notification_delivery",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "notification_delivery_channel_check": {
+ "name": "notification_delivery_channel_check",
+ "value": "\"notification_delivery\".\"channel\" IN ('email', 'telegram')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project": {
+ "name": "project",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "next_sequence": {
+ "name": "next_sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "mcp_enabled": {
+ "name": "mcp_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_key_unique": {
+ "name": "project_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_action": {
+ "name": "project_action",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "condition": {
+ "name": "condition",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "effect": {
+ "name": "effect",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_action_project_idx": {
+ "name": "project_action_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_action_project_id_project_id_fk": {
+ "name": "project_action_project_id_project_id_fk",
+ "tableFrom": "project_action",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_column": {
+ "name": "project_column",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_type": {
+ "name": "state_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unstarted'"
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#6b7280'"
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_column_project_id_project_id_fk": {
+ "name": "project_column_project_id_project_id_fk",
+ "tableFrom": "project_column",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_column_project_id_position_unique": {
+ "name": "project_column_project_id_position_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "position"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "project_column_state_type_check": {
+ "name": "project_column_state_type_check",
+ "value": "\"project_column\".\"state_type\" IN ('backlog', 'unstarted', 'started', 'completed', 'canceled')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_dashboard": {
+ "name": "project_dashboard",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "layout": {
+ "name": "layout",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_dashboard_project_idx": {
+ "name": "project_dashboard_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_dashboard_project_id_project_id_fk": {
+ "name": "project_dashboard_project_id_project_id_fk",
+ "tableFrom": "project_dashboard",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_invite": {
+ "name": "project_invite",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "role_id": {
+ "name": "role_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "invited_by_user_id": {
+ "name": "invited_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by_user_id": {
+ "name": "accepted_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "responded_at": {
+ "name": "responded_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "project_invite_pending_uq": {
+ "name": "project_invite_pending_uq",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"project_invite\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_invite_project_idx": {
+ "name": "project_invite_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_invite_project_id_project_id_fk": {
+ "name": "project_invite_project_id_project_id_fk",
+ "tableFrom": "project_invite",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_invite_role_id_project_role_id_fk": {
+ "name": "project_invite_role_id_project_role_id_fk",
+ "tableFrom": "project_invite",
+ "tableTo": "project_role",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_invite_invited_by_user_id_user_id_fk": {
+ "name": "project_invite_invited_by_user_id_user_id_fk",
+ "tableFrom": "project_invite",
+ "tableTo": "user",
+ "columnsFrom": [
+ "invited_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_invite_accepted_by_user_id_user_id_fk": {
+ "name": "project_invite_accepted_by_user_id_user_id_fk",
+ "tableFrom": "project_invite",
+ "tableTo": "user",
+ "columnsFrom": [
+ "accepted_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_invite_token_unique": {
+ "name": "project_invite_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "project_invite_role_check": {
+ "name": "project_invite_role_check",
+ "value": "\"project_invite\".\"role\" IN ('owner', 'member')"
+ },
+ "project_invite_status_check": {
+ "name": "project_invite_status_check",
+ "value": "\"project_invite\".\"status\" IN ('pending', 'accepted', 'rejected')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_member": {
+ "name": "project_member",
+ "schema": "",
+ "columns": {
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "role_id": {
+ "name": "role_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_member_user_idx": {
+ "name": "project_member_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_member_project_id_project_id_fk": {
+ "name": "project_member_project_id_project_id_fk",
+ "tableFrom": "project_member",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_member_user_id_user_id_fk": {
+ "name": "project_member_user_id_user_id_fk",
+ "tableFrom": "project_member",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_member_role_id_project_role_id_fk": {
+ "name": "project_member_role_id_project_role_id_fk",
+ "tableFrom": "project_member",
+ "tableTo": "project_role",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_member_project_id_user_id_pk": {
+ "name": "project_member_project_id_user_id_pk",
+ "columns": [
+ "project_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "project_member_role_check": {
+ "name": "project_member_role_check",
+ "value": "\"project_member\".\"role\" IN ('owner', 'member')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_notification_setting": {
+ "name": "project_notification_setting",
+ "schema": "",
+ "columns": {
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "ciphertext": {
+ "name": "ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "iv": {
+ "name": "iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_tag": {
+ "name": "auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redacted": {
+ "name": "redacted",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_notification_setting_project_id_project_id_fk": {
+ "name": "project_notification_setting_project_id_project_id_fk",
+ "tableFrom": "project_notification_setting",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_role": {
+ "name": "project_role",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_role_default_uq": {
+ "name": "project_role_default_uq",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"project_role\".\"is_default\"",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_role_project_idx": {
+ "name": "project_role_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_role_project_id_project_id_fk": {
+ "name": "project_role_project_id_project_id_fk",
+ "tableFrom": "project_role",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_role_project_id_name_unique": {
+ "name": "project_role_project_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_setting": {
+ "name": "project_setting",
+ "schema": "",
+ "columns": {
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_setting_project_id_project_id_fk": {
+ "name": "project_setting_project_id_project_id_fk",
+ "tableFrom": "project_setting",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_setting_project_id_key_pk": {
+ "name": "project_setting_project_id_key_pk",
+ "columns": [
+ "project_id",
+ "key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_view": {
+ "name": "project_view",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "filters": {
+ "name": "filters",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "display": {
+ "name": "display",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "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": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_notification_preference": {
+ "name": "user_notification_preference",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_events": {
+ "name": "email_events",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "telegram_events": {
+ "name": "telegram_events",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_notification_preference_user_id_user_id_fk": {
+ "name": "user_notification_preference_user_id_user_id_fk",
+ "tableFrom": "user_notification_preference",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_notification_preference_project_id_project_id_fk": {
+ "name": "user_notification_preference_project_id_project_id_fk",
+ "tableFrom": "user_notification_preference",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_notification_pref_user_project_unique": {
+ "name": "user_notification_pref_user_project_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_preference": {
+ "name": "user_preference",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "timezone": {
+ "name": "timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'UTC'"
+ },
+ "theme": {
+ "name": "theme",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'system'"
+ },
+ "issue_open_mode": {
+ "name": "issue_open_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'panel'"
+ },
+ "start_page": {
+ "name": "start_page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'work-items'"
+ },
+ "show_chat_by_default": {
+ "name": "show_chat_by_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "hotkeys": {
+ "name": "hotkeys",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_project_id": {
+ "name": "last_project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_preference_user_id_user_id_fk": {
+ "name": "user_preference_user_id_user_id_fk",
+ "tableFrom": "user_preference",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_preference_last_project_id_project_id_fk": {
+ "name": "user_preference_last_project_id_project_id_fk",
+ "tableFrom": "user_preference",
+ "tableTo": "project",
+ "columnsFrom": [
+ "last_project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "user_preference_theme_check": {
+ "name": "user_preference_theme_check",
+ "value": "\"user_preference\".\"theme\" IN ('light', 'dark', 'system')"
+ },
+ "user_preference_issue_open_mode_check": {
+ "name": "user_preference_issue_open_mode_check",
+ "value": "\"user_preference\".\"issue_open_mode\" IN ('panel', 'page')"
+ },
+ "user_preference_start_page_check": {
+ "name": "user_preference_start_page_check",
+ "value": "\"user_preference\".\"start_page\" IN ('inbox', 'dashboard', 'work-items', 'initiatives', 'ai-chat')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_telegram_account": {
+ "name": "user_telegram_account",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "username": {
+ "name": "username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "link_code": {
+ "name": "link_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "link_code_expires_at": {
+ "name": "link_code_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "linked_at": {
+ "name": "linked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_telegram_account_chat_id_unique": {
+ "name": "user_telegram_account_chat_id_unique",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"user_telegram_account\".\"chat_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_telegram_account_link_code_unique": {
+ "name": "user_telegram_account_link_code_unique",
+ "columns": [
+ {
+ "expression": "link_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"user_telegram_account\".\"link_code\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_telegram_account_user_id_user_id_fk": {
+ "name": "user_telegram_account_user_id_user_id_fk",
+ "tableFrom": "user_telegram_account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.webhook": {
+ "name": "webhook",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "secret": {
+ "name": "secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "events": {
+ "name": "events",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "consecutive_failures": {
+ "name": "consecutive_failures",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "webhook_project_idx": {
+ "name": "webhook_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "webhook_project_id_project_id_fk": {
+ "name": "webhook_project_id_project_id_fk",
+ "tableFrom": "webhook",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.webhook_delivery": {
+ "name": "webhook_delivery",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "webhook_id": {
+ "name": "webhook_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_id": {
+ "name": "event_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_status": {
+ "name": "response_status",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_body": {
+ "name": "response_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "webhook_delivery_due_idx": {
+ "name": "webhook_delivery_due_idx",
+ "columns": [
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"webhook_delivery\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "webhook_delivery_webhook_idx": {
+ "name": "webhook_delivery_webhook_idx",
+ "columns": [
+ {
+ "expression": "webhook_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "webhook_delivery_webhook_id_webhook_id_fk": {
+ "name": "webhook_delivery_webhook_id_webhook_id_fk",
+ "tableFrom": "webhook_delivery",
+ "tableTo": "webhook",
+ "columnsFrom": [
+ "webhook_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.json
index 8c92c242..38d619a7 100644
--- a/packages/db/drizzle/meta/_journal.json
+++ b/packages/db/drizzle/meta/_journal.json
@@ -337,6 +337,13 @@
"when": 1784650824676,
"tag": "0047_mysterious_wallflower",
"breakpoints": true
+ },
+ {
+ "idx": 48,
+ "version": "7",
+ "when": 1784765564343,
+ "tag": "0048_gigantic_starjammers",
+ "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 b643fccc..1c3ba153 100644
--- a/packages/db/src/schema/app.ts
+++ b/packages/db/src/schema/app.ts
@@ -970,6 +970,27 @@ export const projectDashboard = pgTable(
(t) => [index('project_dashboard_project_idx').on(t.projectId, t.position)],
);
+// Note boards: a freeform canvas of sticky notes. canvas is a jsonb blob owned by
+// the UI (React Flow nodes + edges + viewport), stored and returned verbatim.
+// owner_user_id NULL means a public board visible to every project member; a set
+// owner_user_id means a personal board only its owner can see or edit.
+export const noteBoard = pgTable(
+ 'note_board',
+ {
+ id: serial('id').primaryKey(),
+ projectId: integer('project_id')
+ .notNull()
+ .references(() => project.id, { onDelete: 'cascade' }),
+ ownerUserId: text('owner_user_id').references(() => user.id, { onDelete: 'cascade' }),
+ name: text('name').notNull(),
+ canvas: jsonb('canvas').notNull().default({}),
+ createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
+ updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
+ },
+ // Listed by updatedAt within a project; the index covers the project filter.
+ (t) => [index('note_board_project_idx').on(t.projectId, t.updatedAt)],
+);
+
// Manual actions: saved macros on a project. condition is a filter set deciding
// which issues the action applies to (empty = always); effect is a partial
// issue patch applied in one update. Both jsonb blobs are owned by the UI.