Files
TK-FB-Project/deploy/tkfb-package/api.hyungi.net/db/migrations/20260205004000_create_notifications.sql
Hyungi Ahn 2b1c7bfb88 feat: 다수 기능 개선 - 순찰, 출근, 작업분석, 모바일 UI 등
- 순찰/점검 기능 개선 (zone-detail 페이지 추가)
- 출근/근태 시스템 개선 (연차 조회, 근무현황)
- 작업분석 대분류 그룹화 및 마이그레이션 스크립트
- 모바일 네비게이션 UI 추가
- NAS 배포 도구 및 문서 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 14:41:01 +09:00

47 lines
2.0 KiB
SQL

-- 알림 시스템 테이블 생성
-- 실행: docker exec -i tkfb_db mysql -u hyungi -p'your_password' hyungi < db/migrations/20260205004000_create_notifications.sql
-- ============================================
-- STEP 1: notifications 테이블 생성
-- ============================================
CREATE TABLE IF NOT EXISTS notifications (
notification_id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NULL COMMENT '특정 사용자에게만 표시 (NULL이면 전체)',
type ENUM('repair', 'safety', 'system', 'equipment', 'maintenance') NOT NULL DEFAULT 'system',
title VARCHAR(200) NOT NULL,
message TEXT,
link_url VARCHAR(500) COMMENT '클릭시 이동할 URL',
reference_type VARCHAR(50) COMMENT '연관 테이블 (equipment_repair_requests 등)',
reference_id INT COMMENT '연관 레코드 ID',
is_read BOOLEAN DEFAULT FALSE,
read_at DATETIME NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
created_by INT NULL,
INDEX idx_notifications_user (user_id),
INDEX idx_notifications_type (type),
INDEX idx_notifications_is_read (is_read),
INDEX idx_notifications_created (created_at DESC)
);
-- 수리 요청 테이블 수정 (알림 연동을 위해)
-- equipment_repair_requests 테이블이 없으면 생성
CREATE TABLE IF NOT EXISTS equipment_repair_requests (
request_id INT AUTO_INCREMENT PRIMARY KEY,
equipment_id INT UNSIGNED NOT NULL,
repair_type VARCHAR(100) NOT NULL,
description TEXT,
urgency ENUM('low', 'normal', 'high', 'urgent') DEFAULT 'normal',
status ENUM('pending', 'in_progress', 'completed', 'cancelled') DEFAULT 'pending',
requested_by INT,
assigned_to INT NULL,
completed_at DATETIME NULL,
notes TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (equipment_id) REFERENCES equipments(equipment_id) ON DELETE CASCADE,
INDEX idx_err_equipment (equipment_id),
INDEX idx_err_status (status),
INDEX idx_err_created (created_at DESC)
);