<?php

namespace src\Migrations;

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

        $query = "CREATE TABLE cliente (
            id INT AUTO_INCREMENT PRIMARY KEY,
            nome VARCHAR(50) NOT NULL,
            sobrenome VARCHAR(50) NOT NULL,
            telefone VARCHAR(11) NOT NULL,
            email VARCHAR(100) NOT NULL,
            endereco VARCHAR(100) NOT NULL,
            cidade VARCHAR(100) NOT NULL,
            cep VARCHAR(10) 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 cliente";
    
        $stmt = $conn->prepare($query);
        if (!$stmt) {
            echo "Erro ao preparar a consulta: " . $conn->error;
            return null;
        }

        $stmt->execute();
    }
}