PRAGMA foreign_keys = ON;

CREATE TABLE IF NOT EXISTS global_action (
       name TEXT NOT NULL PRIMARY KEY,
       next_run INTEGER DEFAULT 0 NOT NULL
);

CREATE TABLE IF NOT EXISTS jail_action (
       name TEXT NOT NULL,
       jail_name TEXT NOT NULL,
       next_run INTEGER DEFAULT 0 NOT NULL,
       PRIMARY KEY (name, jail_name)
);

CREATE TABLE IF NOT EXISTS local_action (
       name TEXT NOT NULL,
       jail_name TEXT NOT NULL,
       tree TEXT NOT NULL,
       set_name TEXT NOT NULL,
       next_run INTEGER DEFAULT 0 NOT NULL,
       PRIMARY KEY (name, jail_name, tree, set_name)
);
