-- Create backups table for backup management
USE `blood_bank`;

CREATE TABLE IF NOT EXISTS `backups` (
    `id` INT(11) NOT NULL AUTO_INCREMENT,
    `filename` VARCHAR(255) NOT NULL,
    `original_filename` VARCHAR(255) DEFAULT NULL,
    `filepath` VARCHAR(500) NOT NULL,
    `size` BIGINT(20) NOT NULL,
    `description` TEXT DEFAULT NULL,
    `type` ENUM('database', 'files', 'full') DEFAULT 'database',
    `google_drive_file_id` VARCHAR(255) DEFAULT NULL,
    `created_by` INT(11) DEFAULT NULL,
    `created_at` DATETIME NOT NULL,
    PRIMARY KEY (`id`),
    KEY `created_by` (`created_by`),
    KEY `created_at` (`created_at`),
    KEY `google_drive_file_id` (`google_drive_file_id`),
    CONSTRAINT `fk_backup_user` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

