nxtgauge-backend-rust/crates/db/migrations/20260415010003_add_user_role_profile_id.down.sql
Tracewebstudio Dev 03376b9567 feat: Add database redesign documentation and Phase 1-2 migrations
- Add schema_audit.md documenting current schema issues
- Add target_schema.md with complete target schema design
- Add old_to_new_mapping.md with table mapping
- Add migration_plan.md with phased migration strategy
- Add Phase 1 migrations (core infrastructure):
  - user_sessions table
  - users missing columns
  - departments updates
  - designations updates
  - employees updates
- Add Phase 2 migrations (profile domain - CRITICAL):
  - create user_role_profiles root table
  - backfill user_role_profiles from existing profiles
  - add user_role_profile_id to extension tables
  - remove forbidden external portfolio links
- Add user_role_profile Rust model
- Update photographer model to use user_role_profile_id
2026-04-12 23:21:11 +02:00

23 lines
1.5 KiB
SQL

-- Rollback: Remove user_role_profile_id columns
-- WARNING: This will fail if FK constraints exist
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;
DROP INDEX IF EXISTS idx_photographer_profiles_user_role;
DROP INDEX IF EXISTS idx_tutor_profiles_user_role;
DROP INDEX IF EXISTS idx_makeup_artist_profiles_user_role;
DROP INDEX IF EXISTS idx_developer_profiles_user_role;
DROP INDEX IF EXISTS idx_video_editor_profiles_user_role;
DROP INDEX IF EXISTS idx_graphic_designer_profiles_user_role;
DROP INDEX IF EXISTS idx_social_media_manager_profiles_user_role;
DROP INDEX IF EXISTS idx_fitness_trainer_profiles_user_role;
DROP INDEX IF EXISTS idx_catering_service_profiles_user_role;
DROP INDEX IF EXISTS idx_ugc_content_creator_profiles_user_role;