211 lines
5.7 KiB
SQL
211 lines
5.7 KiB
SQL
-- phpMyAdmin SQL Dump
|
|
-- version 5.2.2
|
|
-- https://www.phpmyadmin.net/
|
|
--
|
|
-- Host: localhost:3306
|
|
-- Tempo de geração: 23-Fev-2026 às 10:41
|
|
-- Versão do servidor: 8.0.45
|
|
-- versão do PHP: 8.3.30
|
|
|
|
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
|
START TRANSACTION;
|
|
SET time_zone = "+00:00";
|
|
|
|
|
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
|
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
|
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
|
/*!40101 SET NAMES utf8mb4 */;
|
|
|
|
--
|
|
-- Base de dados: `agenciac_comia`
|
|
--
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Estrutura da tabela `attendances`
|
|
--
|
|
|
|
CREATE TABLE `attendances` (
|
|
`id` varchar(36) NOT NULL,
|
|
`tenant_id` varchar(36) NOT NULL,
|
|
`user_id` varchar(36) NOT NULL,
|
|
`summary` text,
|
|
`score` int DEFAULT NULL,
|
|
`first_response_time_min` int DEFAULT '0',
|
|
`handling_time_min` int DEFAULT '0',
|
|
`funnel_stage` enum('Sem atendimento','Identificação','Negociação','Ganhos','Perdidos') NOT NULL,
|
|
`origin` enum('WhatsApp','Instagram','Website','LinkedIn','Indicação') NOT NULL,
|
|
`product_requested` varchar(255) DEFAULT NULL,
|
|
`product_sold` varchar(255) DEFAULT NULL,
|
|
`converted` tinyint(1) DEFAULT '0',
|
|
`attention_points` json DEFAULT NULL,
|
|
`improvement_points` json DEFAULT NULL,
|
|
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
--
|
|
-- Extraindo dados da tabela `attendances`
|
|
--
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Estrutura da tabela `teams`
|
|
--
|
|
|
|
CREATE TABLE `teams` (
|
|
`id` varchar(36) NOT NULL,
|
|
`tenant_id` varchar(36) NOT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`description` text,
|
|
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
--
|
|
-- Extraindo dados da tabela `teams`
|
|
--
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Estrutura da tabela `tenants`
|
|
--
|
|
|
|
CREATE TABLE `tenants` (
|
|
`id` varchar(36) NOT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`slug` varchar(255) NOT NULL,
|
|
`admin_email` varchar(255) DEFAULT NULL,
|
|
`logo_url` text,
|
|
`status` enum('active','inactive','trial') DEFAULT 'active',
|
|
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
|
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
--
|
|
-- Extraindo dados da tabela `tenants`
|
|
--
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Estrutura da tabela `pending_registrations`
|
|
--
|
|
|
|
CREATE TABLE `pending_registrations` (
|
|
`email` varchar(255) NOT NULL,
|
|
`password_hash` varchar(255) NOT NULL,
|
|
`full_name` varchar(255) NOT NULL,
|
|
`organization_name` varchar(255) NOT NULL,
|
|
`verification_code` varchar(10) NOT NULL,
|
|
`expires_at` timestamp NOT NULL,
|
|
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`email`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Estrutura da tabela `password_resets`
|
|
--
|
|
|
|
CREATE TABLE `password_resets` (
|
|
`email` varchar(255) NOT NULL,
|
|
`token` varchar(255) NOT NULL,
|
|
`expires_at` timestamp NOT NULL,
|
|
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`token`),
|
|
KEY `email` (`email`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Estrutura da tabela `users`
|
|
--
|
|
|
|
CREATE TABLE `users` (
|
|
`id` varchar(36) NOT NULL,
|
|
`tenant_id` varchar(36) DEFAULT NULL,
|
|
`team_id` varchar(36) DEFAULT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`email` varchar(255) NOT NULL,
|
|
`password_hash` varchar(255) NOT NULL DEFAULT 'hash_placeholder',
|
|
`slug` varchar(255) UNIQUE DEFAULT NULL,
|
|
`avatar_url` text,
|
|
`role` enum('super_admin','admin','manager','agent') NOT NULL DEFAULT 'agent',
|
|
`bio` text,
|
|
`status` enum('active','inactive') DEFAULT 'active',
|
|
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
--
|
|
-- Extraindo dados da tabela `users`
|
|
--
|
|
|
|
--
|
|
-- Índices para tabelas despejadas
|
|
--
|
|
|
|
--
|
|
-- Índices para tabela `attendances`
|
|
--
|
|
ALTER TABLE `attendances`
|
|
ADD PRIMARY KEY (`id`),
|
|
ADD KEY `tenant_id` (`tenant_id`),
|
|
ADD KEY `user_id` (`user_id`);
|
|
|
|
--
|
|
-- Índices para tabela `teams`
|
|
--
|
|
ALTER TABLE `teams`
|
|
ADD PRIMARY KEY (`id`),
|
|
ADD KEY `tenant_id` (`tenant_id`);
|
|
|
|
--
|
|
-- Índices para tabela `tenants`
|
|
--
|
|
ALTER TABLE `tenants`
|
|
ADD PRIMARY KEY (`id`),
|
|
ADD UNIQUE KEY `slug` (`slug`);
|
|
|
|
--
|
|
-- Índices para tabela `users`
|
|
--
|
|
ALTER TABLE `users`
|
|
ADD PRIMARY KEY (`id`),
|
|
ADD UNIQUE KEY `email` (`email`),
|
|
ADD KEY `tenant_id` (`tenant_id`),
|
|
ADD KEY `team_id` (`team_id`);
|
|
|
|
--
|
|
-- Restrições para despejos de tabelas
|
|
--
|
|
|
|
--
|
|
-- Limitadores para a tabela `attendances`
|
|
--
|
|
ALTER TABLE `attendances`
|
|
ADD CONSTRAINT `attendances_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE,
|
|
ADD CONSTRAINT `attendances_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
|
|
|
|
--
|
|
-- Limitadores para a tabela `teams`
|
|
--
|
|
ALTER TABLE `teams`
|
|
ADD CONSTRAINT `teams_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;
|
|
|
|
--
|
|
-- Limitadores para a tabela `users`
|
|
--
|
|
ALTER TABLE `users`
|
|
ADD CONSTRAINT `users_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE,
|
|
ADD CONSTRAINT `users_ibfk_2` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON DELETE SET NULL;
|
|
COMMIT;
|
|
|
|
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
|
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|