-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic-trigger-test.sql
More file actions
89 lines (75 loc) · 3.06 KB
/
basic-trigger-test.sql
File metadata and controls
89 lines (75 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
-- Basic Trigger Test - Works with any table structure
-- =============================================================================
-- STEP 1: Find a submission to test with
-- =============================================================================
SELECT 'FIND_TEST_SUBMISSION' as step,
id as submission_id,
student_id,
status,
'Copy this ID for manual test' as instruction
FROM task_submissions
WHERE status IN ('pending', 'in_review', 'needs_changes')
LIMIT 1;
-- =============================================================================
-- STEP 2: Manual Test Instructions
-- =============================================================================
SELECT 'MANUAL_TEST' as step,
'Replace YOUR_ID_HERE with a submission ID from above' as instruction_1,
'Then uncomment and run the UPDATE below' as instruction_2;
-- MANUAL TEST: Uncomment the line below and replace YOUR_ID_HERE with actual ID
-- UPDATE task_submissions SET status = 'approved' WHERE id = 'YOUR_ID_HERE';
-- =============================================================================
-- STEP 3: Check results (run AFTER the manual update)
-- =============================================================================
-- Check if student_achievements table has new records
SELECT 'ACHIEVEMENTS_RESULT' as result,
COUNT(*) as total_achievements,
'Check if this number increased after approval' as note
FROM student_achievements;
-- Show recent achievements (if any)
SELECT 'RECENT_ACHIEVEMENTS' as result,
student_id,
achievement_type,
title
FROM student_achievements
ORDER BY earned_at DESC
LIMIT 3;
-- Check if week_progress table has new records
SELECT 'PROGRESS_RESULT' as result,
COUNT(*) as total_progress_records,
'Check if this number increased after approval' as note
FROM week_progress;
-- Show recent progress (if any)
SELECT 'RECENT_PROGRESS' as result,
student_id,
week_id,
status
FROM week_progress
ORDER BY updated_at DESC
LIMIT 3;
-- =============================================================================
-- STEP 4: Verify the submission was updated
-- =============================================================================
SELECT 'SUBMISSION_STATUS' as result,
id,
student_id,
status,
'This should show approved if test worked' as verification
FROM task_submissions
WHERE status = 'approved'
ORDER BY id DESC
LIMIT 3;
-- =============================================================================
-- STEP 5: Simple success check
-- =============================================================================
SELECT 'SUCCESS_CHECK' as final_result,
CASE
WHEN EXISTS (SELECT 1 FROM student_achievements)
THEN '✅ Achievements table has data'
ELSE '⚠️ No achievements created yet'
END as achievements_status,
CASE
WHEN EXISTS (SELECT 1 FROM week_progress)
THEN '✅ Progress table has data'
ELSE '⚠️ No progress records yet'
END as progress_status;