-- VASE POS · TANDA 05 · Idempotencia de pagos adicionales
-- Ejecutar primero en phpMyAdmin sobre la BD VASE.
-- No modifica ventas antiguas ni borra registros.
CREATE TABLE IF NOT EXISTS `pos_pago_intentos` (
  `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `venta_id` BIGINT UNSIGNED NOT NULL,
  `clave` VARCHAR(80) NOT NULL,
  `metodo` VARCHAR(30) NOT NULL,
  `monto` DECIMAL(15,2) NOT NULL,
  `referencia` VARCHAR(100) DEFAULT NULL,
  `venta_pago_id` BIGINT UNSIGNED DEFAULT NULL,
  `created_at` TIMESTAMP NULL DEFAULT NULL,
  `updated_at` TIMESTAMP NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `pos_pago_intentos_venta_clave_unica` (`venta_id`,`clave`),
  KEY `pos_pago_intentos_pago_idx` (`venta_pago_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SHOW TABLES LIKE 'pos_pago_intentos';
