CREATE TABLE IF NOT EXISTS guest_action_queue (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  table_id VARCHAR(32) NOT NULL,
  message_type ENUM('waiter_call', 'bill_request') NOT NULL,
  message_text TEXT NOT NULL,
  otwierajacy_imie VARCHAR(100) NULL,
  otwierajacy_nazwisko VARCHAR(100) NULL,
  api_sent TINYINT(1) NOT NULL DEFAULT 0,
  status_kds TINYINT(1) NOT NULL DEFAULT 0,
  created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
  updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (id),
  KEY idx_guest_action_api_sent_created (api_sent, created_at),
  KEY idx_guest_action_status_kds_created (status_kds, created_at),
  KEY idx_guest_action_table_created (table_id, created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

