<?php
require_once __DIR__ . '/../config.php';

try {
    $pdo = db();
    $sql = "
    CREATE TABLE IF NOT EXISTS `photos` (
      `id` INT AUTO_INCREMENT PRIMARY KEY,
      `filename` VARCHAR(255) NOT NULL,
      `filepath` VARCHAR(1024) NOT NULL,
      `thumbnail_path` VARCHAR(1024),
      `filesize` INT,
      `width` INT,
      `height` INT,
      `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
      `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
      UNIQUE KEY `filepath_idx` (`filepath`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
    ";
    $pdo->exec($sql);
    echo "Table 'photos' created successfully." . PHP_EOL;
} catch (PDOException $e) {
    die("DB ERROR: " . $e->getMessage());
}
