USE aihub;
SET FOREIGN_KEY_CHECKS=0;
-- Drop obsolete tables
DROP TABLE IF EXISTS missions;
DROP TABLE IF EXISTS user_missions;
DROP TABLE IF EXISTS surveys;
DROP TABLE IF EXISTS survey_questions;
DROP TABLE IF EXISTS survey_responses;
DROP TABLE IF EXISTS survey_answers;

-- Delete subscription plans related to surveys (if any)
DELETE FROM subscription_plans WHERE plan_type = 'surveys';

-- Remove module entries for missions, subscriptions, surveys
DELETE FROM modules WHERE slug IN ('missions', 'subscriptions', 'surveys');

-- Insert new SocialMedis hub module
INSERT IGNORE INTO modules (slug, name, icon, description, status, is_core, sort_order)
VALUES ('socialmedis', 'SocialMedis', '🌐', 'External social‑media links hub', 'enabled', 0, 6);
SET FOREIGN_KEY_CHECKS=1;
