Trim baseline seed to one super admin and drop demo student.
Remove admin/content team demo accounts and student@yimaru.com; keep a single superadmin upsert and cleanup on reseed. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
7571ee4f1c
commit
e68814c2c5
|
|
@ -5,7 +5,7 @@ CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
|||
-- Customer/Learner Users (login via /api/v1/auth/customer-login)
|
||||
-- Credentials: email + password@123
|
||||
-- OPEN_LEARNER demo user (openlearner@yimaru.com) is seeded by migration 000061_open_learner_role.
|
||||
-- Additional OPEN_LEARNER users are seeded below.
|
||||
-- Optional sample STUDENT / OPEN_LEARNER rows below (no demo student@yimaru.com account).
|
||||
-- ======================================================
|
||||
INSERT INTO users (
|
||||
id,
|
||||
|
|
@ -40,38 +40,6 @@ INSERT INTO users (
|
|||
updated_at
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
10,
|
||||
'Demo',
|
||||
'Student',
|
||||
'Male',
|
||||
'2000-01-01',
|
||||
'student@yimaru.com',
|
||||
NULL,
|
||||
'STUDENT',
|
||||
crypt('password@123', gen_salt('bf'))::bytea,
|
||||
'25_34',
|
||||
'Bachelor',
|
||||
'Ethiopia',
|
||||
'Addis Ababa',
|
||||
'BEGINNER',
|
||||
'Demo',
|
||||
'Student',
|
||||
'Learn programming',
|
||||
'English',
|
||||
'Grammar',
|
||||
'Technology',
|
||||
FALSE,
|
||||
TRUE,
|
||||
FALSE,
|
||||
'ACTIVE',
|
||||
NULL,
|
||||
FALSE,
|
||||
NULL,
|
||||
'en',
|
||||
CURRENT_TIMESTAMP,
|
||||
NULL
|
||||
),
|
||||
(
|
||||
11,
|
||||
'Abebe',
|
||||
|
|
@ -138,6 +106,9 @@ VALUES
|
|||
)
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
DELETE FROM users
|
||||
WHERE LOWER(TRIM(email)) = 'student@yimaru.com';
|
||||
|
||||
-- OPEN_LEARNER learners (login via /api/v1/auth/customer-login)
|
||||
-- Credentials: email + password@123
|
||||
INSERT INTO users (
|
||||
|
|
@ -234,86 +205,8 @@ WHERE LOWER(TRIM(email)) = 'tsegaye.negera@reachforchange.org'
|
|||
-- Credentials: email + password@123
|
||||
-- Allowed team_role values (migration 000103): SUPER_ADMIN, ADMIN, CONTENT_MANAGER
|
||||
-- Super Admin: superadmin@yimaru.com / password@123
|
||||
-- Admin: admin@yimaru.com / password@123
|
||||
-- Content: content@yimaru.com / password@123
|
||||
-- ======================================================
|
||||
|
||||
INSERT INTO team_members (
|
||||
id,
|
||||
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
|
||||
(
|
||||
1,
|
||||
'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
|
||||
),
|
||||
(
|
||||
2,
|
||||
'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
|
||||
),
|
||||
(
|
||||
3,
|
||||
'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 (id) DO NOTHING;
|
||||
|
||||
-- Ensure staff logins exist even if ids were already taken by other rows.
|
||||
INSERT INTO team_members (
|
||||
first_name,
|
||||
last_name,
|
||||
|
|
@ -350,113 +243,33 @@ VALUES
|
|||
CURRENT_TIMESTAMP
|
||||
)
|
||||
ON CONFLICT (email) DO UPDATE SET
|
||||
first_name = EXCLUDED.first_name,
|
||||
last_name = EXCLUDED.last_name,
|
||||
phone_number = EXCLUDED.phone_number,
|
||||
password = EXCLUDED.password,
|
||||
team_role = 'SUPER_ADMIN',
|
||||
department = EXCLUDED.department,
|
||||
job_title = EXCLUDED.job_title,
|
||||
employment_type = EXCLUDED.employment_type,
|
||||
hire_date = EXCLUDED.hire_date,
|
||||
bio = EXCLUDED.bio,
|
||||
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;
|
||||
-- Remove legacy demo staff seeds (admin/content); keep super admin only.
|
||||
UPDATE scheduled_notifications sn
|
||||
SET created_by = tm_super.id
|
||||
FROM team_members tm_super
|
||||
WHERE LOWER(TRIM(tm_super.email)) = 'superadmin@yimaru.com'
|
||||
AND sn.created_by IN (
|
||||
SELECT id FROM team_members
|
||||
WHERE LOWER(TRIM(email)) IN ('admin@yimaru.com', 'content@yimaru.com')
|
||||
);
|
||||
|
||||
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.
|
||||
UPDATE team_members
|
||||
SET permissions = '["*"]'::jsonb,
|
||||
team_role = 'SUPER_ADMIN',
|
||||
status = 'active',
|
||||
email_verified = TRUE,
|
||||
password = crypt('password@123', gen_salt('bf'))::bytea,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = 1 OR email = 'superadmin@yimaru.com';
|
||||
|
||||
UPDATE team_members
|
||||
SET permissions = '["*"]'::jsonb,
|
||||
password = crypt('password@123', gen_salt('bf'))::bytea,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = 2 OR email = 'admin@yimaru.com';
|
||||
DELETE FROM team_members
|
||||
WHERE LOWER(TRIM(email)) IN ('admin@yimaru.com', 'content@yimaru.com');
|
||||
|
||||
-- ======================================================
|
||||
-- RBAC safety seed: ensure ADMIN / SUPER_ADMIN have permission grants
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user