This repository was archived by the owner on Jun 13, 2025. It is now read-only.
forked from Giveth/impact-graph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseed-simple.sql
More file actions
73 lines (67 loc) · 4.25 KB
/
seed-simple.sql
File metadata and controls
73 lines (67 loc) · 4.25 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
-- Simple seed sample data for Giveth development environment
-- Create basic admin user if not exists
INSERT INTO "user" (
id, name, "walletAddress", email, "loginType",
"createdAt", "updatedAt", "isEmailVerified", role
)
SELECT 999, 'Sample Admin', '0x1234567890123456789012345678901234567890',
'sample-admin@giveth.io', 'wallet', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, true, 'admin'
WHERE NOT EXISTS (SELECT 1 FROM "user" WHERE id = 999);
-- Create sample projects
INSERT INTO project (
id, title, slug, description, image, "creationDate", "updatedAt",
verified, "statusId", "adminUserId", "totalDonations", "totalReactions",
listed, "isGivbackEligible"
)
SELECT * FROM (VALUES
(1001, 'Clean Water Initiative', 'clean-water-initiative',
'Providing clean water access to underserved communities.',
'https://images.unsplash.com/photo-1582719508461-905c673771fd?w=800',
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, true, 5, 999, 0, 0, true, true),
(1002, 'Educational Technology for Rural Schools', 'educational-technology-rural-schools',
'Bringing modern educational technology to rural schools.',
'https://images.unsplash.com/photo-1503676260728-1c00da094a0b?w=800',
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, true, 5, 999, 0, 0, true, true),
(1003, 'Renewable Energy for Communities', 'renewable-energy-communities',
'Installing solar panels and wind turbines in remote communities.',
'https://images.unsplash.com/photo-1509391366360-2e959784a276?w=800',
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, false, 5, 999, 0, 0, true, true),
(1004, 'Food Security Program', 'food-security-program',
'Supporting local farmers and food banks.',
'https://images.unsplash.com/photo-1488459716781-31db52582fe9?w=800',
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, true, 5, 999, 0, 0, true, true),
(1005, 'Healthcare Access Initiative', 'healthcare-access-initiative',
'Providing mobile healthcare services.',
'https://images.unsplash.com/photo-1559757148-5c350d0d3c56?w=800',
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, false, 5, 999, 0, 0, true, true)
) AS v(id, title, slug, description, image, "creationDate", "updatedAt", verified, "statusId", "adminUserId", "totalDonations", "totalReactions", listed, "isGivbackEligible")
WHERE NOT EXISTS (SELECT 1 FROM project WHERE id BETWEEN 1001 AND 1005);
-- Add project addresses for sample projects
INSERT INTO project_address (
id, title, "networkId", address, "projectId", "userId", "isRecipient",
"createdAt", "updatedAt"
)
SELECT * FROM (VALUES
(2001, 'Ethereum Mainnet', 1, '0x1111111111111111111111111111111111111111', 1001, 999, true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(2002, 'Ethereum Mainnet', 1, '0x2222222222222222222222222222222222222222', 1002, 999, true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(2003, 'Ethereum Mainnet', 1, '0x3333333333333333333333333333333333333333', 1003, 999, true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(2004, 'Ethereum Mainnet', 1, '0x4444444444444444444444444444444444444444', 1004, 999, true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(2005, 'Ethereum Mainnet', 1, '0x5555555555555555555555555555555555555555', 1005, 999, true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
) AS v(id, title, "networkId", address, "projectId", "userId", "isRecipient", "createdAt", "updatedAt")
WHERE NOT EXISTS (SELECT 1 FROM project_address WHERE id BETWEEN 2001 AND 2005);
-- Create sample instant power balance
INSERT INTO instant_power_balance ("userId", balance, "balanceAggregatorUpdatedAt")
SELECT 999, 1000.0, CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM instant_power_balance WHERE "userId" = 999);
-- Create sample power boosting data
INSERT INTO power_boosting (id, "userId", "projectId", percentage, "updatedAt", "createdAt")
SELECT * FROM (VALUES
(3001, 999, 1001, 20, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(3002, 999, 1002, 25, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(3003, 999, 1003, 15, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(3004, 999, 1004, 30, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(3005, 999, 1005, 10, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
) AS v(id, "userId", "projectId", percentage, "updatedAt", "createdAt")
WHERE NOT EXISTS (SELECT 1 FROM power_boosting WHERE id BETWEEN 3001 AND 3005);
-- Refresh materialized views
REFRESH MATERIALIZED VIEW CONCURRENTLY project_instant_power_view;