
CREATE TABLE IF NOT EXISTS `gift_codes` (
  `id` INT PRIMARY KEY AUTO_INCREMENT,
  `code` VARCHAR(255) NOT NULL UNIQUE,
  `package_id` INT NOT NULL,
  `stripe_checkout_session_id` VARCHAR(255) NOT NULL,
  `is_redeemed` BOOLEAN DEFAULT FALSE,
  `redeemed_by_client_id` INT,
  `redeemed_at` DATETIME,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  FOREIGN KEY (`package_id`) REFERENCES `service_packages`(`id`),
  FOREIGN KEY (`redeemed_by_client_id`) REFERENCES `clients`(`id`)
);
