<?php

namespace src\Migrations;

class _015_criarTabelaGeral
{
    public function up()
    {
        $conexao = new \src\Conexao\Conexao();
        $conn = $conexao->getConexao();

        $query = "CREATE TABLE geral (
            id INT AUTO_INCREMENT PRIMARY KEY,
            urlConexaoWhatsApp VARCHAR(100) NOT NULL,
            licenca VARCHAR(100) NOT NULL,
            idInstancia VARCHAR(100) NOT NULL
        )";
    
        $stmt = $conn->prepare($query);
        if (!$stmt) {
            echo "Erro ao preparar a consulta: " . $conn->error;
            return null;
        }

        $stmt->execute();
    }

    public function down()
    {
        $conexao = new \src\Conexao\Conexao();
        $conn = $conexao->getConexao();

        $query = "DROP TABLE geral";
    
        $stmt = $conn->prepare($query);
        if (!$stmt) {
            echo "Erro ao preparar a consulta: " . $conn->error;
            return null;
        }

        $stmt->execute();
    }
}