<?php

class Migration_20250122093309_property_id_column_in_camera
{
    public static function up(PDO $pdo)
    {
        $sql_add_column = "
            ALTER TABLE `live_camera_streaming_data`
            ADD COLUMN `property_id` INT NULL, -- Allow NULL values
            ADD CONSTRAINT `fk_live_camera_streaming_data_property_id`
            FOREIGN KEY (`property_id`) REFERENCES `properties`(`id`)
            ON DELETE SET NULL ON UPDATE CASCADE
        ";
        $pdo->exec($sql_add_column);
    }

    public static function down(PDO $pdo)
    {
        $sql_drop_column = "
            ALTER TABLE `live_camera_streaming_data`
            DROP FOREIGN KEY `fk_hardware_setting_property_id`,
            DROP COLUMN `property_id`
        ";
        $pdo->exec($sql_drop_column);
    }
}
