<?php

class Migration_20250610170704_hardware_foreign_key
{
    public static function up(PDO $pdo)
    {
        $pdo->exec("
            ALTER TABLE `hardwares_settings`
            DROP FOREIGN KEY `fk_hardware__created_by`
        ");

        $pdo->exec("
            ALTER TABLE `hardwares_settings`
            ADD COLUMN `created_by_email` VARCHAR(256) NULL AFTER `created_by`
        ");
    }

    public static function down(PDO $pdo)
    {
        // Re-add the foreign key constraint if needed
        $pdo->exec("
            ALTER TABLE `hardwares_settings`
            ADD CONSTRAINT `fk_hardware__created_by`
            FOREIGN KEY (`created_by`) REFERENCES `users`(`id`)
        ");
    }
}
