nxtgauge-backend-rust/crates/db/migrations/20260415000005_update_employees.up.sql

13 lines
722 B
MySQL
Raw Normal View History

-- 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);