-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupabase-migration.sql
More file actions
75 lines (67 loc) · 2.01 KB
/
Copy pathsupabase-migration.sql
File metadata and controls
75 lines (67 loc) · 2.01 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
-- Migration to fix mission_id for Indexer compatibility
-- Run this in Supabase SQL Editor
-- Add mission_id as TEXT using DO block to avoid errors
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'mission_progress' AND column_name = 'mission_id'
) THEN
ALTER TABLE mission_progress ADD COLUMN mission_id TEXT;
END IF;
END $$;
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'mission_progress' AND column_name = 'wallet_address'
) THEN
ALTER TABLE mission_progress ADD COLUMN wallet_address TEXT;
END IF;
END $$;
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'mission_progress' AND column_name = 'status'
) THEN
ALTER TABLE mission_progress ADD COLUMN status TEXT DEFAULT 'pending';
END IF;
END $$;
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'mission_progress' AND column_name = 'current_value'
) THEN
ALTER TABLE mission_progress ADD COLUMN current_value BIGINT DEFAULT 0;
END IF;
END $$;
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'mission_progress' AND column_name = 'started_at'
) THEN
ALTER TABLE mission_progress ADD COLUMN started_at TIMESTAMPTZ;
END IF;
END $$;
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'mission_progress' AND column_name = 'completed_at'
) THEN
ALTER TABLE mission_progress ADD COLUMN completed_at TIMESTAMPTZ;
END IF;
END $$;
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'mission_progress' AND column_name = 'claimed_at'
) THEN
ALTER TABLE mission_progress ADD COLUMN claimed_at TIMESTAMPTZ;
END IF;
END $$;
SELECT 'Migration completed successfully' as result;