-- Modify the existing columns to support Georgian language
ALTER TABLE `rules` 
MODIFY `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
MODIFY `condition` text COLLATE utf8mb4_unicode_ci NOT NULL,
MODIFY `response_template` text COLLATE utf8mb4_unicode_ci NOT NULL;

-- Add new columns
ALTER TABLE `rules`
ADD COLUMN `category_id` bigint(20) UNSIGNED NULL AFTER `content_id`,
ADD COLUMN `subcategory_id` bigint(20) UNSIGNED NULL AFTER `category_id`,
ADD COLUMN `language` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT 'en' AFTER `response_template`,
ADD COLUMN `is_active` tinyint(1) DEFAULT 1 AFTER `language`,
ADD COLUMN `tags` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL AFTER `is_active`,
ADD CONSTRAINT `rules_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `rule_categories` (`id`) ON DELETE SET NULL,
ADD CONSTRAINT `rules_subcategory_id_foreign` FOREIGN KEY (`subcategory_id`) REFERENCES `rule_subcategories` (`id`) ON DELETE SET NULL,
ADD INDEX `rules_is_active_priority_index` (`is_active`, `priority`),
ADD INDEX `rules_language_is_active_index` (`language`, `is_active`),
ADD INDEX `rules_tags_index` (`tags`);
