TK-FB(공장관리+신고)와 M-Project(부적합관리)를 3개 독립 시스템으로 분리하기 위한 전체 코드 구조 작성. - SSO 인증 서비스 (bcrypt + pbkdf2 이중 해시 지원) - System 1: 공장관리 (TK-FB 기반, 신고 코드 제거) - System 2: 신고 (TK-FB에서 workIssue 코드 추출) - System 3: 부적합관리 (M-Project 기반) - Gateway 포털 (path-based 라우팅) - 통합 docker-compose.yml 및 배포 스크립트 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
47 lines
2.0 KiB
SQL
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)
|
|
);
|