nxtgauge-backend-rust/crates/db/migrations/20260422000000_seed_widgets.seed.sql
Ashwin Kumar Sivakumar 73beb03368
All checks were successful
build-and-release / build (catering-services) (push) Successful in 1m45s
build-and-release / build (developers) (push) Successful in 1m43s
build-and-release / build (companies) (push) Successful in 1m53s
build-and-release / build (cron) (push) Successful in 2m9s
build-and-release / build (customers) (push) Successful in 2m27s
build-and-release / build (employees) (push) Successful in 1m46s
build-and-release / build (fitness-trainers) (push) Successful in 1m48s
build-and-release / build (graphic-designers) (push) Successful in 1m47s
build-and-release / build (jobs) (push) Successful in 1m32s
build-and-release / build (gateway) (push) Successful in 2m21s
build-and-release / build (job-seekers) (push) Successful in 2m53s
build-and-release / build (photographers) (push) Successful in 1m32s
build-and-release / build (makeup-artists) (push) Successful in 1m58s
build-and-release / build (social-media-managers) (push) Successful in 2m17s
build-and-release / build (payments) (push) Successful in 2m51s
build-and-release / build (tutors) (push) Successful in 2m38s
build-and-release / build (ugc-content-creators) (push) Successful in 2m41s
build-and-release / build (video-editors) (push) Successful in 2m39s
build-and-release / build (users) (push) Successful in 4m13s
fix: seed verification_status into JOB_SEEKER dashboard widgets
The live role_sidebar_configs row for JOB_SEEKER never included this
widget, so the verification status badge never rendered. Also applied
directly to the live DB row (this seed file wasn't wired into any
auto-run migration path, so editing it alone wouldn't have taken effect).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-23 04:26:05 +05:30

84 lines
2.8 KiB
SQL

-- Seed widgets into existing role_sidebar_configs for EXTERNAL roles
-- This ensures the widget-based dashboard renders correctly for all roles.
--
-- Run this AFTER migrations are applied:
-- psql $DATABASE_URL -f crates/db/migrations/YYYYMMDDTTTTTT_add_widgets_to_sidebar_configs.seed.sql
-- Update COMPANY roles
UPDATE role_sidebar_configs
SET config_json = jsonb_set(
COALESCE(config_json, '{}'::jsonb),
'{widgets}',
'["total_jobs", "active_jobs", "pending_jobs", "applications_received", "shortlisted_candidates", "credits"]'::jsonb,
true
)
WHERE audience = 'EXTERNAL'
AND is_active = true
AND EXISTS (
SELECT 1 FROM roles r WHERE r.id = role_sidebar_configs.role_id AND r.key = 'COMPANY'
);
-- Update JOB_SEEKER roles
UPDATE role_sidebar_configs
SET config_json = jsonb_set(
COALESCE(config_json, '{}'::jsonb),
'{widgets}',
'["available_jobs", "my_applications", "shortlisted", "saved_jobs", "profile_status", "verification_status", "portfolio"]'::jsonb,
true
)
WHERE audience = 'EXTERNAL'
AND is_active = true
AND EXISTS (
SELECT 1 FROM roles r WHERE r.id = role_sidebar_configs.role_id AND r.key = 'JOB_SEEKER'
);
-- Update CUSTOMER roles
UPDATE role_sidebar_configs
SET config_json = jsonb_set(
COALESCE(config_json, '{}'::jsonb),
'{widgets}',
'["total_requirements", "open_requirements", "closed_requirements", "responses_received", "shortlisted_responses", "credits"]'::jsonb,
true
)
WHERE audience = 'EXTERNAL'
AND is_active = true
AND EXISTS (
SELECT 1 FROM roles r WHERE r.id = role_sidebar_configs.role_id AND r.key = 'CUSTOMER'
);
-- Update all remaining EXTERNAL roles (PROFESSIONAL: photographer, makeup, tutor, etc.)
UPDATE role_sidebar_configs
SET config_json = jsonb_set(
COALESCE(config_json, '{}'::jsonb),
'{widgets}',
'["open_leads", "my_requests", "accepted_requests", "tracecoins", "portfolio", "profile_status"]'::jsonb,
true
)
WHERE audience = 'EXTERNAL'
AND is_active = true
AND NOT EXISTS (
SELECT 1 FROM roles r WHERE r.id = role_sidebar_configs.role_id AND r.key IN ('COMPANY', 'JOB_SEEKER', 'CUSTOMER')
);
-- Also seed widgets in role_runtime_configs if they differ from role_sidebar_configs
-- (some setups read widgets from runtime_configs)
UPDATE role_runtime_configs
SET config_json = jsonb_set(
COALESCE(config_json, '{}'::jsonb),
'{widgets}',
COALESCE(
(
SELECT config_json->'widgets'
FROM role_sidebar_configs sc
WHERE sc.role_id = role_runtime_configs.role_id
AND sc.audience = 'EXTERNAL'
AND sc.is_active = true
LIMIT 1
),
'["open_leads", "my_requests", "accepted_requests", "tracecoins", "portfolio", "profile_status"]'::jsonb
),
true
)
WHERE is_active = true;
SELECT 'Widget seed completed.' AS status;