This repository was archived by the owner on Jun 13, 2025. It is now read-only.
forked from Giveth/giveth-dapps-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-sample-projects.sql
More file actions
181 lines (173 loc) · 6.3 KB
/
create-sample-projects.sql
File metadata and controls
181 lines (173 loc) · 6.3 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
-- Create project statuses first
INSERT INTO public."project_status" ("id", "symbol", "name", "description") VALUES
(1, 'pending', 'Pending', 'Project is pending review'),
(2, 'rejected', 'Rejected', 'Project has been rejected'),
(3, 'cancelled', 'Cancelled', 'Project has been cancelled'),
(4, 'draft', 'Draft', 'Project is in draft mode'),
(5, 'active', 'Active', 'Project is active and accepting donations')
ON CONFLICT ("id") DO NOTHING;
-- Create sample projects for development
-- First, ensure we have a user to be admin
INSERT INTO public."user" (
"firstName", "lastName", "name", "walletAddress",
"avatar", "url", "isEmailVerified", "createdAt", "updatedAt",
"loginType", "totalDonated", "totalReceived"
) VALUES (
'Demo', 'User', 'Demo User', '0x1234567890123456789012345678901234567890',
'https://example.com/avatar.jpg', 'https://example.com',
true, NOW(), NOW(),
'wallet', 0, 0
) ON CONFLICT ("walletAddress") DO NOTHING;
-- Get the user ID (we'll use ID 1 assuming it exists or was just created)
-- Create sample projects with statusId = 5 (active)
INSERT INTO public."project" (
"title", "slug", "description", "descriptionSummary",
"website", "creationDate", "updatedAt", "image",
"walletAddress", "verified", "statusId", "adminUserId",
"totalDonations", "totalReactions", "listed", "isGivbackEligible",
"reviewStatus", "giveBacks", "qualityScore", "totalTraceDonations",
"totalProjectUpdates", "sumDonationValueUsdForActiveQfRound",
"countUniqueDonorsForActiveQfRound", "countUniqueDonors",
"activeCausesCount", "slugHistory"
) VALUES
(
'Sample Environmental Project', 'sample-environmental-project',
'A project focused on environmental conservation and sustainability.',
'Environmental conservation project',
'https://example.com/env-project', NOW(), NOW(),
'https://example.com/env-project.jpg',
'0x1111111111111111111111111111111111111111', true, 5, 1,
1000.0, 25, true, true, 'Listed', false, 80, 0,
0, 0, 0, 1, 0, ARRAY['sample-environmental-project']
),
(
'Education Initiative', 'education-initiative',
'Supporting education in underserved communities around the world.',
'Education support project',
'https://example.com/edu-project', NOW(), NOW(),
'https://example.com/edu-project.jpg',
'0x2222222222222222222222222222222222222222', true, 5, 1,
2500.0, 50, true, true, 'Listed', false, 85, 0,
0, 0, 0, 1, 0, ARRAY['education-initiative']
),
(
'Healthcare Access Program', 'healthcare-access-program',
'Providing healthcare access to remote and underserved areas.',
'Healthcare access initiative',
'https://example.com/health-project', NOW(), NOW(),
'https://example.com/health-project.jpg',
'0x3333333333333333333333333333333333333333', false, 5, 1,
750.0, 15, true, false, 'Listed', false, 75, 0,
0, 0, 0, 1, 0, ARRAY['healthcare-access-program']
),
(
'Technology for Good', 'technology-for-good',
'Using technology to solve social problems and improve lives.',
'Technology solutions for social impact',
'https://example.com/tech-project', NOW(), NOW(),
'https://example.com/tech-project.jpg',
'0x4444444444444444444444444444444444444444', true, 5, 1,
3200.0, 80, true, true, 'Listed', false, 90, 0,
0, 0, 0, 1, 0, ARRAY['technology-for-good']
),
(
'Community Development Fund', 'community-development-fund',
'Supporting local community development projects and initiatives.',
'Community development support',
'https://example.com/community-project', NOW(), NOW(),
'https://example.com/community-project.jpg',
'0x5555555555555555555555555555555555555555', false, 5, 1,
500.0, 10, true, false, 'Listed', false, 70, 0,
0, 0, 0, 1, 0, ARRAY['community-development-fund']
) ON CONFLICT ("slug") DO NOTHING;
-- Refresh the materialized view
REFRESH MATERIALIZED VIEW public.project_instant_power_view;
-- Create sample projects for testing
-- This script adds sample projects to the database
-- First, let's check if we have any projects
SELECT COUNT(*) as total_projects FROM project;
-- Insert sample projects if database is empty
INSERT INTO project (
title,
slug,
description,
"descriptionSummary",
image,
"creationDate",
"updatedAt",
"adminUserId",
"statusId",
"isActive",
verified,
listed,
"reviewStatus",
"totalDonations",
"totalReactions",
"totalProjectUpdates",
"qualityScore",
"slugHistory"
) VALUES
(
'Technology for Good Initiative',
'technology-for-good',
'A comprehensive project focused on leveraging technology to solve social and environmental challenges. We develop innovative solutions that bridge the gap between cutting-edge technology and real-world problems.',
'Leveraging technology to solve social and environmental challenges through innovative solutions.',
'https://example.com/tech-project.jpg',
NOW(),
NOW(),
1, -- Assuming admin user ID 1 exists
5, -- Active status
true,
false,
true,
'Listed',
0,
0,
0,
80,
ARRAY['technology-for-good']
),
(
'Environmental Conservation Project',
'sample-environmental-project',
'Dedicated to protecting and restoring natural ecosystems through community-driven conservation efforts and sustainable practices.',
'Community-driven environmental conservation and ecosystem restoration.',
'https://example.com/env-project.jpg',
NOW(),
NOW(),
1,
5,
true,
false,
true,
'Listed',
0,
0,
0,
75,
ARRAY['sample-environmental-project']
),
(
'Education Access Initiative',
'education-access-initiative',
'Providing quality education resources and opportunities to underserved communities worldwide through digital platforms and local partnerships.',
'Quality education resources for underserved communities worldwide.',
'https://example.com/edu-project.jpg',
NOW(),
NOW(),
1,
5,
true,
false,
true,
'Listed',
0,
0,
0,
85,
ARRAY['education-access-initiative']
);
-- Verify the projects were created
SELECT id, title, slug, "isActive", verified, listed FROM project WHERE slug IN ('technology-for-good', 'sample-environmental-project', 'education-access-initiative');
-- Show total project count
SELECT COUNT(*) as total_projects_after_insert FROM project;