-- ================================================================
-- Citizen System - PRINTER LOGS TABLE
-- Created: December 1, 2025
-- Description: Tracks all print jobs from FiveM printer system
-- ================================================================

USE pc_citizen;

-- Printer logs table
CREATE TABLE IF NOT EXISTS `printer_logs` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `player` VARCHAR(255) NOT NULL COMMENT 'Player name',
  `identifier` VARCHAR(255) DEFAULT NULL COMMENT 'Player identifier (steam, license, etc)',
  `print_type` ENUM('photo','document') NOT NULL,
  `content` TEXT COMMENT 'Print job content (JSON)',
  `cost` INT(11) DEFAULT 0 COMMENT 'Cost in dollars',
  `printer_net_id` VARCHAR(50) DEFAULT NULL COMMENT 'Printer network ID',
  `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `player` (`player`),
  KEY `identifier` (`identifier`),
  KEY `print_type` (`print_type`),
  KEY `created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Printer job logs';

-- Add index for faster queries
CREATE INDEX idx_player_date ON printer_logs(player, created_at DESC);
CREATE INDEX idx_type_date ON printer_logs(print_type, created_at DESC);

SELECT 'Printer logs table created successfully' AS status;
