Fix team member seed for allowed roles so Super Admin can be created.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
f838299547
commit
edcdaa5bfb
|
|
@ -232,8 +232,10 @@ WHERE LOWER(TRIM(email)) = 'tsegaye.negera@reachforchange.org'
|
||||||
-- ======================================================
|
-- ======================================================
|
||||||
-- Team Members / Admin Panel Users (login via /api/v1/team/login)
|
-- Team Members / Admin Panel Users (login via /api/v1/team/login)
|
||||||
-- Credentials: email + password@123
|
-- Credentials: email + password@123
|
||||||
|
-- Allowed team_role values (migration 000103): SUPER_ADMIN, ADMIN, CONTENT_MANAGER
|
||||||
-- Super Admin: superadmin@yimaru.com / password@123
|
-- Super Admin: superadmin@yimaru.com / password@123
|
||||||
-- Admin: admin@yimaru.com / password@123
|
-- Admin: admin@yimaru.com / password@123
|
||||||
|
-- Content: content@yimaru.com / password@123
|
||||||
-- ======================================================
|
-- ======================================================
|
||||||
|
|
||||||
INSERT INTO team_members (
|
INSERT INTO team_members (
|
||||||
|
|
@ -308,109 +310,152 @@ VALUES
|
||||||
TRUE,
|
TRUE,
|
||||||
'["courses.manage", "courses.publish", "content.manage"]'::jsonb,
|
'["courses.manage", "courses.publish", "content.manage"]'::jsonb,
|
||||||
CURRENT_TIMESTAMP
|
CURRENT_TIMESTAMP
|
||||||
),
|
|
||||||
(
|
|
||||||
4,
|
|
||||||
'Support',
|
|
||||||
'AGENT',
|
|
||||||
'support-team@yimaru.com',
|
|
||||||
'0944001100',
|
|
||||||
crypt('password@123', gen_salt('bf'))::bytea,
|
|
||||||
'SUPPORT_AGENT',
|
|
||||||
'Support',
|
|
||||||
'Customer Support Specialist',
|
|
||||||
'full_time',
|
|
||||||
'2024-03-15',
|
|
||||||
'Handles customer inquiries and support tickets.',
|
|
||||||
'active',
|
|
||||||
TRUE,
|
|
||||||
'["users.view", "tickets.manage", "support.manage"]'::jsonb,
|
|
||||||
CURRENT_TIMESTAMP
|
|
||||||
),
|
|
||||||
(
|
|
||||||
5,
|
|
||||||
'INSTRUCTOR',
|
|
||||||
'Demo',
|
|
||||||
'instructor@yimaru.com',
|
|
||||||
'0955001100',
|
|
||||||
crypt('password@123', gen_salt('bf'))::bytea,
|
|
||||||
'INSTRUCTOR',
|
|
||||||
'Education',
|
|
||||||
'Senior Instructor',
|
|
||||||
'full_time',
|
|
||||||
'2024-04-01',
|
|
||||||
'Creates and manages course materials.',
|
|
||||||
'active',
|
|
||||||
TRUE,
|
|
||||||
'["courses.create", "courses.edit", "students.view"]'::jsonb,
|
|
||||||
CURRENT_TIMESTAMP
|
|
||||||
),
|
|
||||||
(
|
|
||||||
6,
|
|
||||||
'FINANCE',
|
|
||||||
'Officer',
|
|
||||||
'finance@yimaru.com',
|
|
||||||
'0966001100',
|
|
||||||
crypt('password@123', gen_salt('bf'))::bytea,
|
|
||||||
'FINANCE',
|
|
||||||
'Finance',
|
|
||||||
'Finance Officer',
|
|
||||||
'full_time',
|
|
||||||
'2024-04-15',
|
|
||||||
'Manages payments, subscriptions, and financial reports.',
|
|
||||||
'active',
|
|
||||||
TRUE,
|
|
||||||
'["payments.manage", "subscriptions.manage", "reports.finance"]'::jsonb,
|
|
||||||
CURRENT_TIMESTAMP
|
|
||||||
),
|
|
||||||
(
|
|
||||||
7,
|
|
||||||
'HR',
|
|
||||||
'MANAGER',
|
|
||||||
'hr@yimaru.com',
|
|
||||||
'0977001100',
|
|
||||||
crypt('password@123', gen_salt('bf'))::bytea,
|
|
||||||
'HR',
|
|
||||||
'Human Resources',
|
|
||||||
'HR Manager',
|
|
||||||
'full_time',
|
|
||||||
'2024-05-01',
|
|
||||||
'Manages team members and HR operations.',
|
|
||||||
'active',
|
|
||||||
TRUE,
|
|
||||||
'["team.manage", "team.create", "team.delete"]'::jsonb,
|
|
||||||
CURRENT_TIMESTAMP
|
|
||||||
),
|
|
||||||
(
|
|
||||||
8,
|
|
||||||
'Data',
|
|
||||||
'Analyst',
|
|
||||||
'analyst@yimaru.com',
|
|
||||||
'0988001100',
|
|
||||||
crypt('password@123', gen_salt('bf'))::bytea,
|
|
||||||
'ANALYST',
|
|
||||||
'Analytics',
|
|
||||||
'Data Analyst',
|
|
||||||
'contract',
|
|
||||||
'2024-06-01',
|
|
||||||
'Generates reports and analyzes platform metrics.',
|
|
||||||
'active',
|
|
||||||
TRUE,
|
|
||||||
'["reports.view", "analytics.view", "users.view"]'::jsonb,
|
|
||||||
CURRENT_TIMESTAMP
|
|
||||||
)
|
)
|
||||||
ON CONFLICT (id) DO NOTHING;
|
ON CONFLICT (id) DO NOTHING;
|
||||||
|
|
||||||
|
-- Ensure staff logins exist even if ids were already taken by other rows.
|
||||||
|
INSERT INTO team_members (
|
||||||
|
first_name,
|
||||||
|
last_name,
|
||||||
|
email,
|
||||||
|
phone_number,
|
||||||
|
password,
|
||||||
|
team_role,
|
||||||
|
department,
|
||||||
|
job_title,
|
||||||
|
employment_type,
|
||||||
|
hire_date,
|
||||||
|
bio,
|
||||||
|
status,
|
||||||
|
email_verified,
|
||||||
|
permissions,
|
||||||
|
created_at
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
'Super',
|
||||||
|
'Admin',
|
||||||
|
'superadmin@yimaru.com',
|
||||||
|
'0911001100',
|
||||||
|
crypt('password@123', gen_salt('bf'))::bytea,
|
||||||
|
'SUPER_ADMIN',
|
||||||
|
'Executive',
|
||||||
|
'System Super Administrator',
|
||||||
|
'full_time',
|
||||||
|
'2024-01-01',
|
||||||
|
'Platform super administrator with full system access including team invitations.',
|
||||||
|
'active',
|
||||||
|
TRUE,
|
||||||
|
'["*"]'::jsonb,
|
||||||
|
CURRENT_TIMESTAMP
|
||||||
|
)
|
||||||
|
ON CONFLICT (email) DO UPDATE SET
|
||||||
|
password = EXCLUDED.password,
|
||||||
|
team_role = 'SUPER_ADMIN',
|
||||||
|
status = 'active',
|
||||||
|
email_verified = TRUE,
|
||||||
|
permissions = '["*"]'::jsonb,
|
||||||
|
updated_at = CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
|
INSERT INTO team_members (
|
||||||
|
first_name,
|
||||||
|
last_name,
|
||||||
|
email,
|
||||||
|
phone_number,
|
||||||
|
password,
|
||||||
|
team_role,
|
||||||
|
department,
|
||||||
|
job_title,
|
||||||
|
employment_type,
|
||||||
|
hire_date,
|
||||||
|
bio,
|
||||||
|
status,
|
||||||
|
email_verified,
|
||||||
|
permissions,
|
||||||
|
created_at
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
'Admin',
|
||||||
|
'User',
|
||||||
|
'admin@yimaru.com',
|
||||||
|
'0922001100',
|
||||||
|
crypt('password@123', gen_salt('bf'))::bytea,
|
||||||
|
'ADMIN',
|
||||||
|
'Operations',
|
||||||
|
'Operations Manager',
|
||||||
|
'full_time',
|
||||||
|
'2024-02-01',
|
||||||
|
'Administrative staff managing day-to-day operations.',
|
||||||
|
'active',
|
||||||
|
TRUE,
|
||||||
|
'["*"]'::jsonb,
|
||||||
|
CURRENT_TIMESTAMP
|
||||||
|
)
|
||||||
|
ON CONFLICT (email) DO UPDATE SET
|
||||||
|
password = EXCLUDED.password,
|
||||||
|
team_role = 'ADMIN',
|
||||||
|
status = 'active',
|
||||||
|
email_verified = TRUE,
|
||||||
|
permissions = '["*"]'::jsonb,
|
||||||
|
updated_at = CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
|
INSERT INTO team_members (
|
||||||
|
first_name,
|
||||||
|
last_name,
|
||||||
|
email,
|
||||||
|
phone_number,
|
||||||
|
password,
|
||||||
|
team_role,
|
||||||
|
department,
|
||||||
|
job_title,
|
||||||
|
employment_type,
|
||||||
|
hire_date,
|
||||||
|
bio,
|
||||||
|
status,
|
||||||
|
email_verified,
|
||||||
|
permissions,
|
||||||
|
created_at
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
'Content',
|
||||||
|
'MANAGER',
|
||||||
|
'content@yimaru.com',
|
||||||
|
'0933001100',
|
||||||
|
crypt('password@123', gen_salt('bf'))::bytea,
|
||||||
|
'CONTENT_MANAGER',
|
||||||
|
'Content',
|
||||||
|
'Content Lead',
|
||||||
|
'full_time',
|
||||||
|
'2024-03-01',
|
||||||
|
'Manages all course content and curriculum.',
|
||||||
|
'active',
|
||||||
|
TRUE,
|
||||||
|
'["courses.manage", "courses.publish", "content.manage"]'::jsonb,
|
||||||
|
CURRENT_TIMESTAMP
|
||||||
|
)
|
||||||
|
ON CONFLICT (email) DO UPDATE SET
|
||||||
|
password = EXCLUDED.password,
|
||||||
|
team_role = 'CONTENT_MANAGER',
|
||||||
|
status = 'active',
|
||||||
|
email_verified = TRUE,
|
||||||
|
updated_at = CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
-- Legacy team_members rows may pre-exist; align admin permissions with seed expectations.
|
-- Legacy team_members rows may pre-exist; align admin permissions with seed expectations.
|
||||||
UPDATE team_members
|
UPDATE team_members
|
||||||
SET permissions = '["*"]'::jsonb,
|
SET permissions = '["*"]'::jsonb,
|
||||||
team_role = 'SUPER_ADMIN',
|
team_role = 'SUPER_ADMIN',
|
||||||
status = 'active',
|
status = 'active',
|
||||||
email_verified = TRUE
|
email_verified = TRUE,
|
||||||
|
password = crypt('password@123', gen_salt('bf'))::bytea,
|
||||||
|
updated_at = CURRENT_TIMESTAMP
|
||||||
WHERE id = 1 OR email = 'superadmin@yimaru.com';
|
WHERE id = 1 OR email = 'superadmin@yimaru.com';
|
||||||
|
|
||||||
UPDATE team_members
|
UPDATE team_members
|
||||||
SET permissions = '["*"]'::jsonb
|
SET permissions = '["*"]'::jsonb,
|
||||||
|
password = crypt('password@123', gen_salt('bf'))::bytea,
|
||||||
|
updated_at = CURRENT_TIMESTAMP
|
||||||
WHERE id = 2 OR email = 'admin@yimaru.com';
|
WHERE id = 2 OR email = 'admin@yimaru.com';
|
||||||
|
|
||||||
-- ======================================================
|
-- ======================================================
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user