31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
"""Heartbeat configuration — add heartbeat fields to ai_proactive_settings.
|
|
|
|
Revision ID: 0024
|
|
Revises: 0023_theme_customization
|
|
Create Date: 2026-07-23
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
revision = "0024_heartbeat_config"
|
|
down_revision = "0023_theme_customization"
|
|
|
|
|
|
def upgrade():
|
|
op.execute("""
|
|
DO $$ BEGIN
|
|
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'ai_proactive_settings') THEN
|
|
ALTER TABLE ai_proactive_settings ADD COLUMN IF NOT EXISTS heartbeat_enabled BOOLEAN NOT NULL DEFAULT true;
|
|
ALTER TABLE ai_proactive_settings ADD COLUMN IF NOT EXISTS heartbeat_interval_seconds INTEGER NOT NULL DEFAULT 300;
|
|
ALTER TABLE ai_proactive_settings ADD COLUMN IF NOT EXISTS heartbeat_target_room VARCHAR(200) NOT NULL DEFAULT 'Live KI';
|
|
END IF;
|
|
END $$
|
|
""")
|
|
|
|
|
|
def downgrade():
|
|
op.drop_column("ai_proactive_settings", "heartbeat_target_room")
|
|
op.drop_column("ai_proactive_settings", "heartbeat_interval_seconds")
|
|
op.drop_column("ai_proactive_settings", "heartbeat_enabled")
|