-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmigration-hardcoded-events.sql
More file actions
156 lines (150 loc) · 4.54 KB
/
migration-hardcoded-events.sql
File metadata and controls
156 lines (150 loc) · 4.54 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
-- SQL Migration Script: Migrate Hardcoded Events to Database
-- Run this script to create the Event table and populate it with hardcoded events
-- Create the Event table if it doesn't exist
CREATE TABLE IF NOT EXISTS "Event" (
"id" TEXT NOT NULL PRIMARY KEY,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"name" TEXT NOT NULL,
"date" TIMESTAMP(3) NOT NULL,
"startTime" TEXT,
"endTime" TEXT,
"location" TEXT,
"address" TEXT,
"mapUrl" TEXT,
"embedMapUrl" TEXT,
"description" TEXT,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"authorId" TEXT NOT NULL,
CONSTRAINT "Event_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- Create indexes for performance
CREATE INDEX IF NOT EXISTS "Event_authorId_idx" ON "Event"("authorId");
CREATE INDEX IF NOT EXISTS "Event_date_idx" ON "Event"("date");
-- First, ensure we have an admin user to associate events with
-- This script assumes there's an admin user with email 'admin@admin.com'
-- Insert hardcoded events from the UpcomingEvents component
INSERT INTO "Event" (
"id",
"createdAt",
"updatedAt",
"name",
"date",
"startTime",
"endTime",
"location",
"address",
"mapUrl",
"embedMapUrl",
"description",
"isActive",
"authorId"
)
SELECT
gen_random_uuid() as "id",
NOW() as "createdAt",
NOW() as "updatedAt",
events_data."name",
events_data."date",
events_data."startTime",
events_data."endTime",
events_data."location",
events_data."address",
events_data."mapUrl",
events_data."embedMapUrl",
events_data."description",
events_data."isActive",
u."id" as "authorId"
FROM (
VALUES
(
'Monthly Meetup',
'2025-06-10 17:00:00'::timestamp,
'5:00 PM',
'9:00 PM',
'Knuckleheads Garage',
'701 N Montgall Ave, Kansas City, MO 64120',
'https://maps.app.goo.gl/Z9yboWxsEh63QzuDA',
'https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3095.376287263093!2d-94.55174202405244!3d39.12066797167728!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x87c0fa6efbb5e74b%3A0xc88eb26af129a68b!2s701%20N%20Montgall%20Ave%2C%20Kansas%20City%2C%20MO%2064120!5e0!3m2!1sen!2sus!4v1747367871060!5m2!1sen!2sus',
'Monthly meetup for KS3CKC members. Join us for networking, presentations, and ham radio discussions.',
true
),
(
'ARRL Field Day 2025',
'2025-06-27 15:00:00'::timestamp,
'3:00 PM',
'12:00 PM June 29, 2025',
'Clinton State Park | Elk Creek Cabin',
NULL,
'https://maps.app.goo.gl/MTJgqTcw69tigJkE6',
'https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3103.748792336924!2d-95.36182731749331!3d38.92971887188787!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x87bf6b908a5cd5d1%3A0x628e97bd646e3552!2sElk%20Creek%20Cabin!5e0!3m2!1sen!2sus!4v1747367052821!5m2!1sen!2sus',
'ARRL Field Day 2025 - Join us for the premier emergency preparedness exercise in amateur radio. Questions? Find us on Discord (https://discord.gg/seckc) and ask away!',
true
),
(
'Local Meetup',
'2025-05-15 17:00:00'::timestamp,
'5:00 PM',
'9:00 PM',
'Tall Trellis Brew Co.',
'25600 West Valley Parkway, Olathe, KS 66061 United States',
'https://www.google.com/maps/place/Tall+Trellis+Brew+Co./@38.9450675,-94.8871786,17z/data=!3m1!4b1!4m6!3m5!1s0x87c09778274906e5:0x8534144f0ecc2ff9!8m2!3d38.9450634!4d-94.8845983!16s%2Fg%2F11stzc5h4p',
NULL,
'Local meetup for KS3CKC members at Tall Trellis Brew Co.',
true
),
(
'Summer Field Day',
'2024-06-15 12:00:00'::timestamp,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
'Summer Field Day event for amateur radio operators.',
true
),
(
'DX Contest',
'2024-04-30 12:00:00'::timestamp,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
'DX Contest for long-distance communication.',
true
)
) AS events_data(
"name",
"date",
"startTime",
"endTime",
"location",
"address",
"mapUrl",
"embedMapUrl",
"description",
"isActive"
)
CROSS JOIN "User" u
WHERE u."email" = 'admin@admin.com'
AND NOT EXISTS (
-- Only insert if the event doesn't already exist
SELECT 1 FROM "Event" e
WHERE e."name" = events_data."name"
AND e."date" = events_data."date"
);
-- Verify the migration
SELECT
"name",
"date",
"location",
"isActive",
"createdAt"
FROM "Event"
ORDER BY "date" DESC;
-- Optional: Show count of events before and after
SELECT COUNT(*) as total_events FROM "Event";