- 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
12 lines
722 B
SQL
12 lines
722 B
SQL
-- Phase 1.5: Update employees table with new fields
|
|
-- Migration: 20260415000005
|
|
|
|
ALTER TABLE employees ADD COLUMN IF NOT EXISTS joining_date DATE;
|
|
ALTER TABLE employees ADD COLUMN IF NOT EXISTS employment_status VARCHAR(50) DEFAULT 'ACTIVE';
|
|
ALTER TABLE employees ADD COLUMN IF NOT EXISTS manager_employee_id UUID REFERENCES employees(id) ON DELETE SET NULL;
|
|
ALTER TABLE employees ADD COLUMN IF NOT EXISTS updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW();
|
|
|
|
UPDATE employees SET updated_at = COALESCE(updated_at, created_at, NOW()) WHERE updated_at IS NULL;
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_employees_manager ON employees(manager_employee_id);
|
|
CREATE INDEX IF NOT EXISTS idx_employees_status ON employees(employment_status);
|