From df8279602360429464de2af6fda82d9aaef7d0f9 Mon Sep 17 00:00:00 2001 From: Agent Zero Date: Sat, 18 Jul 2026 16:18:45 +0200 Subject: [PATCH] fix: add deleted_at columns to ai_proactive migration - ai_proactive_suggestions: add deleted_at TIMESTAMPTZ - ai_proactive_context_log: add deleted_at TIMESTAMPTZ - ai_proactive_settings: add deleted_at TIMESTAMPTZ ORM models expect deleted_at for soft-delete support. --- .../builtins/ai_proactive/migrations/0001_initial.sql | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/plugins/builtins/ai_proactive/migrations/0001_initial.sql b/app/plugins/builtins/ai_proactive/migrations/0001_initial.sql index 61c4e18..74c597c 100644 --- a/app/plugins/builtins/ai_proactive/migrations/0001_initial.sql +++ b/app/plugins/builtins/ai_proactive/migrations/0001_initial.sql @@ -16,7 +16,8 @@ CREATE TABLE IF NOT EXISTS ai_proactive_suggestions ( is_acted_upon BOOLEAN NOT NULL DEFAULT FALSE, context_snapshot JSONB NOT NULL DEFAULT '{}', created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), - expires_at TIMESTAMPTZ + expires_at TIMESTAMPTZ, + deleted_at TIMESTAMPTZ ); CREATE INDEX IF NOT EXISTS ix_suggestions_user ON ai_proactive_suggestions (tenant_id, user_id, is_dismissed, created_at DESC); CREATE INDEX IF NOT EXISTS ix_suggestions_entity ON ai_proactive_suggestions (tenant_id, entity_type, entity_id); @@ -30,7 +31,8 @@ CREATE TABLE IF NOT EXISTS ai_proactive_context_log ( entity_type VARCHAR(50), entity_id UUID, entity_data JSONB NOT NULL DEFAULT '{}', - created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + deleted_at TIMESTAMPTZ ); CREATE INDEX IF NOT EXISTS ix_context_log_user_time ON ai_proactive_context_log (tenant_id, user_id, created_at DESC); @@ -46,5 +48,6 @@ CREATE TABLE IF NOT EXISTS ai_proactive_settings ( model VARCHAR(100) NOT NULL DEFAULT 'gpt-4o-mini', created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + deleted_at TIMESTAMPTZ, UNIQUE(tenant_id, user_id) );