Skip to content

Commit 7f3a407

Browse files
Corrigir UUIDs nos inserts
Atualiza o script de dados ENGLISH para usar UUIDs corretos em user_id e relações, convertendo os INSERTs de INTEGER para UUIDs compatíveis com auth.users. Inclui ajustes nas inserts de company_profiles, profiles, jobs, applications, notifications e outros elementos que dependem de IDs UUID. X-Lovable-Edit-ID: edt-6974c99e-31e3-470a-bfed-8afa16189e34
2 parents c7c1408 + 3625622 commit 7f3a407

1 file changed

Lines changed: 65 additions & 55 deletions

File tree

entrega-academica/05-insercao-dados-ENGLISH.sql

Lines changed: 65 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,37 @@
1414
-- INSERTING USER ROLES (at least 5 records)
1515
-- ============================================
1616

17-
-- CRITICAL: Replace these UUIDs with real UUIDs from your auth.users table
18-
-- You need at least:
19-
-- - 1 admin user
20-
-- - 3 candidate users
21-
-- - 2 company users
17+
-- ⚠️ CRITICAL: GET REAL UUIDs FROM YOUR DATABASE FIRST!
18+
-- Run this query to get existing user IDs:
19+
-- SELECT id, email FROM auth.users ORDER BY created_at DESC LIMIT 10;
2220

23-
INSERT INTO user_roles (user_id, role) VALUES
24-
-- Admin (1 record)
25-
('00000000-0000-0000-0000-000000000001', 'admin'),
26-
27-
-- Candidates (3 records)
28-
('11111111-1111-1111-1111-111111111111', 'candidate'),
29-
('11111111-1111-1111-1111-111111111112', 'candidate'),
30-
('11111111-1111-1111-1111-111111111113', 'candidate'),
21+
-- ⚠️ REPLACE ALL UUIDs BELOW WITH REAL ONES FROM YOUR DATABASE!
22+
-- Example structure (DO NOT USE THESE FAKE UUIDs):
3123

32-
-- Companies (2 records)
33-
('22222222-2222-2222-2222-222222222221', 'company'),
34-
('22222222-2222-2222-2222-222222222222', 'company')
24+
INSERT INTO user_roles (user_id, role) VALUES
25+
-- Get 1 real UUID for admin from auth.users
26+
('PUT-REAL-ADMIN-UUID-HERE'::uuid, 'admin'),
27+
28+
-- Get 5 real UUIDs for candidates from auth.users
29+
('PUT-REAL-CANDIDATE-UUID-1'::uuid, 'candidate'),
30+
('PUT-REAL-CANDIDATE-UUID-2'::uuid, 'candidate'),
31+
('PUT-REAL-CANDIDATE-UUID-3'::uuid, 'candidate'),
32+
('PUT-REAL-CANDIDATE-UUID-4'::uuid, 'candidate'),
33+
('PUT-REAL-CANDIDATE-UUID-5'::uuid, 'candidate'),
34+
35+
-- Get 5 real UUIDs for companies from auth.users
36+
('PUT-REAL-COMPANY-UUID-1'::uuid, 'company'),
37+
('PUT-REAL-COMPANY-UUID-2'::uuid, 'company'),
38+
('PUT-REAL-COMPANY-UUID-3'::uuid, 'company'),
39+
('PUT-REAL-COMPANY-UUID-4'::uuid, 'company'),
40+
('PUT-REAL-COMPANY-UUID-5'::uuid, 'company')
3541
ON CONFLICT (user_id, role) DO NOTHING;
3642

3743
-- ============================================
3844
-- INSERTING CANDIDATE PROFILES (at least 5 records)
3945
-- ============================================
4046

