-- Ensure the default outlet exists for installs created from complete_schema.sql snapshots.
-- Fresh installs can otherwise miss outlet ID 1 if the outlet seed migration was marked as already executed.

CREATE TABLE IF NOT EXISTS `outlets` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `address` text DEFAULT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `status` enum('active','inactive') DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `outlets` (`id`, `name`, `address`, `phone`, `status`, `created_at`)
SELECT 1, 'Main Outlet', 'Head Office', '', 'active', NOW()
WHERE NOT EXISTS (
    SELECT 1 FROM `outlets` WHERE `id` = 1
);
