-- Migration 1: Core multi-tenant
-- Source: backend/db/dump/19052026_nextbar.sql

-- -------------------------------------------------------- 1. Core multi-tenant

--
-- Estrutura para tabela `tenants`
--

CREATE TABLE `tenants`(
  id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(200) NOT NULL,
  legal_name VARCHAR(200) NOT NULL,
  document VARCHAR(100) NOT NULL,
  tenant_type ENUM('Produtor', 'Bar', 'Casa Noturna', 'Clube', 'Empresa', 'Outro'),
  main_contact_name VARCHAR(200) NOT NULL,
  main_contact_email VARCHAR(200) NOT NULL,
  main_contact_telephone VARCHAR(20) NOT NULL,
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  status TINYINT(1) NOT NULL DEFAULT 1,
  trash TINYINT(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Estrutura para tabela `configuracoes_tenants`
--

CREATE TABLE `configuracoes_tenants`(
  id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  tenant_id INT NOT NULL,
  config_key VARCHAR(200) NOT NULL,
  config_value VARCHAR(200) NOT NULL,
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  status TINYINT(1) NOT NULL DEFAULT 1,
  trash TINYINT(1) NOT NULL DEFAULT 0,
  FOREIGN KEY (tenant_id) REFERENCES tenants(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