47+
-- ⚠️ Use the same candidate UUIDs from user_roles above
4148
INSERT INTO profiles (
4249
id,
4350
full_name,
@@ -48,17 +55,18 @@ INSERT INTO profiles (
4855
about_me,
4956
linkedin_url
5057
) VALUES
51-
('11111111-1111-1111-1111-111111111111', 'Ana Silva Santos', 'São Paulo', 'SP', 'Pleno', 'Desenvolvimento Web', 'Desenvolvedora Full Stack com 3 anos de experiência', 'https://linkedin.com/in/anasilva'),
52-
('11111111-1111-1111-1111-111111111112', 'Carlos Eduardo Oliveira', 'Rio de Janeiro', 'RJ', 'Sênior', 'DevOps', 'Especialista em infraestrutura cloud', 'https://linkedin.com/in/carloseduardo'),
53-
('11111111-1111-1111-1111-111111111113', 'Mariana Costa Lima', 'Belo Horizonte', 'MG', 'Júnior', 'UI/UX Design', 'Designer apaixonada por criar experiências incríveis', 'https://linkedin.com/in/marianacosta'),
54-
('11111111-1111-1111-1111-111111111114', 'Pedro Henrique Santos', 'Porto Alegre', 'RS', 'Pleno', 'Análise de Dados', 'Analista de dados com foco em business intelligence', 'https://linkedin.com/in/pedrosantos'),
55-
('11111111-1111-1111-1111-111111111115', 'Juliana Ferreira Souza', 'Curitiba', 'PR', 'Júnior', 'Marketing Digital', 'Profissional de marketing com experiência em redes sociais', 'https://linkedin.com/in/julianaferreira')
58+
('PUT-REAL-CANDIDATE-UUID-1'::uuid, 'Ana Silva Santos', 'São Paulo', 'SP', 'Pleno', 'Desenvolvimento Web', 'Desenvolvedora Full Stack com 3 anos de experiência', 'https://linkedin.com/in/anasilva'),
59+
('PUT-REAL-CANDIDATE-UUID-2'::uuid, 'Carlos Eduardo Oliveira', 'Rio de Janeiro', 'RJ', 'Sênior', 'DevOps', 'Especialista em infraestrutura cloud', 'https://linkedin.com/in/carloseduardo'),
60+
('PUT-REAL-CANDIDATE-UUID-3'::uuid, 'Mariana Costa Lima', 'Belo Horizonte', 'MG', 'Júnior', 'UI/UX Design', 'Designer apaixonada por criar experiências incríveis', 'https://linkedin.com/in/marianacosta'),
61+
('PUT-REAL-CANDIDATE-UUID-4'::uuid, 'Pedro Henrique Santos', 'Porto Alegre', 'RS', 'Pleno', 'Análise de Dados', 'Analista de dados com foco em business intelligence', 'https://linkedin.com/in/pedrosantos'),
62+
('PUT-REAL-CANDIDATE-UUID-5'::uuid, 'Juliana Ferreira Souza', 'Curitiba', 'PR', 'Júnior', 'Marketing Digital', 'Profissional de marketing com experiência em redes sociais', 'https://linkedin.com/in/julianaferreira')
5663
ON CONFLICT (id) DO NOTHING;
5764

5865
-- ============================================
5966
-- INSERTING COMPANY PROFILES (at least 5 records)
6067
-- ============================================
6168

69+
-- ⚠️ Use the same company UUIDs from user_roles above
6270
INSERT INTO company_profiles (
6371
user_id,
6472
fantasy_name,
@@ -69,17 +77,18 @@ INSERT INTO company_profiles (
6977
description,
7078
about
7179
) VALUES
72-
('22222222-2222-2222-2222-222222222221', 'TechInova Solutions', '12.345.678/0001-90', 'Technology', 'São Paulo', 'SP', 'Software development company', 'Leaders in digital transformation'),
73-
('22222222-2222-2222-2222-222222222222', 'DataCo Analytics', '23.456.789/0001-01', 'Data Science', 'Rio de Janeiro', 'RJ', 'Data analysis and AI', 'Transforming data into insights'),
74-
('22222222-2222-2222-2222-222222222223', 'DesignHub Studio', '34.567.890/0001-12', 'Design', 'Belo Horizonte', 'MG', 'Creative design agency', 'Creating visual experiences'),
75-
('22222222-2222-2222-2222-222222222224', 'CloudMasters Inc', '45.678.901/0001-23', 'Cloud Computing', 'Porto Alegre', 'RS', 'Cloud infrastructure specialists', 'Building the future in the cloud'),
76-
('22222222-2222-2222-2222-222222222225', 'Marketing Plus Digital', '56.789.012/0001-34', 'Marketing', 'Curitiba', 'PR', 'Digital marketing agency', 'Growing brands digitally')
80+
('PUT-REAL-COMPANY-UUID-1'::uuid, 'TechInova Solutions', '12.345.678/0001-90', 'Technology', 'São Paulo', 'SP', 'Software development company', 'Leaders in digital transformation'),
81+
('PUT-REAL-COMPANY-UUID-2'::uuid, 'DataCo Analytics', '23.456.789/0001-01', 'Data Science', 'Rio de Janeiro', 'RJ', 'Data analysis and AI', 'Transforming data into insights'),
82+
('PUT-REAL-COMPANY-UUID-3'::uuid, 'DesignHub Studio', '34.567.890/0001-12', 'Design', 'Belo Horizonte', 'MG', 'Creative design agency', 'Creating visual experiences'),
83+
('PUT-REAL-COMPANY-UUID-4'::uuid, 'CloudMasters Inc', '45.678.901/0001-23', 'Cloud Computing', 'Porto Alegre', 'RS', 'Cloud infrastructure specialists', 'Building the future in the cloud'),
84+
('PUT-REAL-COMPANY-UUID-5'::uuid, 'Marketing Plus Digital', '56.789.012/0001-34', 'Marketing', 'Curitiba', 'PR', 'Digital marketing agency', 'Growing brands digitally')
7785
ON CONFLICT (user_id) DO NOTHING;
7886

7987
-- ============================================
8088
-- INSERTING JOBS (at least 5 records)
8189
-- ============================================
8290

91+
-- ⚠️ Use the same company UUIDs from company_profiles above
8392
INSERT INTO jobs (
8493
company_id,
8594
title,
@@ -90,30 +99,30 @@ INSERT INTO jobs (
9099
is_remote,
91100
required_experience_level
92101
) VALUES
93-
('22222222-2222-2222-2222-222222222221', 'Full Stack Developer', 'Develop web applications with React and Node.js', 'CLT', 'São Paulo, SP', 'R$ 8.000 - R$ 12.000', true, 'Pleno'),
94-
('22222222-2222-2222-2222-222222222222', 'Data Scientist', 'Analyze data and build ML models', 'PJ', 'Rio de Janeiro, RJ', 'R$ 10.000 - R$ 15.000', true, 'Sênior'),
95-
('22222222-2222-2222-2222-222222222223', 'UI/UX Designer', 'Design intuitive and beautiful interfaces', 'CLT', 'Belo Horizonte, MG', 'R$ 5.000 - R$ 7.000', false, 'Júnior'),
96-
('22222222-2222-2222-2222-222222222224', 'DevOps Engineer', 'Manage cloud infrastructure and CI/CD', 'CLT', 'Porto Alegre, RS', 'R$ 9.000 - R$ 13.000', true, 'Pleno'),
97-
('22222222-2222-2222-2222-222222222225', 'Social Media Manager', 'Manage social media campaigns', 'PJ', 'Curitiba, PR', 'R$ 4.000 - R$ 6.000', true, 'Júnior')
102+
('PUT-REAL-COMPANY-UUID-1'::uuid, 'Full Stack Developer', 'Develop web applications with React and Node.js', 'CLT', 'São Paulo, SP', 'R$ 8.000 - R$ 12.000', true, 'Pleno'),
103+
('PUT-REAL-COMPANY-UUID-2'::uuid, 'Data Scientist', 'Analyze data and build ML models', 'PJ', 'Rio de Janeiro, RJ', 'R$ 10.000 - R$ 15.000', true, 'Sênior'),
104+
('PUT-REAL-COMPANY-UUID-3'::uuid, 'UI/UX Designer', 'Design intuitive and beautiful interfaces', 'CLT', 'Belo Horizonte, MG', 'R$ 5.000 - R$ 7.000', false, 'Júnior'),
105+
('PUT-REAL-COMPANY-UUID-4'::uuid, 'DevOps Engineer', 'Manage cloud infrastructure and CI/CD', 'CLT', 'Porto Alegre, RS', 'R$ 9.000 - R$ 13.000', true, 'Pleno'),
106+
('PUT-REAL-COMPANY-UUID-5'::uuid, 'Social Media Manager', 'Manage social media campaigns', 'PJ', 'Curitiba, PR', 'R$ 4.000 - R$ 6.000', true, 'Júnior')
98107
ON CONFLICT DO NOTHING;
99108

100109
-- ============================================
101110
-- INSERTING APPLICATIONS (at least 5 records)
102111
-- ============================================
103112

104-
-- Note: Use actual job IDs from your jobs table
105-
-- Get them with: SELECT id, title FROM jobs LIMIT 5;
113+
-- ⚠️ Use the candidate UUIDs from profiles above
114+
-- Jobs are auto-selected by title from the jobs table
106115

107116
INSERT INTO applications (
108117
candidate_id,
109118
job_id,
110119
status
111120
) VALUES
112-
('11111111-1111-1111-1111-111111111111', (SELECT id FROM jobs WHERE title = 'Full Stack Developer' LIMIT 1), 'pending'),
113-
('11111111-1111-1111-1111-111111111112', (SELECT id FROM jobs WHERE title = 'DevOps Engineer' LIMIT 1), 'accepted'),
114-
('11111111-1111-1111-1111-111111111113', (SELECT id FROM jobs WHERE title = 'UI/UX Designer' LIMIT 1), 'pending'),
115-
('11111111-1111-1111-1111-111111111114', (SELECT id FROM jobs WHERE title = 'Data Scientist' LIMIT 1), 'rejected'),
116-
('11111111-1111-1111-1111-111111111115', (SELECT id FROM jobs WHERE title = 'Social Media Manager' LIMIT 1), 'accepted')
121+
('PUT-REAL-CANDIDATE-UUID-1'::uuid, (SELECT id FROM jobs WHERE title = 'Full Stack Developer' LIMIT 1), 'pending'),
122+
('PUT-REAL-CANDIDATE-UUID-2'::uuid, (SELECT id FROM jobs WHERE title = 'DevOps Engineer' LIMIT 1), 'accepted'),
123+
('PUT-REAL-CANDIDATE-UUID-3'::uuid, (SELECT id FROM jobs WHERE title = 'UI/UX Designer' LIMIT 1), 'pending'),
124+
('PUT-REAL-CANDIDATE-UUID-4'::uuid, (SELECT id FROM jobs WHERE title = 'Data Scientist' LIMIT 1), 'rejected'),
125+
('PUT-REAL-CANDIDATE-UUID-5'::uuid, (SELECT id FROM jobs WHERE title = 'Social Media Manager' LIMIT 1), 'accepted')
117126
ON CONFLICT DO NOTHING;
118127

119128
-- ============================================
@@ -128,7 +137,7 @@ SET contract_status = 'completed', completed_at = NOW()
128137
WHERE status = 'accepted'
129138
LIMIT 2;
130139

131-
-- Now insert ratings (get actual application IDs first)
140+
-- ⚠️ Use the UUIDs you set above
132141
INSERT INTO ratings (
133142
application_id,
134143
rater_id,
@@ -137,38 +146,39 @@ INSERT INTO ratings (
137146
comment
138147
) VALUES
139148
-- Company rating candidate
140-
((SELECT id FROM applications WHERE status = 'accepted' LIMIT 1), '22222222-2222-2222-2222-222222222222', '11111111-1111-1111-1111-111111111112', 4.5, 'Excellent professional, delivered on time'),
149+
((SELECT id FROM applications WHERE status = 'accepted' LIMIT 1), 'PUT-REAL-COMPANY-UUID-2'::uuid, 'PUT-REAL-CANDIDATE-UUID-2'::uuid, 4.5, 'Excellent professional, delivered on time'),
141150
-- Candidate rating company
142-
((SELECT id FROM applications WHERE status = 'accepted' LIMIT 1), '11111111-1111-1111-1111-111111111112', '22222222-2222-2222-2222-222222222222', 5.0, 'Great company to work with'),
151+
((SELECT id FROM applications WHERE status = 'accepted' LIMIT 1), 'PUT-REAL-CANDIDATE-UUID-2'::uuid, 'PUT-REAL-COMPANY-UUID-2'::uuid, 5.0, 'Great company to work with'),
143152
-- More ratings
144-
((SELECT id FROM applications WHERE status = 'accepted' OFFSET 1 LIMIT 1), '22222222-2222-2222-2222-222222222225', '11111111-1111-1111-1111-111111111115', 4.0, 'Good work ethic'),
145-
((SELECT id FROM applications WHERE status = 'accepted' OFFSET 1 LIMIT 1), '11111111-1111-1111-1111-111111111115', '22222222-2222-2222-2222-222222222225', 4.5, 'Professional environment'),
146-
((SELECT id FROM applications WHERE status = 'accepted' LIMIT 1), '22222222-2222-2222-2222-222222222221', '11111111-1111-1111-1111-111111111111', 5.0, 'Outstanding developer')
153+
((SELECT id FROM applications WHERE status = 'accepted' OFFSET 1 LIMIT 1), 'PUT-REAL-COMPANY-UUID-5'::uuid, 'PUT-REAL-CANDIDATE-UUID-5'::uuid, 4.0, 'Good work ethic'),
154+
((SELECT id FROM applications WHERE status = 'accepted' OFFSET 1 LIMIT 1), 'PUT-REAL-CANDIDATE-UUID-5'::uuid, 'PUT-REAL-COMPANY-UUID-5'::uuid, 4.5, 'Professional environment'),
155+
((SELECT id FROM applications WHERE status = 'accepted' LIMIT 1), 'PUT-REAL-COMPANY-UUID-1'::uuid, 'PUT-REAL-CANDIDATE-UUID-1'::uuid, 5.0, 'Outstanding developer')
147156
ON CONFLICT DO NOTHING;
148157

149158
-- ============================================
150159
-- INSERTING NOTIFICATIONS (at least 5 records)
151160
-- ============================================
152161

162+
-- ⚠️ Use the UUIDs you set above
153163
INSERT INTO notifications (
154164
user_id,
155165
title,
156166
message,
157167
type,
158168
related_id
159169
) VALUES
160-
('11111111-1111-1111-1111-111111111111', 'New Match!', 'You matched with TechInova Solutions', 'match', (SELECT id FROM jobs WHERE title = 'Full Stack Developer' LIMIT 1)),
161-
('22222222-2222-2222-2222-222222222222', 'New Application', 'Ana Silva Santos applied for your job', 'new_application', (SELECT id FROM applications WHERE candidate_id = '11111111-1111-1111-1111-111111111111' LIMIT 1)),
162-
('11111111-1111-1111-1111-111111111112', 'Application Accepted!', 'Your application was accepted', 'application_accepted', (SELECT id FROM applications WHERE candidate_id = '11111111-1111-1111-1111-111111111112' LIMIT 1)),
163-
('11111111-1111-1111-1111-111111111113', 'Profile Viewed', 'DesignHub Studio viewed your profile', 'profile_view', NULL),
164-
('22222222-2222-2222-2222-222222222221', 'New Rating', 'You received a 5-star rating', 'new_rating', (SELECT id FROM ratings WHERE rated_user_id = '22222222-2222-2222-2222-222222222221' LIMIT 1))
170+
('PUT-REAL-CANDIDATE-UUID-1'::uuid, 'New Match!', 'You matched with TechInova Solutions', 'match', (SELECT id FROM jobs WHERE title = 'Full Stack Developer' LIMIT 1)),
171+
('PUT-REAL-COMPANY-UUID-2'::uuid, 'New Application', 'Ana Silva Santos applied for your job', 'new_application', (SELECT id FROM applications WHERE candidate_id = 'PUT-REAL-CANDIDATE-UUID-1'::uuid LIMIT 1)),
172+
('PUT-REAL-CANDIDATE-UUID-2'::uuid, 'Application Accepted!', 'Your application was accepted', 'application_accepted', (SELECT id FROM applications WHERE candidate_id = 'PUT-REAL-CANDIDATE-UUID-2'::uuid LIMIT 1)),
173+
('PUT-REAL-CANDIDATE-UUID-3'::uuid, 'Profile Viewed', 'DesignHub Studio viewed your profile', 'profile_view', NULL),
174+
('PUT-REAL-COMPANY-UUID-1'::uuid, 'New Rating', 'You received a 5-star rating', 'new_rating', (SELECT id FROM ratings WHERE rated_user_id = 'PUT-REAL-COMPANY-UUID-1'::uuid LIMIT 1))
165175
ON CONFLICT DO NOTHING;
166176

167177
-- ============================================
168178
-- INSERTING TESTIMONIALS (at least 5 records)
169179
-- ============================================
170180

171-
-- Note: Testimonials require completed applications
181+
-- ⚠️ Use the UUIDs you set above
172182
INSERT INTO testimonials (
173183
application_id,
174184
candidate_id,
@@ -177,11 +187,11 @@ INSERT INTO testimonials (
177187
comment,
178188
status
179189
) VALUES
180-
((SELECT id FROM applications WHERE contract_status = 'completed' LIMIT 1), '11111111-1111-1111-1111-111111111112', '22222222-2222-2222-2222-222222222222', 'DevOps Engineer', 'Amazing experience working here. Great team and challenging projects.', 'approved'),
181-
((SELECT id FROM applications WHERE contract_status = 'completed' OFFSET 1 LIMIT 1), '11111111-1111-1111-1111-111111111115', '22222222-2222-2222-2222-222222222225', 'Social Media Manager', 'Learned a lot and had great support from the team.', 'approved'),
182-
((SELECT id FROM applications WHERE status = 'accepted' LIMIT 1), '11111111-1111-1111-1111-111111111111', '22222222-2222-2222-2222-222222222221', 'Full Stack Developer', 'Professional environment with growth opportunities.', 'pending'),
183-
((SELECT id FROM applications WHERE status = 'accepted' OFFSET 2 LIMIT 1), '11111111-1111-1111-1111-111111111113', '22222222-2222-2222-2222-222222222223', 'UI/UX Designer', 'Creative freedom and supportive leadership.', 'approved'),
184-
((SELECT id FROM applications WHERE status = 'accepted' OFFSET 3 LIMIT 1), '11111111-1111-1111-1111-111111111114', '22222222-2222-2222-2222-222222222224', 'Data Scientist', 'Innovative company with cutting-edge technology.', 'pending')
190+
((SELECT id FROM applications WHERE contract_status = 'completed' LIMIT 1), 'PUT-REAL-CANDIDATE-UUID-2'::uuid, 'PUT-REAL-COMPANY-UUID-2'::uuid, 'DevOps Engineer', 'Amazing experience working here. Great team and challenging projects.', 'approved'),
191+
((SELECT id FROM applications WHERE contract_status = 'completed' OFFSET 1 LIMIT 1), 'PUT-REAL-CANDIDATE-UUID-5'::uuid, 'PUT-REAL-COMPANY-UUID-5'::uuid, 'Social Media Manager', 'Learned a lot and had great support from the team.', 'approved'),
192+
((SELECT id FROM applications WHERE status = 'accepted' LIMIT 1), 'PUT-REAL-CANDIDATE-UUID-1'::uuid, 'PUT-REAL-COMPANY-UUID-1'::uuid, 'Full Stack Developer', 'Professional environment with growth opportunities.', 'pending'),
193+
((SELECT id FROM applications WHERE status = 'accepted' OFFSET 2 LIMIT 1), 'PUT-REAL-CANDIDATE-UUID-3'::uuid, 'PUT-REAL-COMPANY-UUID-3'::uuid, 'UI/UX Designer', 'Creative freedom and supportive leadership.', 'approved'),
194+
((SELECT id FROM applications WHERE status = 'accepted' OFFSET 3 LIMIT 1), 'PUT-REAL-CANDIDATE-UUID-4'::uuid, 'PUT-REAL-COMPANY-UUID-4'::uuid, 'Data Scientist', 'Innovative company with cutting-edge technology.', 'pending')
185195
ON CONFLICT (application_id) DO NOTHING;
186196

187197
-- ============================================

0 commit comments

Comments
 (0)