<?php

class Migration_20240712000008_add_unique_email_invitations
{
    public static function up(PDO $pdo)
    {
        $sql = "
            DROP TABLE IF EXISTS invitations
            ;";

        $pdo->exec($sql);

        $sql = "
            CREATE TABLE  IF NOT EXISTS invitations (
                id INT AUTO_INCREMENT PRIMARY KEY,
                email VARCHAR(255) NOT NULL UNIQUE,
                token VARCHAR(64) NOT NULL,
                role varchar(25) NOT NULL,
                created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
            );";

        $pdo->exec($sql);
    }

    public static function down(PDO $pdo)
    {
        $sql = "
            DROP TABLE IF EXISTS invitations;
        ";

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