<?php

class Migration_20250414134811_camera_permission
{
    public static function up(PDO $pdo)
    {
        $pdo->exec("
            CREATE TABLE camera_permissions (
                id INT AUTO_INCREMENT PRIMARY KEY,
                property_user_id INT NOT NULL,
                property_user_email VARCHAR(256) NOT NULL,
                property_user_name VARCHAR(256) NULL,
                have_view_permission INT NOT NULL,
                camera_id INT NOT NULL,
                property_id INT NOT NULL,
                created_at DATETIME DEFAULT CURRENT_TIMESTAMP
            )
        ");
        
        $pdo->exec("
            CREATE TABLE camera_permissions_global (
                id INT AUTO_INCREMENT PRIMARY KEY,
                property_id INT NOT NULL,
                camera_ids VARCHAR(256) NOT NULL
            )
        ");
    }

    public static function down(PDO $pdo)
    {
        $pdo->exec("DROP TABLE IF EXISTS camera_permissions_global");
        $pdo->exec("DROP TABLE IF EXISTS camera_permissions");
    }
}
