<?php

class Migration_20241112164730_add_property_id_to_hardwares_settings
{
    public static function up(PDO $pdo)
    {
        // Your migration code here
        $sqlUpdate = "
            ALTER TABLE `hardwares_settings`
            ADD COLUMN `property_id` INT NULL,
            ADD CONSTRAINT `fk_hardware_setting_property_id`
            FOREIGN KEY (`property_id`) REFERENCES `properties`(`id`)
            ON DELETE SET NULL ON UPDATE CASCADE
        ";

        $pdo->exec($sqlUpdate);
    }

    public static function down(PDO $pdo)
    {
        // Rollback code here
        $sqlRollback = "
            ALTER TABLE `hardwares_settings`
            DROP FOREIGN KEY `fk_hardware_setting_property_id`,
            DROP COLUMN `property_id`
        ";

        $pdo->exec($sqlRollback);
    }
}