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.
This commit is contained in:
@@ -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)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user