

-- Create audit_logs table
CREATE TABLE IF NOT EXISTS `audit_logs` (
    `id` CHAR(36) PRIMARY KEY,
    `action` VARCHAR(255) NOT NULL,
    `table_name` VARCHAR(255) NULL,
    `record_id` VARCHAR(255) NULL,
    `record_title` VARCHAR(255) NULL,
    `old_data` JSON NULL,
    `new_data` JSON NULL,
    `performed_by` CHAR(36) NULL,
    `performed_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (`performed_by`) REFERENCES `admins`(`id`) ON DELETE SET NULL,
    INDEX `audit_logs_performed_by_index` (`performed_by`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Mark the admin migrations as complete in the migrations table
INSERT INTO `migrations` (`migration`, `batch`) VALUES
('2024_01_02_000008_create_admin_tables', 1);

-- Mark the blog migration as complete (table already exists)
INSERT INTO `migrations` (`migration`, `batch`) VALUES
('2026_01_13_091410_create_blogs_table', 1);

SELECT 'Database setup complete!' AS Status;
