--
-- Host: localhost    Database: multitienda
-- ------------------------------------------------------


--
-- Table structure for table `categorias`
--

CREATE TABLE `categorias` (
  `id` int NOT NULL AUTO_INCREMENT,
  `tienda_id` int NOT NULL,
  `nombre` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL,
  `orden` int DEFAULT '0',
  `activo` tinyint(1) DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `tienda_id` (`tienda_id`),
  CONSTRAINT `categorias_ibfk_1` FOREIGN KEY (`tienda_id`) REFERENCES `tiendas` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `categorias`
--


--
-- Table structure for table `pagos`
--

CREATE TABLE `pagos` (
  `id` int NOT NULL AUTO_INCREMENT,
  `tienda_id` int NOT NULL,
  `comprobante` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `monto` decimal(8,2) DEFAULT '0.00',
  `nota` text COLLATE utf8mb4_unicode_ci,
  `estado` enum('pendiente','verificado','rechazado') COLLATE utf8mb4_unicode_ci DEFAULT 'pendiente',
  `subido_en` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `tienda_id` (`tienda_id`),
  CONSTRAINT `pagos_ibfk_1` FOREIGN KEY (`tienda_id`) REFERENCES `tiendas` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `pagos`
--


--
-- Table structure for table `pedidos`
--

CREATE TABLE `pedidos` (
  `id` int NOT NULL AUTO_INCREMENT,
  `tienda_id` int NOT NULL,
  `cliente_nombre` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `cliente_tel` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `items` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `total` decimal(8,2) DEFAULT '0.00',
  `estado` enum('nuevo','visto','completado','cancelado') COLLATE utf8mb4_unicode_ci DEFAULT 'nuevo',
  `creado_en` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `tienda_id` (`tienda_id`),
  CONSTRAINT `pedidos_ibfk_1` FOREIGN KEY (`tienda_id`) REFERENCES `tiendas` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `pedidos`
--


--
-- Table structure for table `productos`
--

CREATE TABLE `productos` (
  `id` int NOT NULL AUTO_INCREMENT,
  `tienda_id` int NOT NULL,
  `categoria_id` int NOT NULL,
  `nombre` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL,
  `descripcion` text COLLATE utf8mb4_unicode_ci,
  `precio` decimal(8,2) NOT NULL DEFAULT '0.00',
  `precio_antes` decimal(8,2) DEFAULT NULL,
  `tallas` varchar(120) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `colores` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `imagen` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `destacado` tinyint(1) DEFAULT '0',
  `activo` tinyint(1) DEFAULT '1',
  `orden` int DEFAULT '0',
  `creado_en` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `tienda_id` (`tienda_id`),
  KEY `categoria_id` (`categoria_id`),
  CONSTRAINT `productos_ibfk_1` FOREIGN KEY (`tienda_id`) REFERENCES `tiendas` (`id`) ON DELETE CASCADE,
  CONSTRAINT `productos_ibfk_2` FOREIGN KEY (`categoria_id`) REFERENCES `categorias` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `productos`
--


--
-- Table structure for table `suscripciones`
--

CREATE TABLE `suscripciones` (
  `id` int NOT NULL AUTO_INCREMENT,
  `tienda_id` int NOT NULL,
  `mes_inicio` date NOT NULL,
  `estado` enum('activo','pendiente','vencido') COLLATE utf8mb4_unicode_ci DEFAULT 'activo',
  `creado_en` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `tienda_id` (`tienda_id`),
  CONSTRAINT `suscripciones_ibfk_1` FOREIGN KEY (`tienda_id`) REFERENCES `tiendas` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `suscripciones`
--


--
-- Table structure for table `tiendas`
--

CREATE TABLE `tiendas` (
  `id` int NOT NULL AUTO_INCREMENT,
  `slug` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL,
  `nombre` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slogan` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `whatsapp` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `instagram` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `facebook` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `color1` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT '#e91e8c',
  `color2` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT '#222222',
  `banner_texto` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT 'Bienvenido',
  `banner_subtexto` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `logo` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `banner` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `activa` tinyint(1) DEFAULT '1',
  `creado_en` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `slug` (`slug`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `tiendas`
--



