feat: initialize master data module with new entity definitions, cohort module, and SQL seeding script

This commit is contained in:
azeeee05
2026-08-10 17:17:06 +05:30
parent e920c9e3b5
commit 5f95a5c341
12 changed files with 380 additions and 2 deletions
+83 -2
View File
@@ -261,7 +261,14 @@ SELECT code, name, "tableName", description, "displayOrder", true FROM (VALUES
('revenue-segment', 'Revenue Segment', 'tbl_revenue_segments', 'Revenue Segment master', 31),
('jurisdiction', 'Jurisdiction', 'tbl_jurisdictions', 'Jurisdiction master', 32),
('operator', 'Operator', 'tbl_operators', 'Operator master', 33),
('amount-type', 'Amount Type', 'tbl_amount_types', 'Amount Type master', 34)
('amount-type', 'Amount Type', 'tbl_amount_types', 'Amount Type master', 34),
('baggage-type', 'Baggage Type', 'tbl_baggage_types', 'Baggage Type master', 35),
('compensation-rule', 'Compensation Rule', 'tbl_compensation_rules', 'Compensation Rule master', 36),
('approval-level', 'Approval Level', 'tbl_approval_levels', 'Approval Level master', 37),
('eligible-fare-type', 'Eligible Fare Type', 'tbl_eligible_fare_types', 'Eligible Fare Type master', 38),
('applicable-product', 'Applicable Product', 'tbl_applicable_products', 'Applicable Product master', 39),
('meal-type', 'Meal Type', 'tbl_meal_types', 'Meal Type master', 40),
('airport-restriction', 'Airport Restriction', 'tbl_airport_restrictions', 'Airport Restriction master', 41)
) 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);
@@ -302,7 +309,14 @@ FROM (VALUES
('revenue-segment', 'tbl_revenue_segments'),
('jurisdiction', 'tbl_jurisdictions'),
('operator', 'tbl_operators'),
('amount-type', 'tbl_amount_types')
('amount-type', 'tbl_amount_types'),
('baggage-type', 'tbl_baggage_types'),
('compensation-rule', 'tbl_compensation_rules'),
('approval-level', 'tbl_approval_levels'),
('eligible-fare-type', 'tbl_eligible_fare_types'),
('applicable-product', 'tbl_applicable_products'),
('meal-type', 'tbl_meal_types'),
('airport-restriction', 'tbl_airport_restrictions')
) AS v(code, "tableName")
WHERE c.code = v.code AND (c."tableName" IS NULL OR c."tableName" != v."tableName");
@@ -631,5 +645,72 @@ SELECT label, value, true FROM (VALUES
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_amount_types WHERE masters.tbl_amount_types.value = t.value);
-- 38. Baggage Types
INSERT INTO masters.tbl_baggage_types (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Checked Bag', 'checked-bag'),
('Cabin Bag', 'cabin-bag'),
('Oversized Baggage', 'oversized-baggage'),
('Sports Equipment', 'sports-equipment'),
('Special Baggage', 'special-baggage')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_baggage_types WHERE masters.tbl_baggage_types.value = t.value);
-- 39. Compensation Rules
INSERT INTO masters.tbl_compensation_rules (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('EU261', 'eu261'),
('UK261', 'uk261'),
('APPR', 'appr'),
('DGCA', 'dgca'),
('DOT', 'dot'),
('Airline Policy', 'airline-policy')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_compensation_rules WHERE masters.tbl_compensation_rules.value = t.value);
-- 40. Approval Levels
INSERT INTO masters.tbl_approval_levels (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Supervisor', 'supervisor'),
('Manager', 'manager'),
('Director', 'director')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_approval_levels WHERE masters.tbl_approval_levels.value = t.value);
-- 41. Eligible Fare Types
INSERT INTO masters.tbl_eligible_fare_types (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Published Fares', 'published-fares'),
('Promo Fares', 'promo-fares')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_eligible_fare_types WHERE masters.tbl_eligible_fare_types.value = t.value);
-- 42. Applicable Products
INSERT INTO masters.tbl_applicable_products (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Flights', 'flights'),
('Ancillary', 'ancillary'),
('Lounge', 'lounge')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_applicable_products WHERE masters.tbl_applicable_products.value = t.value);
-- 43. Meal Types
INSERT INTO masters.tbl_meal_types (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Breakfast', 'breakfast'),
('Lunch', 'lunch'),
('Dinner', 'dinner'),
('Snack', 'snack'),
('Any', 'any')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_meal_types WHERE masters.tbl_meal_types.value = t.value);
-- 44. Airport Restrictions
INSERT INTO masters.tbl_airport_restrictions (label, value, "isActive")
SELECT label, value, true FROM (VALUES
('Departure', 'departure'),
('Transit', 'transit'),
('Arrival', 'arrival'),
('Any Airport', 'any-airport')
) AS t(label, value)
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_airport_restrictions WHERE masters.tbl_airport_restrictions.value = t.value);