diff --git a/apps/server/src/database/migrations/20260703T190000-comment-suggestions.ts b/apps/server/src/database/migrations/20260703T190000-comment-suggestions.ts new file mode 100644 index 00000000..2f0523f8 --- /dev/null +++ b/apps/server/src/database/migrations/20260703T190000-comment-suggestions.ts @@ -0,0 +1,26 @@ +import { type Kysely } from 'kysely'; + +export async function up(db: Kysely): Promise { + // Agent comment suggestions (#315): a comment may carry a proposed replacement + // for its anchored `selection`, which a human applies via the comment UI. + await db.schema + .alterTable('comments') + // The proposed replacement text (plain text). NULL for ordinary comments. + .addColumn('suggested_text', 'text') + // When the suggestion was applied (NULL until applied). + .addColumn('suggestion_applied_at', 'timestamptz') + // Who applied it (NULL until applied). + .addColumn('suggestion_applied_by_id', 'uuid', (col) => + col.references('users.id').onDelete('set null'), + ) + .execute(); +} + +export async function down(db: Kysely): Promise { + await db.schema + .alterTable('comments') + .dropColumn('suggested_text') + .dropColumn('suggestion_applied_at') + .dropColumn('suggestion_applied_by_id') + .execute(); +} diff --git a/apps/server/src/database/types/db.d.ts b/apps/server/src/database/types/db.d.ts index f4b868cc..dab98b3d 100644 --- a/apps/server/src/database/types/db.d.ts +++ b/apps/server/src/database/types/db.d.ts @@ -173,6 +173,9 @@ export interface Comments { resolvedSource: string | null; selection: string | null; spaceId: string; + suggestedText: string | null; + suggestionAppliedAt: Timestamp | null; + suggestionAppliedById: string | null; type: string | null; updatedAt: Generated; workspaceId: string;