Re_Backend/src/scripts/seed-configurations-complete.sql

469 lines
8.4 KiB
SQL

-- ===================================================================
-- Royal Enfield Workflow Management - Complete Configuration Seed
-- Run this script to seed all 18 admin configurations
-- ===================================================================
-- Clear existing configurations (optional - remove if you want to keep custom values)
-- DELETE FROM admin_configurations;
-- Insert all 18 configurations with proper field mapping
INSERT INTO admin_configurations (
config_id, config_key, config_category, config_value, value_type,
display_name, description, default_value, is_editable, is_sensitive,
validation_rules, ui_component, sort_order, requires_restart,
created_at, updated_at
) VALUES
-- ==================== TAT SETTINGS (6) ====================
(
gen_random_uuid(),
'DEFAULT_TAT_EXPRESS_HOURS',
'TAT_SETTINGS',
'24',
'NUMBER',
'Default TAT for Express Priority',
'Default turnaround time in hours for express priority requests (calendar days, 24/7)',
'24',
true,
false,
'{"min": 1, "max": 168}'::jsonb,
'number',
1,
false,
NOW(),
NOW()
),
(
gen_random_uuid(),
'DEFAULT_TAT_STANDARD_HOURS',
'TAT_SETTINGS',
'48',
'NUMBER',
'Default TAT for Standard Priority',
'Default turnaround time in hours for standard priority requests (working days only)',
'48',
true,
false,
'{"min": 1, "max": 720}'::jsonb,
'number',
2,
false,
NOW(),
NOW()
),
(
gen_random_uuid(),
'TAT_REMINDER_THRESHOLD_1',
'TAT_SETTINGS',
'50',
'NUMBER',
'First TAT Reminder Threshold (%)',
'Send first gentle reminder when this percentage of TAT is elapsed',
'50',
true,
false,
'{"min": 1, "max": 100}'::jsonb,
'slider',
3,
false,
NOW(),
NOW()
),
(
gen_random_uuid(),
'TAT_REMINDER_THRESHOLD_2',
'TAT_SETTINGS',
'75',
'NUMBER',
'Second TAT Reminder Threshold (%)',
'Send escalation warning when this percentage of TAT is elapsed',
'75',
true,
false,
'{"min": 1, "max": 100}'::jsonb,
'slider',
4,
false,
NOW(),
NOW()
),
(
gen_random_uuid(),
'WORK_START_HOUR',
'TAT_SETTINGS',
'9',
'NUMBER',
'Working Day Start Hour',
'Hour when working day starts (24-hour format, 0-23)',
'9',
true,
false,
'{"min": 0, "max": 23}'::jsonb,
'number',
5,
true,
NOW(),
NOW()
),
(
gen_random_uuid(),
'WORK_END_HOUR',
'TAT_SETTINGS',
'18',
'NUMBER',
'Working Day End Hour',
'Hour when working day ends (24-hour format, 0-23)',
'18',
true,
false,
'{"min": 0, "max": 23}'::jsonb,
'number',
6,
true,
NOW(),
NOW()
),
-- ==================== DOCUMENT POLICY (3) ====================
(
gen_random_uuid(),
'MAX_FILE_SIZE_MB',
'DOCUMENT_POLICY',
'10',
'NUMBER',
'Maximum File Upload Size (MB)',
'Maximum allowed file size for document uploads in megabytes',
'10',
true,
false,
'{"min": 1, "max": 100}'::jsonb,
'number',
10,
true,
NOW(),
NOW()
),
(
gen_random_uuid(),
'ALLOWED_FILE_TYPES',
'DOCUMENT_POLICY',
'pdf,doc,docx,xls,xlsx,ppt,pptx,jpg,jpeg,png,gif',
'STRING',
'Allowed File Types',
'Comma-separated list of allowed file extensions for uploads',
'pdf,doc,docx,xls,xlsx,ppt,pptx,jpg,jpeg,png,gif',
true,
false,
'{}'::jsonb,
'text',
11,
true,
NOW(),
NOW()
),
(
gen_random_uuid(),
'DOCUMENT_RETENTION_DAYS',
'DOCUMENT_POLICY',
'365',
'NUMBER',
'Document Retention Period (Days)',
'Number of days to retain documents after workflow closure before archival',
'365',
true,
false,
'{"min": 30, "max": 3650}'::jsonb,
'number',
12,
false,
NOW(),
NOW()
),
-- ==================== AI CONFIGURATION (2) ====================
(
gen_random_uuid(),
'AI_REMARK_GENERATION_ENABLED',
'AI_CONFIGURATION',
'true',
'BOOLEAN',
'Enable AI Remark Generation',
'Toggle AI-generated conclusion remarks for workflow closures',
'true',
true,
false,
'{}'::jsonb,
'toggle',
20,
false,
NOW(),
NOW()
),
(
gen_random_uuid(),
'AI_REMARK_MAX_CHARACTERS',
'AI_CONFIGURATION',
'500',
'NUMBER',
'AI Remark Maximum Characters',
'Maximum character limit for AI-generated conclusion remarks',
'500',
true,
false,
'{"min": 100, "max": 2000}'::jsonb,
'number',
21,
false,
NOW(),
NOW()
),
-- ==================== NOTIFICATION RULES (3) ====================
(
gen_random_uuid(),
'ENABLE_EMAIL_NOTIFICATIONS',
'NOTIFICATION_RULES',
'true',
'BOOLEAN',
'Enable Email Notifications',
'Send email notifications for workflow events',
'true',
true,
false,
'{}'::jsonb,
'toggle',
30,
false,
NOW(),
NOW()
),
(
gen_random_uuid(),
'ENABLE_IN_APP_NOTIFICATIONS',
'NOTIFICATION_RULES',
'true',
'BOOLEAN',
'Enable In-App Notifications',
'Show notifications within the application portal',
'true',
true,
false,
'{}'::jsonb,
'toggle',
31,
false,
NOW(),
NOW()
),
(
gen_random_uuid(),
'NOTIFICATION_BATCH_DELAY_MS',
'NOTIFICATION_RULES',
'5000',
'NUMBER',
'Notification Batch Delay (ms)',
'Delay in milliseconds before sending batched notifications to avoid spam',
'5000',
true,
false,
'{"min": 1000, "max": 30000}'::jsonb,
'number',
32,
false,
NOW(),
NOW()
),
-- ==================== DASHBOARD LAYOUT (4) ====================
(
gen_random_uuid(),
'DASHBOARD_SHOW_TOTAL_REQUESTS',
'DASHBOARD_LAYOUT',
'true',
'BOOLEAN',
'Show Total Requests Card',
'Display total requests KPI card on dashboard',
'true',
true,
false,
'{}'::jsonb,
'toggle',
40,
false,
NOW(),
NOW()
),
(
gen_random_uuid(),
'DASHBOARD_SHOW_OPEN_REQUESTS',
'DASHBOARD_LAYOUT',
'true',
'BOOLEAN',
'Show Open Requests Card',
'Display open requests KPI card on dashboard',
'true',
true,
false,
'{}'::jsonb,
'toggle',
41,
false,
NOW(),
NOW()
),
(
gen_random_uuid(),
'DASHBOARD_SHOW_TAT_COMPLIANCE',
'DASHBOARD_LAYOUT',
'true',
'BOOLEAN',
'Show TAT Compliance Card',
'Display TAT compliance KPI card on dashboard',
'true',
true,
false,
'{}'::jsonb,
'toggle',
42,
false,
NOW(),
NOW()
),
(
gen_random_uuid(),
'DASHBOARD_SHOW_PENDING_ACTIONS',
'DASHBOARD_LAYOUT',
'true',
'BOOLEAN',
'Show Pending Actions Card',
'Display pending actions KPI card on dashboard',
'true',
true,
false,
'{}'::jsonb,
'toggle',
43,
false,
NOW(),
NOW()
),
-- ==================== WORKFLOW SHARING (3) ====================
(
gen_random_uuid(),
'ALLOW_ADD_SPECTATOR',
'WORKFLOW_SHARING',
'true',
'BOOLEAN',
'Allow Adding Spectators',
'Enable users to add spectators to workflow requests',
'true',
true,
false,
'{}'::jsonb,
'toggle',
50,
false,
NOW(),
NOW()
),
(
gen_random_uuid(),
'MAX_SPECTATORS_PER_REQUEST',
'WORKFLOW_SHARING',
'20',
'NUMBER',
'Maximum Spectators per Request',
'Maximum number of spectators allowed per workflow request',
'20',
true,
false,
'{"min": 1, "max": 100}'::jsonb,
'number',
51,
false,
NOW(),
NOW()
),
(
gen_random_uuid(),
'ALLOW_EXTERNAL_SHARING',
'WORKFLOW_SHARING',
'false',
'BOOLEAN',
'Allow External Sharing',
'Allow sharing workflow links with users outside the organization',
'false',
true,
false,
'{}'::jsonb,
'toggle',
52,
false,
NOW(),
NOW()
),
-- ==================== WORKFLOW LIMITS (2) ====================
(
gen_random_uuid(),
'MAX_APPROVAL_LEVELS',
'WORKFLOW_LIMITS',
'10',
'NUMBER',
'Maximum Approval Levels',
'Maximum number of approval levels allowed per workflow',
'10',
true,
false,
'{"min": 1, "max": 20}'::jsonb,
'number',
60,
false,
NOW(),
NOW()
),
(
gen_random_uuid(),
'MAX_PARTICIPANTS_PER_REQUEST',
'WORKFLOW_LIMITS',
'50',
'NUMBER',
'Maximum Participants per Request',
'Maximum total participants (approvers + spectators) per workflow',
'50',
true,
false,
'{"min": 2, "max": 200}'::jsonb,
'number',
61,
false,
NOW(),
NOW()
)
ON CONFLICT (config_key) DO UPDATE SET
config_value = EXCLUDED.config_value,
display_name = EXCLUDED.display_name,
description = EXCLUDED.description,
is_editable = EXCLUDED.is_editable,
updated_at = NOW();
-- Verify insertion
SELECT
config_category,
config_key,
is_editable,
is_sensitive,
requires_restart
FROM admin_configurations
ORDER BY config_category, sort_order;
-- Show summary
SELECT
config_category AS category,
COUNT(*) AS total_settings,
SUM(CASE WHEN is_editable = true THEN 1 ELSE 0 END) AS editable_count
FROM admin_configurations
GROUP BY config_category
ORDER BY config_category;