-- Crear la base de datos si no existe
CREATE DATABASE IF NOT EXISTS formularioDB;
USE formularioDB;

-- Tabla de Usuarios (Administradores)
CREATE TABLE IF NOT EXISTS users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(255) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL,
    role VARCHAR(50) DEFAULT 'admin',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

-- Tabla de Registros (Formularios)
CREATE TABLE IF NOT EXISTS registrations (
    id INT AUTO_INCREMENT PRIMARY KEY,
    razonSocial VARCHAR(255) NOT NULL,
    nit VARCHAR(255) NOT NULL UNIQUE,
    email VARCHAR(255) NOT NULL,
    representante VARCHAR(255) NOT NULL,
    direccion VARCHAR(255) NOT NULL,
    celular VARCHAR(255) NOT NULL,
    tesoreria_nombre VARCHAR(255),
    tesoreria_celular VARCHAR(255),
    tesoreria_email VARCHAR(255),
    pdfPath VARCHAR(255) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);


-- DDBB PRoduccion 


CREATE DATABASE IF NOT EXISTS formularioDB;
USE formularioDB;

CREATE TABLE IF NOT EXISTS users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(150) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL,
    role VARCHAR(50) DEFAULT 'admin',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS registrations (
    id INT AUTO_INCREMENT PRIMARY KEY,
    razonSocial VARCHAR(255) NOT NULL,
    nit VARCHAR(50) NOT NULL UNIQUE,
    email VARCHAR(255) NOT NULL,
    representante VARCHAR(255) NOT NULL,
    direccion VARCHAR(255) NOT NULL,
    celular VARCHAR(20) NOT NULL,
    tesoreria_nombre VARCHAR(255),
    tesoreria_celular VARCHAR(20),
    tesoreria_email VARCHAR(255),
    pdfPath VARCHAR(255) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);