feat: implement comprehensive master data module with CRUD services, controllers, and entities

This commit is contained in:
Syed Waseem
2026-07-29 15:13:41 +05:30
parent e8e6da31be
commit 046d36d069
54 changed files with 2650 additions and 793 deletions
+257 -38
View File
@@ -60,125 +60,280 @@ CREATE TABLE IF NOT EXISTS tenant.tbl_tenants (
CREATE TABLE IF NOT EXISTS masters.tbl_membership_tiers (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"tenantId" UUID NOT NULL REFERENCES tenant.tbl_tenants(id) ON DELETE CASCADE,
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_tbl_membership_tiers_tenant ON masters.tbl_membership_tiers("tenantId");
CREATE TABLE IF NOT EXISTS masters.tbl_customer_values (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"tenantId" UUID NOT NULL REFERENCES tenant.tbl_tenants(id) ON DELETE CASCADE,
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_tbl_customer_values_tenant ON masters.tbl_customer_values("tenantId");
CREATE TABLE IF NOT EXISTS masters.tbl_regions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"tenantId" UUID NOT NULL REFERENCES tenant.tbl_tenants(id) ON DELETE CASCADE,
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_tbl_regions_tenant ON masters.tbl_regions("tenantId");
CREATE TABLE IF NOT EXISTS masters.tbl_trip_purposes (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"tenantId" UUID NOT NULL REFERENCES tenant.tbl_tenants(id) ON DELETE CASCADE,
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_tbl_trip_purposes_tenant ON masters.tbl_trip_purposes("tenantId");
CREATE TABLE IF NOT EXISTS masters.tbl_cabin_classes (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"tenantId" UUID NOT NULL REFERENCES tenant.tbl_tenants(id) ON DELETE CASCADE,
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_tbl_cabin_classes_tenant ON masters.tbl_cabin_classes("tenantId");
CREATE TABLE IF NOT EXISTS masters.tbl_passenger_types (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"tenantId" UUID NOT NULL REFERENCES tenant.tbl_tenants(id) ON DELETE CASCADE,
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_tbl_passenger_types_tenant ON masters.tbl_passenger_types("tenantId");
CREATE TABLE IF NOT EXISTS masters.tbl_ancillary_purchases (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"tenantId" UUID NOT NULL REFERENCES tenant.tbl_tenants(id) ON DELETE CASCADE,
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_tbl_ancillary_purchases_tenant ON masters.tbl_ancillary_purchases("tenantId");
CREATE TABLE IF NOT EXISTS masters.tbl_revenue_segments (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"tenantId" UUID NOT NULL REFERENCES tenant.tbl_tenants(id) ON DELETE CASCADE,
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_tbl_revenue_segments_tenant ON masters.tbl_revenue_segments("tenantId");
CREATE TABLE IF NOT EXISTS masters.tbl_jurisdictions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_rules_categories (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"tenantId" UUID NOT NULL REFERENCES tenant.tbl_tenants(id) ON DELETE CASCADE,
code VARCHAR(100) NOT NULL,
code VARCHAR(100) NOT NULL UNIQUE,
name VARCHAR(150) NOT NULL,
"tableName" VARCHAR,
description TEXT,
"displayOrder" INT DEFAULT 0,
"isActive" BOOLEAN DEFAULT TRUE,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_tbl_rules_categories_tenant ON masters.tbl_rules_categories("tenantId");
CREATE UNIQUE INDEX IF NOT EXISTS uq_tbl_rules_categories_tenant_code
ON masters.tbl_rules_categories("tenantId", code);
CREATE TABLE IF NOT EXISTS masters.tbl_rule_categories_values (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"tenantId" UUID NOT NULL REFERENCES tenant.tbl_tenants(id) ON DELETE CASCADE,
"categoryId" UUID NOT NULL REFERENCES masters.tbl_rules_categories(id) ON DELETE CASCADE,
code VARCHAR(100),
value VARCHAR(255) NOT NULL,
"displayOrder" INT DEFAULT 0,
"isActive" BOOLEAN DEFAULT TRUE,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
CREATE TABLE IF NOT EXISTS masters.tbl_booking_channels (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_flight_types (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_journey_types (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_fare_flexibilities (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_carrier_types (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_special_assistance_types (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_delay_reasons (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_delay_durations (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_extraordinary_circumstances (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_cancellation_reasons (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_diversion_reasons (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_missed_connection_reasons (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_compensation_eligibilities (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_compensation_types (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_refund_types (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_flight_disruption_types (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_airline_responsibilities (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_weather_conditions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_atc_restrictions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_technical_fault_categories (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_tbl_rule_categories_values_tenant ON masters.tbl_rule_categories_values("tenantId");
CREATE INDEX IF NOT EXISTS idx_tbl_rule_categories_values_category ON masters.tbl_rule_categories_values("categoryId");
CREATE TABLE IF NOT EXISTS masters.tbl_operators (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"tenantId" UUID NOT NULL REFERENCES tenant.tbl_tenants(id) ON DELETE CASCADE,
code VARCHAR(50) NOT NULL,
code VARCHAR(50) NOT NULL UNIQUE,
name VARCHAR(100) NOT NULL,
symbol VARCHAR(20),
"dataTypes" TEXT[],
@@ -187,9 +342,6 @@ CREATE TABLE IF NOT EXISTS masters.tbl_operators (
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_tbl_operators_tenant ON masters.tbl_operators("tenantId");
CREATE UNIQUE INDEX IF NOT EXISTS uq_tbl_operators_tenant_code
ON masters.tbl_operators("tenantId", code);
-- ─── Cohorts ────────────────────────────────────────────────────────────────
@@ -252,3 +404,70 @@ CREATE TABLE IF NOT EXISTS cohort.tbl_cohort_trip_purposes (
"tripPurposeId" UUID NOT NULL REFERENCES masters.tbl_trip_purposes(id) ON DELETE CASCADE,
PRIMARY KEY ("cohortId", "tripPurposeId")
);
-- ─── Action Builder & Metadata-Driven Field Definitions ────────────────────
CREATE TABLE IF NOT EXISTS masters.tbl_field_definitions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"actionTypeId" UUID NOT NULL REFERENCES masters.tbl_action_types(id) ON DELETE CASCADE,
"fieldCode" VARCHAR NOT NULL,
"fieldName" VARCHAR NOT NULL,
"fieldType" VARCHAR NOT NULL,
"lookupSource" VARCHAR,
"isRequired" BOOLEAN NOT NULL DEFAULT false,
"defaultValue" TEXT,
placeholder VARCHAR,
"helpText" TEXT,
width VARCHAR NOT NULL DEFAULT 'full',
section VARCHAR,
"displayOrder" INT NOT NULL DEFAULT 0,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"validationJson" JSONB,
"visibilityConditionJson" JSONB,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE UNIQUE INDEX IF NOT EXISTS uq_field_definition_action_type_code
ON masters.tbl_field_definitions("actionTypeId", "fieldCode");
CREATE TABLE IF NOT EXISTS masters.tbl_action_submissions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"categoryId" UUID NOT NULL REFERENCES masters.tbl_action_categories(id) ON DELETE CASCADE,
"actionTypeId" UUID NOT NULL REFERENCES masters.tbl_action_types(id) ON DELETE CASCADE,
data JSONB NOT NULL,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_refund_bases (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_currencies (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
symbol VARCHAR,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS masters.tbl_refund_methods (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label VARCHAR NOT NULL,
value VARCHAR NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
+610
View File
@@ -0,0 +1,610 @@
-- =============================================================================
-- AeroResolve Master Data Seed Script
-- PostgreSQL 14+
-- =============================================================================
-- 1. Action Categories
INSERT INTO masters.tbl_action_categories (code, name, "displayOrder", "isActive")
SELECT code, name, displayOrder, true FROM (VALUES
('REFUNDS', 'Refunds', 1),
('CASH_COMPENSATION', 'Cash Compensation', 2),
('TRAVEL_CREDITS', 'Travel Credits', 3),
('LOYALTY_BENEFITS', 'Loyalty Benefits', 4),
('ACCOMMODATION', 'Accommodation', 5),
('MEALS', 'Meals', 6),
('TRANSPORTATION', 'Transportation', 7),
('REBOOKING_TRAVEL', 'Rebooking & Travel', 8),
('UPGRADES', 'Upgrades', 9),
('ANCILLARY_RECOVERY', 'Ancillary Recovery', 10),
('COMMUNICATION', 'Communication', 11),
('WORKFLOW', 'Workflow', 12),
('FINANCE', 'Finance', 13),
('SYSTEM_INTEGRATION', 'System Integration', 14)
) AS t(code, name, displayOrder)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_action_categories WHERE masters.tbl_action_categories.code = t.code);
-- 2. Action Types
INSERT INTO masters.tbl_action_types (code, "categoryId", name, "displayOrder", "isActive")
SELECT v.code, c.id, v.name, v.display_order, true
FROM (VALUES
-- Refunds
('FULL_TICKET_REFUND', 'REFUNDS', 'Full Ticket Refund', 1),
('PARTIAL_TICKET_REFUND', 'REFUNDS', 'Partial Ticket Refund', 2),
('TAX_REFUND', 'REFUNDS', 'Tax Refund', 3),
('ANCILLARY_REFUND', 'REFUNDS', 'Ancillary Refund', 4),
('BAGGAGE_FEE_REFUND', 'REFUNDS', 'Baggage Fee Refund', 5),
('CABIN_DOWNGRADE_REFUND', 'REFUNDS', 'Cabin Downgrade Refund', 6),
-- Cash Compensation
('REGULATORY_COMPENSATION', 'CASH_COMPENSATION', 'Regulatory Compensation', 1),
('AIRLINE_GOODWILL_CASH', 'CASH_COMPENSATION', 'Airline Goodwill Cash', 2),
('EX_GRATIA_COMPENSATION', 'CASH_COMPENSATION', 'Ex-Gratia Compensation', 3),
-- Travel Credits
('TRAVEL_VOUCHER', 'TRAVEL_CREDITS', 'Travel Voucher', 1),
('FUTURE_TRAVEL_CREDIT', 'TRAVEL_CREDITS', 'Future Travel Credit', 2),
('PROMO_CODE', 'TRAVEL_CREDITS', 'Promo Code', 3),
('DISCOUNT_COUPON', 'TRAVEL_CREDITS', 'Discount Coupon', 4),
-- Loyalty Benefits
('AWARD_MILES', 'LOYALTY_BENEFITS', 'Award Miles', 1),
('BONUS_MILES', 'LOYALTY_BENEFITS', 'Bonus Miles', 2),
('TIER_POINTS', 'LOYALTY_BENEFITS', 'Tier Points', 3),
('TIER_UPGRADE', 'LOYALTY_BENEFITS', 'Tier Upgrade', 4),
-- Accommodation
('HOTEL_ACCOMMODATION', 'ACCOMMODATION', 'Hotel Accommodation', 1),
('AIRPORT_HOTEL', 'ACCOMMODATION', 'Airport Hotel', 2),
-- Meals
('MEAL_VOUCHER', 'MEALS', 'Meal Voucher', 1),
('RESTAURANT_VOUCHER', 'MEALS', 'Restaurant Voucher', 2),
('REFRESHMENT_COUPON', 'MEALS', 'Refreshment Coupon', 3),
-- Transportation
('TAXI', 'TRANSPORTATION', 'Taxi', 1),
('AIRPORT_TRANSFER', 'TRANSPORTATION', 'Airport Transfer', 2),
('BUS_TRANSFER', 'TRANSPORTATION', 'Bus Transfer', 3),
('TRAIN_TICKET', 'TRANSPORTATION', 'Train Ticket', 4),
('CHAUFFEUR_SERVICE', 'TRANSPORTATION', 'Chauffeur Service', 5),
-- Rebooking & Travel
('AUTO_REBOOK', 'REBOOKING_TRAVEL', 'Auto Rebook', 1),
('PRIORITY_REBOOKING', 'REBOOKING_TRAVEL', 'Priority Rebooking', 2),
('OPEN_TICKET', 'REBOOKING_TRAVEL', 'Open Ticket', 3),
('ALTERNATE_AIRLINE', 'REBOOKING_TRAVEL', 'Alternate Airline', 4),
-- Upgrades
('CABIN_UPGRADE', 'UPGRADES', 'Cabin Upgrade', 1),
('SEAT_UPGRADE', 'UPGRADES', 'Seat Upgrade', 2),
('LOUNGE_ACCESS', 'UPGRADES', 'Lounge Access', 3),
('FAST_TRACK_SECURITY', 'UPGRADES', 'Fast Track Security', 4),
('PRIORITY_BOARDING', 'UPGRADES', 'Priority Boarding', 5),
-- Ancillary Recovery
('COMPLIMENTARY_WIFI', 'ANCILLARY_RECOVERY', 'Complimentary Wi-Fi', 1),
('FREE_BAGGAGE', 'ANCILLARY_RECOVERY', 'Free Baggage', 2),
('COMPLIMENTARY_MEAL', 'ANCILLARY_RECOVERY', 'Complimentary Meal', 3),
('SEAT_SELECTION', 'ANCILLARY_RECOVERY', 'Seat Selection', 4),
('CARBON_OFFSET_CREDIT', 'ANCILLARY_RECOVERY', 'Carbon Offset Credit', 5),
-- Communication
('PASSENGER_NOTIFICATION', 'COMMUNICATION', 'Passenger Notification', 1),
('AGENT_NOTIFICATION', 'COMMUNICATION', 'Agent Notification', 2),
('MANAGEMENT_ALERT', 'COMMUNICATION', 'Management Alert', 3),
-- Workflow
('AUTO_APPROVE', 'WORKFLOW', 'Auto Approve', 1),
('MANUAL_REVIEW', 'WORKFLOW', 'Manual Review', 2),
('ESCALATE', 'WORKFLOW', 'Escalate', 3),
('CREATE_CASE', 'WORKFLOW', 'Create Case', 4),
('HOLD_FOR_INVESTIGATION', 'WORKFLOW', 'Hold for Investigation', 5),
-- Finance
('TRIGGER_PAYMENT', 'FINANCE', 'Trigger Payment', 1),
('GENERATE_CREDIT_NOTE', 'FINANCE', 'Generate Credit Note', 2),
('GENERATE_INVOICE', 'FINANCE', 'Generate Invoice', 3),
('WRITE_OFF', 'FINANCE', 'Write-off', 4),
-- System Integration
('UPDATE_CRM', 'SYSTEM_INTEGRATION', 'Update CRM', 1),
('UPDATE_LOYALTY', 'SYSTEM_INTEGRATION', 'Update Loyalty', 2),
('UPDATE_PSS', 'SYSTEM_INTEGRATION', 'Update PSS', 3),
('CREATE_AUDIT_RECORD', 'SYSTEM_INTEGRATION', 'Create Audit Record', 4),
('TRIGGER_WEBHOOK_API', 'SYSTEM_INTEGRATION', 'Trigger Webhook / API', 5)
) AS v(code, cat_code, name, display_order)
JOIN masters.tbl_action_categories c ON c.code = v.cat_code
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_action_types WHERE masters.tbl_action_types.code = v.code);
-- 3. Membership Tiers
INSERT INTO masters.tbl_membership_tiers (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Platinum', 'platinum'),
('Gold', 'gold'),
('Silver', 'silver'),
('Bronze', 'bronze'),
('Basic', 'basic'),
('Non-Member', 'non-member')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_membership_tiers WHERE masters.tbl_membership_tiers.value = t.value);
-- 4. Customer Values
INSERT INTO masters.tbl_customer_values (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('High Value', 'high'),
('Medium Value', 'medium'),
('Low Value', 'low')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_customer_values WHERE masters.tbl_customer_values.value = t.value);
-- 5. Regions
INSERT INTO masters.tbl_regions (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Global', 'global'),
('Americas', 'americas'),
('Europe', 'europe'),
('Middle East', 'middle-east'),
('Asia Pacific', 'asia-pacific'),
('Africa', 'africa')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_regions WHERE masters.tbl_regions.value = t.value);
-- 6. Trip Purposes
INSERT INTO masters.tbl_trip_purposes (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Business', 'business'),
('Leisure', 'leisure'),
('Corporate', 'corporate'),
('Government', 'government')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_trip_purposes WHERE masters.tbl_trip_purposes.value = t.value);
-- 7. Cabin Classes
INSERT INTO masters.tbl_cabin_classes (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('First Class', 'first-class'),
('Business Class', 'business-class'),
('Premium Economy', 'premium-economy'),
('Economy', 'economy')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_cabin_classes WHERE masters.tbl_cabin_classes.value = t.value);
-- 8. Passenger Types
INSERT INTO masters.tbl_passenger_types (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Adult', 'adult'),
('Child', 'child'),
('Infant', 'infant'),
('Senior Citizen', 'senior')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_passenger_types WHERE masters.tbl_passenger_types.value = t.value);
-- 9. Ancillary Purchases
INSERT INTO masters.tbl_ancillary_purchases (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Preferred Seat', 'preferred-seat'),
('Extra Legroom', 'extra-legroom'),
('Wi-Fi', 'wi-fi'),
('Lounge Access', 'lounge-access'),
('Priority Boarding', 'priority-boarding'),
('Fast Track', 'fast-track'),
('Paid Meal', 'paid-meal'),
('Special Meal', 'special-meal'),
('Extra Baggage', 'extra-baggage'),
('Upgrade Purchase', 'upgrade-purchase'),
('Airport Transfer', 'airport-transfer'),
('Chauffeur Service', 'chauffeur-service'),
('Sports Equipment', 'sports-equipment'),
('Musical Instrument', 'musical-instrument'),
('In-flight Entertainment', 'in-flight-entertainment'),
('Power Outlet', 'power-outlet'),
('Carbon Offset', 'carbon-offset')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_ancillary_purchases WHERE masters.tbl_ancillary_purchases.value = t.value);
-- 10. Revenue Segments
INSERT INTO masters.tbl_revenue_segments (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('High Value', 'high'),
('Medium Value', 'medium'),
('Low Value', 'low')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_revenue_segments WHERE masters.tbl_revenue_segments.value = t.value);
-- 11. Jurisdictions
INSERT INTO masters.tbl_jurisdictions (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('United Arab Emirates', 'uae'),
('European Union', 'eu'),
('United States', 'us'),
('United Kingdom', 'uk'),
('India', 'india'),
('Asia Pacific', 'apac'),
('Global', 'global')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_jurisdictions WHERE masters.tbl_jurisdictions.value = t.value);
-- 12. Rule Categories
INSERT INTO masters.tbl_rules_categories (code, name, "tableName", description, "displayOrder", "isActive")
SELECT code, name, "tableName", description, "displayOrder", true FROM (VALUES
('passenger-type', 'Passenger Type', 'tbl_passenger_types', 'Passenger Type master', 1),
('cabin-class', 'Cabin Class', 'tbl_cabin_classes', 'Cabin Class master', 2),
('booking-channel', 'Booking Channel', 'tbl_booking_channels', 'Booking Channel master', 3),
('loyalty-tier', 'Loyalty Tier', 'tbl_membership_tiers', 'Loyalty Tier master', 4),
('flight-type', 'Flight Type', 'tbl_flight_types', 'Flight Type master', 5),
('journey-type', 'Journey Type', 'tbl_journey_types', 'Journey Type master', 6),
('fare-flexibility', 'Fare Flexibility', 'tbl_fare_flexibilities', 'Fare Flexibility master', 7),
('trip-purpose', 'Trip Purpose', 'tbl_trip_purposes', 'Trip Purpose master', 8),
('carrier-type', 'Carrier Type', 'tbl_carrier_types', 'Carrier Type master', 9),
('special-assistance-type', 'Special Assistance Type', 'tbl_special_assistance_types', 'Special Assistance Type master', 10),
('delay-reason', 'Delay Reason', 'tbl_delay_reasons', 'Delay Reason master', 11),
('delay-duration', 'Delay Duration', 'tbl_delay_durations', 'Delay Duration master', 12),
('extraordinary-circumstances', 'Extraordinary Circumstances', 'tbl_extraordinary_circumstances', 'Extraordinary Circumstances master', 13),
('cancellation-reason', 'Cancellation Reason', 'tbl_cancellation_reasons', 'Cancellation Reason master', 14),
('diversion-reason', 'Diversion Reason', 'tbl_diversion_reasons', 'Diversion Reason master', 15),
('missed-connection-reason', 'Missed Connection Reason', 'tbl_missed_connection_reasons', 'Missed Connection Reason master', 16),
('compensation-eligibility', 'Compensation Eligibility', 'tbl_compensation_eligibilities', 'Compensation Eligibility master', 17),
('compensation-type', 'Compensation Type', 'tbl_compensation_types', 'Compensation Type master', 18),
('refund-type', 'Refund Type', 'tbl_refund_types', 'Refund Type master', 19),
('flight-disruption-type', 'Flight Disruption Type', 'tbl_flight_disruption_types', 'Flight Disruption Type master', 20),
('airline-responsibility', 'Airline Responsibility', 'tbl_airline_responsibilities', 'Airline Responsibility master', 21),
('weather-condition', 'Weather Condition', 'tbl_weather_conditions', 'Weather Condition master', 22),
('atc-restriction', 'ATC Restriction', 'tbl_atc_restrictions', 'ATC Restriction master', 23),
('technical-fault-category', 'Technical Fault Category', 'tbl_technical_fault_categories', 'Technical Fault Category master', 24),
('refund-basis', 'Refund Basis', 'tbl_refund_bases', 'Refund Basis master', 25),
('currency', 'Currency', 'tbl_currencies', 'Currency master', 26),
('refund-method', 'Refund Method', 'tbl_refund_methods', 'Refund Method master', 27)
) AS t(code, name, "tableName", description, "displayOrder")
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_rules_categories WHERE masters.tbl_rules_categories.code = t.code);
UPDATE masters.tbl_rules_categories c
SET "tableName" = v."tableName"
FROM (VALUES
('passenger-type', 'tbl_passenger_types'),
('cabin-class', 'tbl_cabin_classes'),
('booking-channel', 'tbl_booking_channels'),
('loyalty-tier', 'tbl_membership_tiers'),
('flight-type', 'tbl_flight_types'),
('journey-type', 'tbl_journey_types'),
('fare-flexibility', 'tbl_fare_flexibilities'),
('trip-purpose', 'tbl_trip_purposes'),
('carrier-type', 'tbl_carrier_types'),
('special-assistance-type', 'tbl_special_assistance_types'),
('delay-reason', 'tbl_delay_reasons'),
('delay-duration', 'tbl_delay_durations'),
('extraordinary-circumstances', 'tbl_extraordinary_circumstances'),
('cancellation-reason', 'tbl_cancellation_reasons'),
('diversion-reason', 'tbl_diversion_reasons'),
('missed-connection-reason', 'tbl_missed_connection_reasons'),
('compensation-eligibility', 'tbl_compensation_eligibilities'),
('compensation-type', 'tbl_compensation_types'),
('refund-type', 'tbl_refund_types'),
('flight-disruption-type', 'tbl_flight_disruption_types'),
('airline-responsibility', 'tbl_airline_responsibilities'),
('weather-condition', 'tbl_weather_conditions'),
('atc-restriction', 'tbl_atc_restrictions'),
('technical-fault-category', 'tbl_technical_fault_categories'),
('refund-basis', 'tbl_refund_bases'),
('currency', 'tbl_currencies'),
('refund-method', 'tbl_refund_methods')
) AS v(code, "tableName")
WHERE c.code = v.code AND (c."tableName" IS NULL OR c."tableName" != v."tableName");
-- 13. Booking Channels
INSERT INTO masters.tbl_booking_channels (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Airline Website', 'airline-website'),
('Airline Mobile App', 'airline-mobile-app'),
('Airport Ticket Counter', 'airport-ticket-counter'),
('Call Center', 'call-center'),
('Corporate Booking Tool', 'corporate-booking-tool'),
('Global Distribution System', 'global-distribution-system'),
('Online Travel Agency', 'online-travel-agency'),
('Travel Agent', 'travel-agent')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_booking_channels WHERE masters.tbl_booking_channels.value = t.value);
-- 14. Flight Types
INSERT INTO masters.tbl_flight_types (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Domestic', 'domestic'),
('International', 'international')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_flight_types WHERE masters.tbl_flight_types.value = t.value);
-- 15. Journey Types
INSERT INTO masters.tbl_journey_types (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('One Way', 'one-way'),
('Round Trip', 'round-trip'),
('Multi City', 'multi-city')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_journey_types WHERE masters.tbl_journey_types.value = t.value);
-- 16. Fare Flexibilities
INSERT INTO masters.tbl_fare_flexibilities (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Non Refundable', 'non-refundable'),
('Partially Refundable', 'partially-refundable'),
('Refundable', 'refundable'),
('Exchangeable', 'exchangeable'),
('Non Changeable', 'non-changeable')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_fare_flexibilities WHERE masters.tbl_fare_flexibilities.value = t.value);
-- 17. Carrier Types
INSERT INTO masters.tbl_carrier_types (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Operating Carrier', 'operating-carrier'),
('Marketing Carrier', 'marketing-carrier'),
('Partner Carrier', 'partner-carrier'),
('Regional Carrier', 'regional-carrier'),
('Low Cost Carrier', 'low-cost-carrier'),
('Full Service Carrier', 'full-service-carrier'),
('Charter Carrier', 'charter-carrier')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_carrier_types WHERE masters.tbl_carrier_types.value = t.value);
-- 18. Special Assistance Types
INSERT INTO masters.tbl_special_assistance_types (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Wheelchair Assistance', 'wheelchair-assistance'),
('Wheelchair Ramp', 'wheelchair-ramp'),
('Wheelchair Steps', 'wheelchair-steps'),
('Wheelchair Cabin', 'wheelchair-cabin'),
('Blind Passenger', 'blind-passenger'),
('Deaf Passenger', 'deaf-passenger'),
('Medical Assistance', 'medical-assistance'),
('Oxygen Required', 'oxygen-required'),
('Stretcher', 'stretcher'),
('Unaccompanied Minor', 'unaccompanied-minor'),
('Service Animal', 'service-animal'),
('Pregnant Passenger', 'pregnant-passenger'),
('Elderly Passenger', 'elderly-passenger'),
('Other', 'other')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_special_assistance_types WHERE masters.tbl_special_assistance_types.value = t.value);
-- 19. Delay Reasons
INSERT INTO masters.tbl_delay_reasons (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Air Traffic Control Restriction', 'air-traffic-control-restriction'),
('Aircraft Rotation', 'aircraft-rotation'),
('Airport Congestion', 'airport-congestion'),
('Crew Availability', 'crew-availability'),
('Customs Delay', 'customs-delay'),
('Fueling Delay', 'fueling-delay'),
('Late Arrival of Aircraft', 'late-arrival-of-aircraft'),
('Operational Decision', 'operational-decision'),
('Passenger Handling', 'passenger-handling'),
('Runway Closure', 'runway-closure'),
('Security', 'security'),
('Severe Weather', 'severe-weather'),
('Technical Fault', 'technical-fault'),
('Other', 'other')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_delay_reasons WHERE masters.tbl_delay_reasons.value = t.value);
-- 20. Delay Durations
INSERT INTO masters.tbl_delay_durations (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Less than 1 Hour', 'less-than-1-hour'),
('1-2 Hours', '1-2-hours'),
('2-3 Hours', '2-3-hours'),
('3-4 Hours', '3-4-hours'),
('More than 4 Hours', 'more-than-4-hours')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_delay_durations WHERE masters.tbl_delay_durations.value = t.value);
-- 21. Extraordinary Circumstances
INSERT INTO masters.tbl_extraordinary_circumstances (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Air Traffic Management Decision', 'air-traffic-management-decision'),
('Airport Closure', 'airport-closure'),
('Bird Strike', 'bird-strike'),
('Civil Unrest', 'civil-unrest'),
('Medical Emergency', 'medical-emergency'),
('Political Instability', 'political-instability'),
('Security Threat', 'security-threat'),
('Severe Weather', 'severe-weather'),
('Strike (External)', 'strike-external-'),
('War', 'war'),
('Other', 'other')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_extraordinary_circumstances WHERE masters.tbl_extraordinary_circumstances.value = t.value);
-- 22. Cancellation Reasons
INSERT INTO masters.tbl_cancellation_reasons (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Air Traffic Control Restriction', 'air-traffic-control-restriction'),
('Airport Closure', 'airport-closure'),
('Commercial Decision', 'commercial-decision'),
('Crew Availability', 'crew-availability'),
('Operational Decision', 'operational-decision'),
('Overbooking', 'overbooking'),
('Security', 'security'),
('Severe Weather', 'severe-weather'),
('Strike', 'strike'),
('Technical Fault', 'technical-fault')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_cancellation_reasons WHERE masters.tbl_cancellation_reasons.value = t.value);
-- 23. Diversion Reasons
INSERT INTO masters.tbl_diversion_reasons (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Airport Closure', 'airport-closure'),
('Destination Weather', 'destination-weather'),
('Fuel Emergency', 'fuel-emergency'),
('Medical Emergency', 'medical-emergency'),
('Runway Obstruction', 'runway-obstruction'),
('Security Threat', 'security-threat'),
('Technical Fault', 'technical-fault')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_diversion_reasons WHERE masters.tbl_diversion_reasons.value = t.value);
-- 24. Missed Connection Reasons
INSERT INTO masters.tbl_missed_connection_reasons (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Customs Delay', 'customs-delay'),
('Flight Delay', 'flight-delay'),
('Immigration Delay', 'immigration-delay'),
('Passenger Delay', 'passenger-delay'),
('Security Screening Delay', 'security-screening-delay')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_missed_connection_reasons WHERE masters.tbl_missed_connection_reasons.value = t.value);
-- 25. Compensation Eligibilities
INSERT INTO masters.tbl_compensation_eligibilities (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Eligible', 'eligible'),
('Not Eligible', 'not-eligible'),
('Requires Manual Review', 'requires-manual-review')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_compensation_eligibilities WHERE masters.tbl_compensation_eligibilities.value = t.value);
-- 26. Compensation Types
INSERT INTO masters.tbl_compensation_types (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Cash', 'cash'),
('Cheque', 'cheque'),
('Flight Voucher', 'flight-voucher'),
('Loyalty Miles', 'loyalty-miles'),
('Meal Voucher', 'meal-voucher'),
('Hotel Accommodation', 'hotel-accommodation'),
('Ground Transport', 'ground-transport')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_compensation_types WHERE masters.tbl_compensation_types.value = t.value);
-- 27. Refund Types
INSERT INTO masters.tbl_refund_types (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Full Refund', 'full-refund'),
('Partial Refund', 'partial-refund'),
('Future Travel Credit', 'future-travel-credit'),
('Travel Voucher', 'travel-voucher'),
('Tax Refund Only', 'tax-refund-only'),
('Telephone Reimbursement', 'telephone-reimbursement')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_refund_types WHERE masters.tbl_refund_types.value = t.value);
-- 28. Flight Disruption Types
INSERT INTO masters.tbl_flight_disruption_types (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Cancellation', 'cancellation'),
('Delay', 'delay'),
('Denied Boarding', 'denied-boarding'),
('Diversion', 'diversion'),
('Missed Connection', 'missed-connection')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_flight_disruption_types WHERE masters.tbl_flight_disruption_types.value = t.value);
-- 29. Airline Responsibilities
INSERT INTO masters.tbl_airline_responsibilities (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Airline Responsible', 'airline-responsible'),
('Airport Responsible', 'airport-responsible'),
('ATC Responsible', 'atc-responsible'),
('Passenger Responsible', 'passenger-responsible'),
('Shared Responsibility', 'shared-responsibility'),
('Third Party Responsible', 'third-party-responsible'),
('Snow', 'snow')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_airline_responsibilities WHERE masters.tbl_airline_responsibilities.value = t.value);
-- 30. Weather Conditions
INSERT INTO masters.tbl_weather_conditions (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Fog', 'fog'),
('Heavy Rain', 'heavy-rain'),
('Hurricane', 'hurricane'),
('Ice', 'ice'),
('Lightning', 'lightning'),
('Sandstorm', 'sandstorm'),
('Thunderstorm', 'thunderstorm')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_weather_conditions WHERE masters.tbl_weather_conditions.value = t.value);
-- 31. ATC Restrictions
INSERT INTO masters.tbl_atc_restrictions (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Airspace Closure', 'airspace-closure'),
('Flow Control', 'flow-control'),
('Ground Stop', 'ground-stop'),
('Slot Restriction', 'slot-restriction'),
('Traffic Congestion', 'traffic-congestion'),
('Navigation System', 'navigation-system')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_atc_restrictions WHERE masters.tbl_atc_restrictions.value = t.value);
-- 32. Technical Fault Categories
INSERT INTO masters.tbl_technical_fault_categories (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Aircraft Damage', 'aircraft-damage'),
('Avionics', 'avionics'),
('Cabin Systems', 'cabin-systems'),
('Engine', 'engine'),
('Hydraulic System', 'hydraulic-system'),
('Landing Gear', 'landing-gear'),
('Volcanic Ash', 'volcanic-ash'),
('Wind Shear', 'wind-shear')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_technical_fault_categories WHERE masters.tbl_technical_fault_categories.value = t.value);
-- 33. Operators
INSERT INTO masters.tbl_operators (code, name, symbol, "displayOrder", "isActive")
SELECT code, name, symbol, displayOrder, true FROM (VALUES
('EQ', 'Equals', '=', 1),
('NE', 'Not Equals', '!=', 2),
('GT', 'Greater Than', '>', 3),
('GTE', 'Greater Than or Equal', '>=', 4),
('LT', 'Less Than', '<', 5),
('LTE', 'Less Than or Equal', '<=', 6),
('BETWEEN', 'Between', 'BETWEEN', 7),
('CONTAINS', 'Contains', 'CONTAINS', 8),
('IN', 'In', 'IN', 9),
('IS_EMPTY', 'Is Empty', 'IS EMPTY', 10)
) AS t(code, name, symbol, displayOrder)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_operators WHERE masters.tbl_operators.code = t.code);
-- 34. Refund Bases
INSERT INTO masters.tbl_refund_bases (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Base Fare', 'base-fare'),
('Taxes', 'taxes'),
('Total Fare', 'total-fare')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_refund_bases WHERE masters.tbl_refund_bases.value = t.value);
-- 35. Currencies
INSERT INTO masters.tbl_currencies (label, value, symbol, "isActive")
SELECT label, value, symbol, true FROM (VALUES
('United States Dollar', 'USD', '$'),
('Euro', 'EUR', ''),
('British Pound', 'GBP', '£'),
('United Arab Emirates Dirham', 'AED', 'AED'),
('Saudi Riyal', 'SAR', 'SAR'),
('Indian Rupee', 'INR', ''),
('Japanese Yen', 'JPY', '¥'),
('Canadian Dollar', 'CAD', '$'),
('Australian Dollar', 'AUD', '$'),
('Swiss Franc', 'CHF', 'CHF'),
('Singapore Dollar', 'SGD', '$'),
('Qatari Riyal', 'QAR', 'QAR'),
('Kuwaiti Dinar', 'KWD', 'KWD'),
('Bahraini Dinar', 'BHD', 'BHD'),
('Omani Rial', 'OMR', 'OMR')
) AS t(label, value, symbol)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_currencies WHERE masters.tbl_currencies.value = t.value);
-- 36. Refund Methods
INSERT INTO masters.tbl_refund_methods (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Original Payment Method', 'original-payment-method'),
('Wallet', 'wallet'),
('Bank Transfer', 'bank-transfer'),
('Voucher', 'voucher')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_refund_methods WHERE masters.tbl_refund_methods.value = t.value);