- Introduced `bot_id` column in `system_automations` table (migration 6.0.0.sql) and updated the Diesel schema/model to include it. - Adjusted migrations to remove the hard‑coded “Update Summary” automation and only create an index on the `name` column. - Extended the `SET_SCHEDULE` keyword: - Added a second string argument for the script name. - Passed the invoking user's `bot_id` to the database layer. - Updated function signature to accept a full `UserSession` instead of discarding it. - Modified `execute_set_schedule` to store `bot_id`, script name, and activation flag; added conflict handling on `(bot_id, param)` to update schedule and reset trigger state. - Updated imports and logging to reflect new parameters. These changes enable per‑bot automation management, allow specifying the script to run, and improve idempotent schedule updates.
11 lines
488 B
SQL
11 lines
488 B
SQL
-- Migration 6.0.9: Add bot_id column to system_automations
|
|
-- Description: Introduces a bot_id column to associate automations with a specific bot.
|
|
-- The column is added as UUID and indexed for efficient queries.
|
|
|
|
-- Add bot_id column if it does not exist
|
|
ALTER TABLE public.system_automations
|
|
ADD COLUMN IF NOT EXISTS bot_id UUID NOT NULL;
|
|
|
|
-- Create an index on bot_id for faster lookups
|
|
CREATE INDEX IF NOT EXISTS idx_system_automations_bot_id
|
|
ON public.system_automations (bot_id);
|