vibesql_ast/ddl/
schedule.rs

1//! Scheduled functions and cron jobs
2//!
3//! This module contains AST nodes for VibeSQL's scheduled function execution feature.
4//! Supports one-time scheduled tasks and recurring cron jobs.
5
6use crate::Expression;
7
8/// SCHEDULE AFTER statement - schedule a task to run after a time interval
9#[derive(Debug, Clone, PartialEq)]
10pub struct ScheduleAfterStmt {
11    /// The interval expression (e.g., INTERVAL '5 minutes')
12    pub interval: Box<Expression>,
13    /// The SQL statement to execute
14    pub statement: Box<crate::Statement>,
15}
16
17/// SCHEDULE AT statement - schedule a task to run at a specific time
18#[derive(Debug, Clone, PartialEq)]
19pub struct ScheduleAtStmt {
20    /// The timestamp expression (e.g., TIMESTAMP '2024-12-25 00:00:00')
21    pub timestamp: Box<Expression>,
22    /// The SQL statement to execute
23    pub statement: Box<crate::Statement>,
24}
25
26/// CREATE CRON statement - create a recurring cron job
27#[derive(Debug, Clone, PartialEq)]
28pub struct CreateCronStmt {
29    /// The name of the cron job
30    pub cron_name: String,
31    /// The cron schedule expression (5-field format)
32    pub schedule: String,
33    /// The SQL statement to execute
34    pub statement: Box<crate::Statement>,
35}
36
37/// DROP CRON statement - remove a cron job
38#[derive(Debug, Clone, PartialEq)]
39pub struct DropCronStmt {
40    pub cron_name: String,
41    pub if_exists: bool,
42}
43
44/// ALTER CRON statement - modify a cron job
45#[derive(Debug, Clone, PartialEq)]
46pub struct AlterCronStmt {
47    pub cron_name: String,
48    pub schedule: Option<String>,
49    pub statement: Option<Box<crate::Statement>>,
50    pub enabled: Option<bool>,
51}
52
53/// CANCEL SCHEDULE statement - remove a scheduled task
54#[derive(Debug, Clone, PartialEq)]
55pub struct CancelScheduleStmt {
56    /// The schedule ID (UUID)
57    pub schedule_id: String,
58}