ALTER TABLE schedule_tasks
    ADD COLUMN workspace_id BIGINT REFERENCES workspaces(id),
    ADD COLUMN auto_publish BOOLEAN NOT NULL DEFAULT FALSE,
    ADD COLUMN publish_account_ids JSONB NOT NULL DEFAULT '[]'::jsonb,
    ADD COLUMN cover_asset_url TEXT,
    ADD COLUMN cover_image_asset_id BIGINT;

ALTER TABLE schedule_tasks
    ADD CONSTRAINT chk_schedule_tasks_publish_account_ids_json
        CHECK (jsonb_typeof(publish_account_ids) = 'array');

CREATE INDEX idx_schedule_task_workspace
    ON schedule_tasks(tenant_id, workspace_id, created_at DESC)
    WHERE deleted_at IS NULL;
