CREATE TABLE `endpoint_hourly` ( `check_id` integer NOT NULL, `hour` text NOT NULL, `total` integer DEFAULT 0 NOT NULL, `ok` integer DEFAULT 0 NOT NULL, `ms_sum` integer DEFAULT 0 NOT NULL, `ms_count` integer DEFAULT 0 NOT NULL, `ms_max` integer DEFAULT 0 NOT NULL, PRIMARY KEY(`check_id`, `hour`), FOREIGN KEY (`check_id`) REFERENCES `endpoint_checks`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `server_metrics_rollup` ( `server_id` integer NOT NULL, `metric` text NOT NULL, `grain` text NOT NULL, `at` text NOT NULL, `sum` real NOT NULL, `n` integer NOT NULL, `min` real NOT NULL, `max` real NOT NULL, PRIMARY KEY(`server_id`, `metric`, `grain`, `at`), FOREIGN KEY (`server_id`) REFERENCES `servers`(`id`) ON UPDATE no action ON DELETE cascade );