Files
TK-FB-Project/api.hyungi.net/db_archive/migrations/011_add_worker_status.sql
Hyungi Ahn b67362a733 feat: Introduce knex for database migrations
- Adds knex.js to manage database schema changes systematically.
- Creates an initial migration file based on `hyungi_schema_v2.sql` to represent the current database state.
- Adds npm scripts (`db:migrate`, `db:rollback`, etc.) for easy execution of migration tasks.
- Archives legacy SQL files and old migration scripts into the `db_archive/` directory to prevent confusion and clean up the project structure.
2025-12-19 09:43:09 +09:00

31 lines
1.0 KiB
SQL

-- 011_add_worker_status.sql
-- workers 테이블에 추가 정보 필드 추가
-- 작업자 상태 필드 수정 (기존 text에서 ENUM으로)
ALTER TABLE workers
MODIFY COLUMN status ENUM('active', 'inactive') DEFAULT 'active' COMMENT '작업자 상태 (active: 활성, inactive: 비활성)';
-- 작업자 추가 정보 필드들 추가
ALTER TABLE workers
ADD COLUMN phone_number VARCHAR(20) NULL COMMENT '전화번호';
ALTER TABLE workers
ADD COLUMN email VARCHAR(100) NULL COMMENT '이메일';
ALTER TABLE workers
ADD COLUMN hire_date DATE NULL COMMENT '입사일';
ALTER TABLE workers
ADD COLUMN department VARCHAR(100) NULL COMMENT '부서';
ALTER TABLE workers
ADD COLUMN notes TEXT NULL COMMENT '비고';
-- 기존 작업자들을 모두 활성 상태로 설정
UPDATE workers SET status = 'active' WHERE status IS NULL;
-- 인덱스 추가 (성능 최적화)
CREATE INDEX idx_workers_status ON workers(status);
CREATE INDEX idx_workers_job_type ON workers(job_type);
CREATE INDEX idx_workers_hire_date ON workers(hire_date);