CREATE TABLE `ups_readings` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `integration_id` integer NOT NULL, `at` text NOT NULL, `charge` real, `runtime_seconds` integer, `load_percent` real, `input_voltage` real, `on_battery` integer DEFAULT false NOT NULL, FOREIGN KEY (`integration_id`) REFERENCES `integrations`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE INDEX `ups_readings_lookup_idx` ON `ups_readings` (`integration_id`,`at`);--> statement-breakpoint CREATE TABLE `ups_state` ( `integration_id` integer PRIMARY KEY NOT NULL, `model` text, `manufacturer` text, `status_text` text NOT NULL, `on_battery` integer DEFAULT false NOT NULL, `low_battery` integer DEFAULT false NOT NULL, `replace_battery` integer DEFAULT false NOT NULL, `overload` integer DEFAULT false NOT NULL, `charge` real, `runtime_seconds` integer, `load_percent` real, `input_voltage` real, `output_voltage` real, `on_battery_since` text, `updated_at` text NOT NULL, FOREIGN KEY (`integration_id`) REFERENCES `integrations`(`id`) ON UPDATE no action ON DELETE cascade );