CREATE TABLE `cloud_schema_migrations` ( `id` text PRIMARY KEY NOT NULL, `applied_at` text NOT NULL ); --> statement-breakpoint CREATE TABLE `device_credentials` ( `id` text PRIMARY KEY NOT NULL, `host_id` text NOT NULL, `token_hash` text NOT NULL, `status` text DEFAULT 'active' NOT NULL, `issued_at` text NOT NULL, `expires_at` text, `last_used_at` text, `revoked_at` text, `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, FOREIGN KEY (`host_id`) REFERENCES `hosts`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE UNIQUE INDEX `idx_device_credentials_token_hash` ON `device_credentials` (`token_hash`);--> statement-breakpoint CREATE INDEX `idx_device_credentials_host_status` ON `device_credentials` (`host_id`,`status`);--> statement-breakpoint CREATE TABLE `pairing_claim_attempts` ( `id` text PRIMARY KEY NOT NULL, `pairing_request_id` text NOT NULL, `source_hash` text NOT NULL, `outcome` text NOT NULL, `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL ); --> statement-breakpoint CREATE INDEX `idx_pairing_claim_attempts_target_time` ON `pairing_claim_attempts` (`pairing_request_id`,`created_at`);--> statement-breakpoint CREATE INDEX `idx_pairing_claim_attempts_source_time` ON `pairing_claim_attempts` (`source_hash`,`created_at`);--> statement-breakpoint CREATE TABLE `pairing_claim_rate_limits` ( `source_hash` text NOT NULL, `window_start` text NOT NULL, `attempts` integer DEFAULT 1 NOT NULL, `updated_at` text NOT NULL, PRIMARY KEY(`source_hash`, `window_start`) ); --> statement-breakpoint ALTER TABLE `hosts` ADD `ed25519_public` text;--> statement-breakpoint ALTER TABLE `hosts` ADD `x25519_public` text;--> statement-breakpoint ALTER TABLE `hosts` ADD `identity_fingerprint` text;--> statement-breakpoint ALTER TABLE `hosts` ADD `claimed_at` text;--> statement-breakpoint CREATE UNIQUE INDEX `idx_hosts_identity_fingerprint` ON `hosts` (`identity_fingerprint`);--> statement-breakpoint ALTER TABLE `pairing_requests` ADD `failed_attempts` integer DEFAULT 0 NOT NULL;--> statement-breakpoint ALTER TABLE `pairing_requests` ADD `locked_at` text;--> statement-breakpoint ALTER TABLE `pairing_requests` ADD `last_attempt_at` text;