-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-database-correct.sql
More file actions
162 lines (154 loc) · 4.08 KB
/
fix-database-correct.sql
File metadata and controls
162 lines (154 loc) · 4.08 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
-- GrowthOS 数据库数据修复脚本 - 正确版本
-- 在Supabase控制台的SQL编辑器中执行
-- =====================================================
-- 临时禁用RLS
ALTER TABLE users DISABLE ROW LEVEL SECURITY;
ALTER TABLE products DISABLE ROW LEVEL SECURITY;
-- 清空现有数据(保留Supabase系统用户)
DELETE FROM orders WHERE true;
DELETE FROM product_images WHERE true;
DELETE FROM products WHERE true;
DELETE FROM users WHERE email NOT LIKE '%@supabase.io' AND email NOT LIKE '%service_role%';
-- 插入测试用户(使用正确的字段)
INSERT INTO users (
id,
email,
username,
bio,
avatar,
wallet_address,
social_wechat,
social_alipay,
social_linkedin,
social_website,
email_verified,
is_active
) VALUES
(
'8ab146dd-9e5d-4046-9b14-04bc5e2c8a73',
'test@example.com',
'testuser',
'Test user for development',
'https://avatars.githubusercontent.com/u/190834534?s=200&v=4',
null,
null,
null,
null,
null,
true,
true
),
(
'9bc257ee-0f6e-5157-ac25-15cd6f3d9b84',
'admin@workwork.com',
'admin',
'Administrator account',
'https://avatars.githubusercontent.com/u/190834534?s=200&v=4',
null,
null,
null,
null,
null,
true,
true
);
-- 插入测试产品
INSERT INTO products (
name,
description,
author_id,
author_name,
price,
currency,
category,
zone,
pricing_model,
product_type,
tags,
images,
views,
likes,
rating,
status
) VALUES
(
'AI Code Generator Pro',
'Advanced AI-powered code generation tool for Solana smart contracts. Generate secure, optimized Rust code with built-in best practices.',
'8ab146dd-9e5d-4046-9b14-04bc5e2c8a73',
'testuser',
49.99,
'SOL',
'AI Tools',
'products',
'one_time',
'product',
'[{"type":"ai","label":"Code Generation"},{"type":"crypto","label":"Solana"}]'::jsonb,
'[{"url":"https://avatars.githubusercontent.com/u/190834534?s=200&v=4","alt":"AI Code Generator Pro"}]'::jsonb,
1247,
89,
4.8,
'active'
),
(
'DeFi Analytics Dashboard',
'Comprehensive analytics platform for DeFi protocols on Solana. Real-time data, yield tracking, and risk assessment tools.',
'8ab146dd-9e5d-4046-9b14-04bc5e2c8a73',
'testuser',
29.99,
'SOL',
'Analytics',
'services',
'one_time',
'product',
'[{"type":"crypto","label":"DeFi"},{"type":"education","label":"Analytics"}]'::jsonb,
'[{"url":"https://avatars.githubusercontent.com/u/190834534?s=200&v=4","alt":"DeFi Analytics Dashboard"}]'::jsonb,
2156,
156,
4.7,
'active'
),
(
'Solana Developer Bootcamp',
'Intensive 8-week online bootcamp covering Solana development from basics to advanced topics.',
'9bc257ee-0f6e-5157-ac25-15cd6f3d9b84',
'admin',
199.99,
'SOL',
'Education',
'courses',
'subscription',
'subscription',
'[{"type":"education","label":"Bootcamp"},{"type":"crypto","label":"Solana"}]'::jsonb,
'[{"url":"https://avatars.githubusercontent.com/u/190834534?s=200&v=4","alt":"Solana Developer Bootcamp"}]'::jsonb,
3421,
298,
4.9,
'active'
);
-- 为每个产品添加主图片到 product_images 表
INSERT INTO product_images (
product_id,
image_url,
image_type,
is_primary,
display_order,
alt_text
)
SELECT
p.id,
'https://avatars.githubusercontent.com/u/190834534?s=200&v=4',
'default',
true,
0,
p.name || ' - Main Image'
FROM products p;
-- 重新启用RLS
ALTER TABLE users ENABLE ROW LEVEL SECURITY;
ALTER TABLE products ENABLE ROW LEVEL SECURITY;
-- 显示结果
SELECT 'Users inserted:' as info, COUNT(*) as count FROM users;
SELECT 'Products inserted:' as info, COUNT(*) as count FROM products;
SELECT 'Product images inserted:' as info, COUNT(*) as count FROM product_images;
-- 显示详细信息
SELECT 'USER DETAILS:' as section, username, email, bio FROM users ORDER BY username;
SELECT 'PRODUCT DETAILS:' as section, name, price, currency, category, zone FROM products ORDER BY name;