-- Create migrations table first (required by CodeIgniter)
CREATE TABLE IF NOT EXISTS `migrations` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `version` varchar(255) NOT NULL,
  `class` varchar(255) NOT NULL,
  `group` varchar(255) NOT NULL,
  `namespace` varchar(255) NOT NULL,
  `time` int(11) NOT NULL,
  `batch` int(11) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Create listing_types table
CREATE TABLE IF NOT EXISTS `listing_types` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `type_name` varchar(100) NOT NULL,
  `category` varchar(50) NOT NULL,
  `field_config` text DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Insert some default listing types (optional)
INSERT INTO `listing_types` (`type_name`, `category`, `created_at`) VALUES
('Sell', 'general', NOW()),
('Rent', 'general', NOW())
ON DUPLICATE KEY UPDATE `type_name`=VALUES(`type_name`);
