fix: professionals (photographer, tutor, developer, etc.) couldn't submit profiles/documents
The generic profile save/get/submit handlers (apps/users/src/handlers/profile.rs) have always read and written every non-COMPANY/JOB_SEEKER role's table via `... WHERE user_role_profile_id = $1`, but that linking column was never migrated onto any of the 10 profession tables (photographer_profiles, tutor_profiles, makeup_artist_profiles, developer_profiles, video_editor_profiles, graphic_designer_profiles, social_media_manager_profiles, fitness_trainer_profiles, catering_service_profiles, ugc_content_creator_profiles) — it only existed in a migration that was disabled (20260415010003, .skip). Every basic-info save, document upload persistence, and verification submission for these professions has therefore always failed with "column user_role_profile_id does not exist". Adds the column (+ backfill from existing user_role_profiles rows, + index) to all 10 tables. No application code changes needed — the Rust handlers were already written correctly for this schema.
This commit is contained in:
parent
2e95c4750b
commit
28b09aa019
2 changed files with 126 additions and 0 deletions
|
|
@ -0,0 +1,10 @@
|
|||
ALTER TABLE photographer_profiles DROP COLUMN IF EXISTS user_role_profile_id;
|
||||
ALTER TABLE tutor_profiles DROP COLUMN IF EXISTS user_role_profile_id;
|
||||
ALTER TABLE makeup_artist_profiles DROP COLUMN IF EXISTS user_role_profile_id;
|
||||
ALTER TABLE developer_profiles DROP COLUMN IF EXISTS user_role_profile_id;
|
||||
ALTER TABLE video_editor_profiles DROP COLUMN IF EXISTS user_role_profile_id;
|
||||
ALTER TABLE graphic_designer_profiles DROP COLUMN IF EXISTS user_role_profile_id;
|
||||
ALTER TABLE social_media_manager_profiles DROP COLUMN IF EXISTS user_role_profile_id;
|
||||
ALTER TABLE fitness_trainer_profiles DROP COLUMN IF EXISTS user_role_profile_id;
|
||||
ALTER TABLE catering_service_profiles DROP COLUMN IF EXISTS user_role_profile_id;
|
||||
ALTER TABLE ugc_content_creator_profiles DROP COLUMN IF EXISTS user_role_profile_id;
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
-- The generic profile save/get handlers (apps/users/src/handlers/profile.rs)
|
||||
-- have always read and written every non-COMPANY/JOB_SEEKER role's profile
|
||||
-- table (INSERT/SELECT ... WHERE user_role_profile_id = ...), but this
|
||||
-- linking column was never migrated onto any of the profession tables — it
|
||||
-- only ever existed in a disabled migration (20260415010003, .skip). Every
|
||||
-- profile save/submit and document upload for these 10 professions has
|
||||
-- therefore always failed with "column user_role_profile_id does not exist".
|
||||
ALTER TABLE photographer_profiles ADD COLUMN IF NOT EXISTS user_role_profile_id UUID REFERENCES user_role_profiles(id) ON DELETE CASCADE;
|
||||
ALTER TABLE tutor_profiles ADD COLUMN IF NOT EXISTS user_role_profile_id UUID REFERENCES user_role_profiles(id) ON DELETE CASCADE;
|
||||
ALTER TABLE makeup_artist_profiles ADD COLUMN IF NOT EXISTS user_role_profile_id UUID REFERENCES user_role_profiles(id) ON DELETE CASCADE;
|
||||
ALTER TABLE developer_profiles ADD COLUMN IF NOT EXISTS user_role_profile_id UUID REFERENCES user_role_profiles(id) ON DELETE CASCADE;
|
||||
ALTER TABLE video_editor_profiles ADD COLUMN IF NOT EXISTS user_role_profile_id UUID REFERENCES user_role_profiles(id) ON DELETE CASCADE;
|
||||
ALTER TABLE graphic_designer_profiles ADD COLUMN IF NOT EXISTS user_role_profile_id UUID REFERENCES user_role_profiles(id) ON DELETE CASCADE;
|
||||
ALTER TABLE social_media_manager_profiles ADD COLUMN IF NOT EXISTS user_role_profile_id UUID REFERENCES user_role_profiles(id) ON DELETE CASCADE;
|
||||
ALTER TABLE fitness_trainer_profiles ADD COLUMN IF NOT EXISTS user_role_profile_id UUID REFERENCES user_role_profiles(id) ON DELETE CASCADE;
|
||||
ALTER TABLE catering_service_profiles ADD COLUMN IF NOT EXISTS user_role_profile_id UUID REFERENCES user_role_profiles(id) ON DELETE CASCADE;
|
||||
ALTER TABLE ugc_content_creator_profiles ADD COLUMN IF NOT EXISTS user_role_profile_id UUID REFERENCES user_role_profiles(id) ON DELETE CASCADE;
|
||||
|
||||
-- Backfill for any rows created by earlier (failed) save attempts — the
|
||||
-- user_role_profiles row itself was created successfully by
|
||||
-- get_or_create_user_role_profile_id() even though the subsequent profile
|
||||
-- table write then failed, so a matching row may already exist.
|
||||
UPDATE photographer_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'PHOTOGRAPHER' AND p.user_role_profile_id IS NULL;
|
||||
UPDATE tutor_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'TUTOR' AND p.user_role_profile_id IS NULL;
|
||||
UPDATE makeup_artist_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'MAKEUP_ARTIST' AND p.user_role_profile_id IS NULL;
|
||||
UPDATE developer_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'DEVELOPER' AND p.user_role_profile_id IS NULL;
|
||||
UPDATE video_editor_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'VIDEO_EDITOR' AND p.user_role_profile_id IS NULL;
|
||||
UPDATE graphic_designer_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'GRAPHIC_DESIGNER' AND p.user_role_profile_id IS NULL;
|
||||
UPDATE social_media_manager_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'SOCIAL_MEDIA_MANAGER' AND p.user_role_profile_id IS NULL;
|
||||
UPDATE fitness_trainer_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'FITNESS_TRAINER' AND p.user_role_profile_id IS NULL;
|
||||
UPDATE catering_service_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'CATERING_SERVICES' AND p.user_role_profile_id IS NULL;
|
||||
UPDATE ugc_content_creator_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'UGC_CONTENT_CREATOR' AND p.user_role_profile_id IS NULL;
|
||||
|
||||
-- For any rows still unlinked (profile table row exists but no matching
|
||||
-- user_role_profiles row was ever created), create one now so existing data
|
||||
-- isn't orphaned by the NOT NULL below.
|
||||
INSERT INTO user_role_profiles (user_id, role_key, status)
|
||||
SELECT user_id, 'PHOTOGRAPHER', 'DRAFT' FROM photographer_profiles WHERE user_role_profile_id IS NULL
|
||||
ON CONFLICT (user_id, role_key) DO NOTHING;
|
||||
UPDATE photographer_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'PHOTOGRAPHER' AND p.user_role_profile_id IS NULL;
|
||||
|
||||
INSERT INTO user_role_profiles (user_id, role_key, status)
|
||||
SELECT user_id, 'TUTOR', 'DRAFT' FROM tutor_profiles WHERE user_role_profile_id IS NULL
|
||||
ON CONFLICT (user_id, role_key) DO NOTHING;
|
||||
UPDATE tutor_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'TUTOR' AND p.user_role_profile_id IS NULL;
|
||||
|
||||
INSERT INTO user_role_profiles (user_id, role_key, status)
|
||||
SELECT user_id, 'MAKEUP_ARTIST', 'DRAFT' FROM makeup_artist_profiles WHERE user_role_profile_id IS NULL
|
||||
ON CONFLICT (user_id, role_key) DO NOTHING;
|
||||
UPDATE makeup_artist_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'MAKEUP_ARTIST' AND p.user_role_profile_id IS NULL;
|
||||
|
||||
INSERT INTO user_role_profiles (user_id, role_key, status)
|
||||
SELECT user_id, 'DEVELOPER', 'DRAFT' FROM developer_profiles WHERE user_role_profile_id IS NULL
|
||||
ON CONFLICT (user_id, role_key) DO NOTHING;
|
||||
UPDATE developer_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'DEVELOPER' AND p.user_role_profile_id IS NULL;
|
||||
|
||||
INSERT INTO user_role_profiles (user_id, role_key, status)
|
||||
SELECT user_id, 'VIDEO_EDITOR', 'DRAFT' FROM video_editor_profiles WHERE user_role_profile_id IS NULL
|
||||
ON CONFLICT (user_id, role_key) DO NOTHING;
|
||||
UPDATE video_editor_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'VIDEO_EDITOR' AND p.user_role_profile_id IS NULL;
|
||||
|
||||
INSERT INTO user_role_profiles (user_id, role_key, status)
|
||||
SELECT user_id, 'GRAPHIC_DESIGNER', 'DRAFT' FROM graphic_designer_profiles WHERE user_role_profile_id IS NULL
|
||||
ON CONFLICT (user_id, role_key) DO NOTHING;
|
||||
UPDATE graphic_designer_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'GRAPHIC_DESIGNER' AND p.user_role_profile_id IS NULL;
|
||||
|
||||
INSERT INTO user_role_profiles (user_id, role_key, status)
|
||||
SELECT user_id, 'SOCIAL_MEDIA_MANAGER', 'DRAFT' FROM social_media_manager_profiles WHERE user_role_profile_id IS NULL
|
||||
ON CONFLICT (user_id, role_key) DO NOTHING;
|
||||
UPDATE social_media_manager_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'SOCIAL_MEDIA_MANAGER' AND p.user_role_profile_id IS NULL;
|
||||
|
||||
INSERT INTO user_role_profiles (user_id, role_key, status)
|
||||
SELECT user_id, 'FITNESS_TRAINER', 'DRAFT' FROM fitness_trainer_profiles WHERE user_role_profile_id IS NULL
|
||||
ON CONFLICT (user_id, role_key) DO NOTHING;
|
||||
UPDATE fitness_trainer_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'FITNESS_TRAINER' AND p.user_role_profile_id IS NULL;
|
||||
|
||||
INSERT INTO user_role_profiles (user_id, role_key, status)
|
||||
SELECT user_id, 'CATERING_SERVICES', 'DRAFT' FROM catering_service_profiles WHERE user_role_profile_id IS NULL
|
||||
ON CONFLICT (user_id, role_key) DO NOTHING;
|
||||
UPDATE catering_service_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'CATERING_SERVICES' AND p.user_role_profile_id IS NULL;
|
||||
|
||||
INSERT INTO user_role_profiles (user_id, role_key, status)
|
||||
SELECT user_id, 'UGC_CONTENT_CREATOR', 'DRAFT' FROM ugc_content_creator_profiles WHERE user_role_profile_id IS NULL
|
||||
ON CONFLICT (user_id, role_key) DO NOTHING;
|
||||
UPDATE ugc_content_creator_profiles p SET user_role_profile_id = urp.id
|
||||
FROM user_role_profiles urp WHERE p.user_id = urp.user_id AND urp.role_key = 'UGC_CONTENT_CREATOR' AND p.user_role_profile_id IS NULL;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_photographer_profiles_urp ON photographer_profiles(user_role_profile_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_tutor_profiles_urp ON tutor_profiles(user_role_profile_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_makeup_artist_profiles_urp ON makeup_artist_profiles(user_role_profile_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_developer_profiles_urp ON developer_profiles(user_role_profile_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_video_editor_profiles_urp ON video_editor_profiles(user_role_profile_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_graphic_designer_profiles_urp ON graphic_designer_profiles(user_role_profile_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_social_media_manager_profiles_urp ON social_media_manager_profiles(user_role_profile_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_fitness_trainer_profiles_urp ON fitness_trainer_profiles(user_role_profile_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_catering_service_profiles_urp ON catering_service_profiles(user_role_profile_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_ugc_content_creator_profiles_urp ON ugc_content_creator_profiles(user_role_profile_id);
|
||||
Loading…
Add table
Reference in a new issue