CREATE TABLE `network_devices` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `integration_id` integer NOT NULL, `external_id` text NOT NULL, `site_name` text, `name` text NOT NULL, `model` text, `kind` text DEFAULT 'other' NOT NULL, `ip` text, `mac` text, `state` text DEFAULT 'other' NOT NULL, `uptime_seconds` integer, `firmware` text, `firmware_updatable` integer DEFAULT false NOT NULL, `uplink_external_id` text, `offline_since` text, `last_online_at` text, `first_seen_at` text 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 `network_devices_unique` ON `network_devices` (`integration_id`,`external_id`);--> statement-breakpoint CREATE TABLE `network_segments` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `integration_id` integer NOT NULL, `kind` text NOT NULL, `external_id` text NOT NULL, `site_name` text, `name` text NOT NULL, `enabled` integer DEFAULT true NOT NULL, `vlan_id` integer, `subnet` text, `purpose` text, `security` text, `network_name` text, `updated_at` text NOT NULL, FOREIGN KEY (`integration_id`) REFERENCES `integrations`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE UNIQUE INDEX `network_segments_unique` ON `network_segments` (`integration_id`,`kind`,`external_id`);