-- 차트 실시간 소스, 실거래 예산, FCM 푸시 설정
ALTER TABLE gc_app_settings
    ADD COLUMN chart_realtime_source VARCHAR(20) NOT NULL DEFAULT 'BACKEND_STOMP'
        COMMENT 'BACKEND_STOMP | UPBIT_DIRECT',
    ADD COLUMN live_auto_trade_budget_pct DECIMAL(8, 4) NOT NULL DEFAULT 95.0000,
    ADD COLUMN fcm_push_enabled BOOLEAN NOT NULL DEFAULT FALSE;

CREATE TABLE IF NOT EXISTS gc_fcm_token (
    id           BIGINT AUTO_INCREMENT PRIMARY KEY,
    user_id      BIGINT NULL,
    device_id    VARCHAR(64) NOT NULL,
    token        VARCHAR(512) NOT NULL,
    active       BOOLEAN NOT NULL DEFAULT TRUE,
    last_used_at DATETIME NULL,
    created_at   DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at   DATETIME NULL ON UPDATE CURRENT_TIMESTAMP,
    UNIQUE KEY uk_gc_fcm_token (token),
    KEY idx_gc_fcm_device (device_id),
    KEY idx_gc_fcm_user (user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
