CREATE TABLE IF NOT EXISTS field_options (
    id BIGSERIAL PRIMARY KEY,
    field_key VARCHAR(50) NOT NULL,
    code VARCHAR(50) NOT NULL,
    label VARCHAR(255) NOT NULL,
    display_order INT NOT NULL DEFAULT 0,
    status VARCHAR(20) NOT NULL DEFAULT 'ACTIVE' CHECK (status IN ('ACTIVE', 'INACTIVE')),
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at TIMESTAMPTZ,
    CONSTRAINT field_options_field_key_format CHECK (field_key ~ '^[a-z][a-z0-9_]*$'),
    CONSTRAINT field_options_unique_field_code UNIQUE (field_key, code)
);

CREATE INDEX IF NOT EXISTS idx_field_options_field_key ON field_options(field_key);
CREATE INDEX IF NOT EXISTS idx_field_options_status ON field_options(status);
CREATE INDEX IF NOT EXISTS idx_field_options_display_order ON field_options(display_order);

INSERT INTO field_options (field_key, code, label, display_order, status) VALUES
    ('education_level', 'NO_FORMAL', 'No formal education', 1, 'ACTIVE'),
    ('education_level', 'PRIMARY', 'Primary school', 2, 'ACTIVE'),
    ('education_level', 'SECONDARY', 'Secondary school', 3, 'ACTIVE'),
    ('education_level', 'HIGH_SCHOOL', 'High school', 4, 'ACTIVE'),
    ('education_level', 'VOCATIONAL', 'Vocational / technical', 5, 'ACTIVE'),
    ('education_level', 'BACHELOR', 'Bachelor''s degree', 6, 'ACTIVE'),
    ('education_level', 'MASTER', 'Master''s degree', 7, 'ACTIVE'),
    ('education_level', 'DOCTORATE', 'Doctorate', 8, 'ACTIVE'),
    ('education_level', 'OTHER', 'Other', 99, 'ACTIVE'),

    ('occupation', 'STUDENTS', 'Students (High school & University)', 1, 'ACTIVE'),
    ('occupation', 'JOB_SEEKERS', 'Job Seekers / Fresh Graduates', 2, 'ACTIVE'),
    ('occupation', 'WORKING_PROFESSIONALS', 'Working Professionals (Corporate/Office)', 3, 'ACTIVE'),
    ('occupation', 'GOVERNMENT_NGO', 'Government & NGO Workers', 4, 'ACTIVE'),
    ('occupation', 'ENTREPRENEURS', 'Entrepreneurs & Small Business Owners', 5, 'ACTIVE'),
    ('occupation', 'HOSPITALITY_TOURISM', 'Hospitality & Tourism Workers', 6, 'ACTIVE'),
    ('occupation', 'FREELANCERS_REMOTE', 'Freelancers / Remote Workers (Digital Economy)', 7, 'ACTIVE'),

    ('age_group', 'UNDER_13', 'Under 13', 1, 'ACTIVE'),
    ('age_group', '13_17', '13–17', 2, 'ACTIVE'),
    ('age_group', '18_24', '18–24', 3, 'ACTIVE'),
    ('age_group', '25_34', '25–34', 4, 'ACTIVE'),
    ('age_group', '35_44', '35–44', 5, 'ACTIVE'),
    ('age_group', '45_54', '45–54', 6, 'ACTIVE'),
    ('age_group', '55_PLUS', '55+', 7, 'ACTIVE'),

    ('learning_goal', 'EVERYDAY_CONVERSATION', 'Everyday conversation', 1, 'ACTIVE'),
    ('learning_goal', 'WORK_CAREER', 'Work and career', 2, 'ACTIVE'),
    ('learning_goal', 'ACADEMIC_STUDY', 'Academic study', 3, 'ACTIVE'),
    ('learning_goal', 'TRAVEL', 'Travel', 4, 'ACTIVE'),
    ('learning_goal', 'EXAM_PREP', 'Exam preparation', 5, 'ACTIVE'),
    ('learning_goal', 'PERSONAL_GROWTH', 'Personal growth', 6, 'ACTIVE'),
    ('learning_goal', 'OTHER', 'Other', 99, 'ACTIVE'),

    ('language_challange', 'PRONUNCIATION', 'Pronunciation', 1, 'ACTIVE'),
    ('language_challange', 'WORDS_GRAMMAR', 'Finding words or grammar quickly', 2, 'ACTIVE'),
    ('language_challange', 'CONFIDENCE', 'Feeling nervous or lacking confidence', 3, 'ACTIVE'),
    ('language_challange', 'ACCENTS_FAST_SPEECH', 'Understanding accents or fast speech', 4, 'ACTIVE'),
    ('language_challange', 'OTHER', 'Other', 99, 'ACTIVE'),

    ('language_goal', 'LEARN_TO_SPEAK_ENGLISH', 'Learn to Speak English', 1, 'ACTIVE'),
    ('language_goal', 'PRACTICE_TO_SPEAK_ENGLISH', 'Practice Speaking English', 2, 'ACTIVE'),
    ('language_goal', 'SKILL_BASED_COURSES', 'Skill-based Courses', 3, 'ACTIVE'),
    -- ('language_goal', 'GENERAL_SKILLS', 'General skills expansion', 4, 'ACTIVE'),
    -- ('language_goal', 'OTHER', 'Other', 99, 'ACTIVE'),

    ('favourite_topic', 'FOOD_COOKING', 'Food & Cooking', 1, 'ACTIVE'),
    ('favourite_topic', 'HOBBIES_SPORTS_MUSIC', 'Hobbies, Sports, Music', 2, 'ACTIVE'),
    ('favourite_topic', 'TECH_NEWS_BUSINESS', 'Tech, News, Business', 3, 'ACTIVE'),
    ('favourite_topic', 'TRAVEL_PLACES_CULTURE', 'Travel, Places, Culture', 4, 'ACTIVE'),
    ('favourite_topic', 'OTHER', 'Other', 99, 'ACTIVE'),

    ('country', 'AF', 'Afghanistan', 1, 'ACTIVE'),
    ('country', 'AL', 'Albania', 2, 'ACTIVE'),
    ('country', 'DZ', 'Algeria', 3, 'ACTIVE'),
    ('country', 'AD', 'Andorra', 4, 'ACTIVE'),
    ('country', 'AO', 'Angola', 5, 'ACTIVE'),
    ('country', 'AR', 'Argentina', 6, 'ACTIVE'),
    ('country', 'AM', 'Armenia', 7, 'ACTIVE'),
    ('country', 'AU', 'Australia', 8, 'ACTIVE'),
    ('country', 'AT', 'Austria', 9, 'ACTIVE'),
    ('country', 'AZ', 'Azerbaijan', 10, 'ACTIVE'),
    ('country', 'BH', 'Bahrain', 11, 'ACTIVE'),
    ('country', 'BD', 'Bangladesh', 12, 'ACTIVE'),
    ('country', 'BY', 'Belarus', 13, 'ACTIVE'),
    ('country', 'BE', 'Belgium', 14, 'ACTIVE'),
    ('country', 'BZ', 'Belize', 15, 'ACTIVE'),
    ('country', 'BJ', 'Benin', 16, 'ACTIVE'),
    ('country', 'BT', 'Bhutan', 17, 'ACTIVE'),
    ('country', 'BO', 'Bolivia', 18, 'ACTIVE'),
    ('country', 'BA', 'Bosnia and Herzegovina', 19, 'ACTIVE'),
    ('country', 'BW', 'Botswana', 20, 'ACTIVE'),
    ('country', 'BR', 'Brazil', 21, 'ACTIVE'),
    ('country', 'BN', 'Brunei', 22, 'ACTIVE'),
    ('country', 'BG', 'Bulgaria', 23, 'ACTIVE'),
    ('country', 'BF', 'Burkina Faso', 24, 'ACTIVE'),
    ('country', 'BI', 'Burundi', 25, 'ACTIVE'),
    ('country', 'KH', 'Cambodia', 26, 'ACTIVE'),
    ('country', 'CM', 'Cameroon', 27, 'ACTIVE'),
    ('country', 'CA', 'Canada', 28, 'ACTIVE'),
    ('country', 'TD', 'Chad', 29, 'ACTIVE'),
    ('country', 'CL', 'Chile', 30, 'ACTIVE'),
    ('country', 'CN', 'China', 31, 'ACTIVE'),
    ('country', 'CO', 'Colombia', 32, 'ACTIVE'),
    ('country', 'KM', 'Comoros', 33, 'ACTIVE'),
    ('country', 'CG', 'Congo', 34, 'ACTIVE'),
    ('country', 'CR', 'Costa Rica', 35, 'ACTIVE'),
    ('country', 'HR', 'Croatia', 36, 'ACTIVE'),
    ('country', 'CU', 'Cuba', 37, 'ACTIVE'),
    ('country', 'CY', 'Cyprus', 38, 'ACTIVE'),
    ('country', 'CZ', 'Czech Republic', 39, 'ACTIVE'),
    ('country', 'DK', 'Denmark', 40, 'ACTIVE'),
    ('country', 'DJ', 'Djibouti', 41, 'ACTIVE'),
    ('country', 'DO', 'Dominican Republic', 42, 'ACTIVE'),
    ('country', 'EC', 'Ecuador', 43, 'ACTIVE'),
    ('country', 'EG', 'Egypt', 44, 'ACTIVE'),
    ('country', 'SV', 'El Salvador', 45, 'ACTIVE'),
    ('country', 'ER', 'Eritrea', 46, 'ACTIVE'),
    ('country', 'EE', 'Estonia', 47, 'ACTIVE'),
    ('country', 'SZ', 'Eswatini', 48, 'ACTIVE'),
    ('country', 'ET', 'Ethiopia', 49, 'ACTIVE'),
    ('country', 'FI', 'Finland', 50, 'ACTIVE'),
    ('country', 'FR', 'France', 51, 'ACTIVE'),
    ('country', 'GA', 'Gabon', 52, 'ACTIVE'),
    ('country', 'GM', 'Gambia', 53, 'ACTIVE'),
    ('country', 'GE', 'Georgia', 54, 'ACTIVE'),
    ('country', 'DE', 'Germany', 55, 'ACTIVE'),
    ('country', 'GH', 'Ghana', 56, 'ACTIVE'),
    ('country', 'GR', 'Greece', 57, 'ACTIVE'),
    ('country', 'GT', 'Guatemala', 58, 'ACTIVE'),
    ('country', 'GN', 'Guinea', 59, 'ACTIVE'),
    ('country', 'HT', 'Haiti', 60, 'ACTIVE'),
    ('country', 'HN', 'Honduras', 61, 'ACTIVE'),
    ('country', 'HU', 'Hungary', 62, 'ACTIVE'),
    ('country', 'IS', 'Iceland', 63, 'ACTIVE'),
    ('country', 'IN', 'India', 64, 'ACTIVE'),
    ('country', 'ID', 'Indonesia', 65, 'ACTIVE'),
    ('country', 'IR', 'Iran', 66, 'ACTIVE'),
    ('country', 'IQ', 'Iraq', 67, 'ACTIVE'),
    ('country', 'IE', 'Ireland', 68, 'ACTIVE'),
    ('country', 'IL', 'Israel', 69, 'ACTIVE'),
    ('country', 'IT', 'Italy', 70, 'ACTIVE'),
    ('country', 'JM', 'Jamaica', 71, 'ACTIVE'),
    ('country', 'JP', 'Japan', 72, 'ACTIVE'),
    ('country', 'JO', 'Jordan', 73, 'ACTIVE'),
    ('country', 'KZ', 'Kazakhstan', 74, 'ACTIVE'),
    ('country', 'KE', 'Kenya', 75, 'ACTIVE'),
    ('country', 'KW', 'Kuwait', 76, 'ACTIVE'),
    ('country', 'KG', 'Kyrgyzstan', 77, 'ACTIVE'),
    ('country', 'LA', 'Laos', 78, 'ACTIVE'),
    ('country', 'LV', 'Latvia', 79, 'ACTIVE'),
    ('country', 'LB', 'Lebanon', 80, 'ACTIVE'),
    ('country', 'LR', 'Liberia', 81, 'ACTIVE'),
    ('country', 'LY', 'Libya', 82, 'ACTIVE'),
    ('country', 'LT', 'Lithuania', 83, 'ACTIVE'),
    ('country', 'LU', 'Luxembourg', 84, 'ACTIVE'),
    ('country', 'MG', 'Madagascar', 85, 'ACTIVE'),
    ('country', 'MW', 'Malawi', 86, 'ACTIVE'),
    ('country', 'MY', 'Malaysia', 87, 'ACTIVE'),
    ('country', 'MV', 'Maldives', 88, 'ACTIVE'),
    ('country', 'ML', 'Mali', 89, 'ACTIVE'),
    ('country', 'MT', 'Malta', 90, 'ACTIVE'),
    ('country', 'MX', 'Mexico', 91, 'ACTIVE'),
    ('country', 'MD', 'Moldova', 92, 'ACTIVE'),
    ('country', 'MC', 'Monaco', 93, 'ACTIVE'),
    ('country', 'MN', 'Mongolia', 94, 'ACTIVE'),
    ('country', 'MA', 'Morocco', 95, 'ACTIVE'),
    ('country', 'MZ', 'Mozambique', 96, 'ACTIVE'),
    ('country', 'MM', 'Myanmar', 97, 'ACTIVE'),
    ('country', 'NA', 'Namibia', 98, 'ACTIVE'),
    ('country', 'NP', 'Nepal', 99, 'ACTIVE'),
    ('country', 'NL', 'Netherlands', 100, 'ACTIVE'),
    ('country', 'NZ', 'New Zealand', 101, 'ACTIVE'),
    ('country', 'NI', 'Nicaragua', 102, 'ACTIVE'),
    ('country', 'NE', 'Niger', 103, 'ACTIVE'),
    ('country', 'NG', 'Nigeria', 104, 'ACTIVE'),
    ('country', 'KP', 'North Korea', 105, 'ACTIVE'),
    ('country', 'NO', 'Norway', 106, 'ACTIVE'),
    ('country', 'OM', 'Oman', 107, 'ACTIVE'),
    ('country', 'PK', 'Pakistan', 108, 'ACTIVE'),
    ('country', 'PA', 'Panama', 109, 'ACTIVE'),
    ('country', 'PY', 'Paraguay', 110, 'ACTIVE'),
    ('country', 'PE', 'Peru', 111, 'ACTIVE'),
    ('country', 'PH', 'Philippines', 112, 'ACTIVE'),
    ('country', 'PL', 'Poland', 113, 'ACTIVE'),
    ('country', 'PT', 'Portugal', 114, 'ACTIVE'),
    ('country', 'QA', 'Qatar', 115, 'ACTIVE'),
    ('country', 'RO', 'Romania', 116, 'ACTIVE'),
    ('country', 'RU', 'Russia', 117, 'ACTIVE'),
    ('country', 'RW', 'Rwanda', 118, 'ACTIVE'),
    ('country', 'SA', 'Saudi Arabia', 119, 'ACTIVE'),
    ('country', 'SN', 'Senegal', 120, 'ACTIVE'),
    ('country', 'RS', 'Serbia', 121, 'ACTIVE'),
    ('country', 'SG', 'Singapore', 122, 'ACTIVE'),
    ('country', 'SK', 'Slovakia', 123, 'ACTIVE'),
    ('country', 'SI', 'Slovenia', 124, 'ACTIVE'),
    ('country', 'SO', 'Somalia', 125, 'ACTIVE'),
    ('country', 'ZA', 'South Africa', 126, 'ACTIVE'),
    ('country', 'KR', 'South Korea', 127, 'ACTIVE'),
    ('country', 'ES', 'Spain', 128, 'ACTIVE'),
    ('country', 'LK', 'Sri Lanka', 129, 'ACTIVE'),
    ('country', 'SD', 'Sudan', 130, 'ACTIVE'),
    ('country', 'SE', 'Sweden', 131, 'ACTIVE'),
    ('country', 'CH', 'Switzerland', 132, 'ACTIVE'),
    ('country', 'SY', 'Syria', 133, 'ACTIVE'),
    ('country', 'TW', 'Taiwan', 134, 'ACTIVE'),
    ('country', 'TJ', 'Tajikistan', 135, 'ACTIVE'),
    ('country', 'TZ', 'Tanzania', 136, 'ACTIVE'),
    ('country', 'TH', 'Thailand', 137, 'ACTIVE'),
    ('country', 'TN', 'Tunisia', 138, 'ACTIVE'),
    ('country', 'TR', 'Turkey', 139, 'ACTIVE'),
    ('country', 'UG', 'Uganda', 140, 'ACTIVE'),
    ('country', 'UA', 'Ukraine', 141, 'ACTIVE'),
    ('country', 'AE', 'United Arab Emirates', 142, 'ACTIVE'),
    ('country', 'GB', 'United Kingdom', 143, 'ACTIVE'),
    ('country', 'US', 'United States', 144, 'ACTIVE'),
    ('country', 'UY', 'Uruguay', 145, 'ACTIVE'),
    ('country', 'UZ', 'Uzbekistan', 146, 'ACTIVE'),
    ('country', 'VE', 'Venezuela', 147, 'ACTIVE'),
    ('country', 'VN', 'Vietnam', 148, 'ACTIVE'),
    ('country', 'YE', 'Yemen', 149, 'ACTIVE'),
    ('country', 'ZM', 'Zambia', 150, 'ACTIVE'),
    ('country', 'ZW', 'Zimbabwe', 151, 'ACTIVE'),

    ('ethiopia_regions', 'ADDIS_ABABA', 'Addis Ababa', 1, 'ACTIVE'),
    ('ethiopia_regions', 'AFAR', 'Afar', 2, 'ACTIVE'),
    ('ethiopia_regions', 'AMHARA', 'Amhara', 3, 'ACTIVE'),
    ('ethiopia_regions', 'BENISHANGUL_GUMUZ', 'Benishangul-Gumuz', 4, 'ACTIVE'),
    ('ethiopia_regions', 'CENTRAL_ETHIOPIA', 'Central Ethiopia', 5, 'ACTIVE'),
    ('ethiopia_regions', 'DIRE_DAWA', 'Dire Dawa', 6, 'ACTIVE'),
    ('ethiopia_regions', 'GAMBELA', 'Gambela', 7, 'ACTIVE'),
    ('ethiopia_regions', 'HARARI', 'Harari', 8, 'ACTIVE'),
    ('ethiopia_regions', 'OROMIA', 'Oromia', 9, 'ACTIVE'),
    ('ethiopia_regions', 'SIDAMA', 'Sidama', 10, 'ACTIVE'),
    ('ethiopia_regions', 'SOMALI', 'Somali', 11, 'ACTIVE'),
    ('ethiopia_regions', 'SOUTH_ETHIOPIA', 'South Ethiopia', 12, 'ACTIVE'),
    ('ethiopia_regions', 'SOUTH_WEST_ETHIOPIA_PEOPLES', 'South West Ethiopia Peoples', 13, 'ACTIVE'),
    ('ethiopia_regions', 'TIGRAY', 'Tigray', 14, 'ACTIVE');
