CREATE TABLE `integration_figure_rollup` ( `figure_id` integer 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(`figure_id`, `grain`, `at`), FOREIGN KEY (`figure_id`) REFERENCES `integration_figures`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `integration_figure_samples` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `figure_id` integer NOT NULL, `at` text NOT NULL, `value` real NOT NULL, FOREIGN KEY (`figure_id`) REFERENCES `integration_figures`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE INDEX `integration_figure_samples_idx` ON `integration_figure_samples` (`figure_id`,`at`);--> statement-breakpoint CREATE TABLE `integration_figures` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `integration_id` integer NOT NULL, `key` text NOT NULL, `label` text NOT NULL, `unit` text NOT NULL, `latest` real NOT NULL, `updated_at` text NOT NULL, FOREIGN KEY (`integration_id`) REFERENCES `integrations`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE UNIQUE INDEX `integration_figures_key_idx` ON `integration_figures` (`integration_id`,`key`);