source: backend/src/main/resources/db/phase7/verify_section2_deployment.sql

Last change on this file was cdcff72, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance and fix bugs

  • Property mode set to 100644
File size: 4.1 KB
Line 
1-- ============================================================================
2-- Section 2: Appointment Scheduling Integrity - Deployment Verification
3-- ============================================================================
4
5-- 1. Check triggers on appointments table
6-- ============================================================================
7-- === 1. TRIGGERS ON APPOINTMENTS TABLE ===
8SELECT
9 tgname as trigger_name,
10 CASE WHEN tgdisabled = 0 THEN 'ENABLED' ELSE 'DISABLED' END as status
11FROM pg_trigger
12WHERE tgrelid = 'appointments'::regclass
13ORDER BY tgname;
14
15-- 2. Check trigger functions
16-- ============================================================================
17-- === 2. TRIGGER FUNCTIONS ===
18SELECT
19 proname as function_name,
20 pronargs as parameter_count,
21 prokind as kind
22FROM pg_proc
23WHERE proname IN ('trigger_appointments_enforce', 'trigger_appointments_no_overlap', 'is_valid_appointment_transition')
24ORDER BY proname;
25
26-- 3. Check background job procedure
27-- ============================================================================
28-- === 3. BACKGROUND JOB PROCEDURE ===
29SELECT
30 proname as procedure_name,
31 prokind as kind,
32 'PL/pgSQL' as language
33FROM pg_proc
34WHERE proname = 'job_mark_no_show';
35
36-- 4. Check view
37-- ============================================================================
38-- === 4. VIEWS ===
39SELECT
40 viewname as view_name,
41 schemaname as schema_name
42FROM pg_views
43WHERE viewname = 'v_overdue_appointments';
44
45-- 5. Check appointment status constraint
46-- ============================================================================
47-- === 5. STATUS CONSTRAINT (CHECK) ===
48SELECT
49 constraint_name,
50 constraint_type,
51 table_name
52FROM information_schema.table_constraints
53WHERE table_name = 'appointments'
54 AND constraint_type = 'CHECK'
55 AND constraint_name LIKE '%status%';
56
57-- 6. Verify constraint includes NO_SHOW
58-- ============================================================================
59-- === 6. CONSTRAINT DEFINITION ===
60SELECT
61 constraint_name,
62 check_clause
63FROM information_schema.check_constraints
64WHERE constraint_name = 'appointments_status_chk';
65
66-- 7. Test appointment status values
67-- ============================================================================
68-- === 7. VALID APPOINTMENT STATUSES ===
69SELECT 'SCHEDULED' as status
70UNION ALL
71SELECT 'IN_PROGRESS'
72UNION ALL
73SELECT 'COMPLETED'
74UNION ALL
75SELECT 'CANCELLED'
76UNION ALL
77SELECT 'NO_SHOW'
78ORDER BY status;
79
80-- 8. Summary Statistics
81-- ============================================================================
82-- === 8. DEPLOYMENT SUMMARY ===
83SELECT
84 'Triggers' as component,
85 COUNT(*) as count
86FROM pg_trigger
87WHERE tgrelid = 'appointments'::regclass
88UNION ALL
89SELECT
90 'Trigger Functions' as component,
91 COUNT(*) as count
92FROM pg_proc
93WHERE proname IN ('trigger_appointments_enforce', 'trigger_appointments_no_overlap')
94UNION ALL
95SELECT
96 'Validation Functions' as component,
97 COUNT(*) as count
98FROM pg_proc
99WHERE proname = 'is_valid_appointment_transition'
100UNION ALL
101SELECT
102 'Background Procedures' as component,
103 COUNT(*) as count
104FROM pg_proc
105WHERE proname = 'job_mark_no_show'
106UNION ALL
107SELECT
108 'Views' as component,
109 COUNT(*) as count
110FROM pg_views
111WHERE viewname = 'v_overdue_appointments'
112ORDER BY component;
113
114-- 9. Test the transition validation function
115-- ============================================================================
116-- === 9. STATUS TRANSITION VALIDATION TEST ===
117SELECT
118 'SCHEDULED → IN_PROGRESS' as transition,
119 is_valid_appointment_transition('SCHEDULED', 'IN_PROGRESS') as valid
120UNION ALL
121SELECT 'SCHEDULED → COMPLETED', is_valid_appointment_transition('SCHEDULED', 'COMPLETED')
122UNION ALL
123SELECT 'SCHEDULED → CANCELLED', is_valid_appointment_transition('SCHEDULED', 'CANCELLED')
124UNION ALL
125SELECT 'IN_PROGRESS → COMPLETED', is_valid_appointment_transition('IN_PROGRESS', 'COMPLETED')
126UNION ALL
127SELECT 'COMPLETED → SCHEDULED', is_valid_appointment_transition('COMPLETED', 'SCHEDULED')
128UNION ALL
129SELECT 'COMPLETED → COMPLETED', is_valid_appointment_transition('COMPLETED', 'COMPLETED')
130ORDER BY transition;
Note: See TracBrowser for help on using the repository browser.