-- CloudVault Initial Schema - Backups Table
CREATE TABLE IF NOT EXISTS `backups` (
  `id` int AUTO_INCREMENT NOT NULL,
  `backup_id` varchar(255) NOT NULL,
  `device_id` varchar(255) NOT NULL,
  `backup_type` varchar(50) NOT NULL,
  `status` varchar(50) NOT NULL,
  `size` bigint,
  `file_path` varchar(500),
  `metadata` text,
  `encrypted` boolean DEFAULT false,
  `encryption_algorithm` varchar(50),
  `encryption_iv` varchar(255),
  `encryption_auth_tag` varchar(255),
  `encryption_salt` varchar(255),
  `hash` varchar(64),
  `checksum` varchar(8),
  `verified` boolean DEFAULT false,
  `verified_at` timestamp,
  `compressed` boolean DEFAULT false,
  `compression_algorithm` varchar(50),
  `original_size` bigint,
  `compressed_size` bigint,
  `compression_ratio` int,
  `started_at` timestamp,
  `completed_at` timestamp,
  `error_message` text,
  `created_at` timestamp DEFAULT (now()),
  CONSTRAINT `backups_id` PRIMARY KEY(`id`),
  CONSTRAINT `backups_backup_id_unique` UNIQUE(`backup_id`)
);
