[
  {
    "type": "create_table",
    "description": "Create scheduleTimesheets table for weekly timesheet records",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'scheduleTimesheets'",
    "sql": "CREATE TABLE `scheduleTimesheets` (\n  `timesheetId` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `employeeId` int(10) unsigned NOT NULL COMMENT 'FK to kiosk_users.users.id (central user ID)',\n  `weekStartDate` date NOT NULL COMMENT 'Start of work week (store local)',\n  `weekEndDate` date NOT NULL COMMENT 'End of work week (store local)',\n  `scheduledTotalHours` decimal(6,2) NOT NULL DEFAULT 0.00 COMMENT 'Total scheduled hours',\n  `scheduledRegularHours` decimal(6,2) NOT NULL DEFAULT 0.00 COMMENT 'Scheduled regular hours',\n  `scheduledOvertimeHours` decimal(6,2) NOT NULL DEFAULT 0.00 COMMENT 'Scheduled overtime hours',\n  `scheduledDoubletimeHours` decimal(6,2) NOT NULL DEFAULT 0.00 COMMENT 'Scheduled double-time hours',\n  `totalHours` decimal(6,2) NOT NULL DEFAULT 0.00 COMMENT 'Total actual worked hours',\n  `regularHours` decimal(6,2) NOT NULL DEFAULT 0.00 COMMENT 'Actual regular hours',\n  `overtimeHours` decimal(6,2) NOT NULL DEFAULT 0.00 COMMENT 'Actual overtime hours',\n  `doubletimeHours` decimal(6,2) NOT NULL DEFAULT 0.00 COMMENT 'Actual double-time hours',\n  `totalPay` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT 'Calculated total pay',\n  `status` enum('pending','approved','exported') NOT NULL DEFAULT 'pending',\n  `approvedByUserId` int(10) unsigned DEFAULT NULL COMMENT 'User who approved timesheet',\n  `approved_at` timestamp NULL DEFAULT NULL COMMENT 'When timesheet was approved',\n  `exported_at` timestamp NULL DEFAULT NULL COMMENT 'When timesheet was exported',\n  `calculated_at` timestamp NULL DEFAULT NULL COMMENT 'When hours/pay were last calculated',\n  `calculationMetadataJson` text DEFAULT NULL COMMENT 'JSON metadata from last calculation (overtime rules applied, etc)',\n  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),\n  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),\n  PRIMARY KEY (`timesheetId`),\n  UNIQUE KEY `idx_employee_week` (`employeeId`, `weekStartDate`),\n  KEY `idx_status` (`status`),\n  KEY `idx_week` (`weekStartDate`),\n  KEY `idx_week_status` (`weekStartDate`, `status`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Weekly timesheet summaries for payroll'"
  }
]
