refactor(db): Replace SELECT * with explicit columns in models
Replaced `SELECT *` statements across multiple data models with explicit column lists to improve query performance, reduce data transfer, and increase code clarity. This is part of the Phase 2 refactoring plan. - Refactored queries in the following models: - projectModel - toolsModel - attendanceModel - dailyIssueReportModel - issueTypeModel - workReportModel - userModel - dailyWorkReportModel fix(api): Add missing volume mounts to docker-compose Modified docker-compose.yml to mount the `config`, `middlewares`, `utils`, and `services` directories into the API container. This fixes a `MODULE_NOT_FOUND` error that caused the container to crash on startup. feat(db): Add migration for missing project columns Created a new database migration to add `is_active`, `project_status`, and `completed_date` columns to the `projects` table, resolving an inconsistency between the model code and the schema. docs: Add deployment notes Added a new markdown file to document the testing (macOS, Docker Desktop) and production (Synology NAS, Container Manager) environments.
This commit is contained in:
@@ -7,7 +7,7 @@ const { getDb } = require('../dbPool');
|
||||
const getAllWorkTypes = async (callback) => {
|
||||
try {
|
||||
const db = await getDb();
|
||||
const [rows] = await db.query('SELECT * FROM work_types ORDER BY name ASC');
|
||||
const [rows] = await db.query('SELECT id, name, description, category, created_at, updated_at FROM work_types ORDER BY name ASC');
|
||||
callback(null, rows);
|
||||
} catch (err) {
|
||||
console.error('작업 유형 조회 오류:', err);
|
||||
@@ -18,7 +18,7 @@ const getAllWorkTypes = async (callback) => {
|
||||
const getAllWorkStatusTypes = async (callback) => {
|
||||
try {
|
||||
const db = await getDb();
|
||||
const [rows] = await db.query('SELECT * FROM work_status_types ORDER BY id ASC');
|
||||
const [rows] = await db.query('SELECT id, name, description, is_error, created_at FROM work_status_types ORDER BY id ASC');
|
||||
callback(null, rows);
|
||||
} catch (err) {
|
||||
console.error('업무 상태 유형 조회 오류:', err);
|
||||
@@ -29,7 +29,7 @@ const getAllWorkStatusTypes = async (callback) => {
|
||||
const getAllErrorTypes = async (callback) => {
|
||||
try {
|
||||
const db = await getDb();
|
||||
const [rows] = await db.query('SELECT * FROM error_types ORDER BY name ASC');
|
||||
const [rows] = await db.query('SELECT id, name, description, severity, solution_guide, created_at, updated_at FROM error_types ORDER BY name ASC');
|
||||
callback(null, rows);
|
||||
} catch (err) {
|
||||
console.error('에러 유형 조회 오류:', err);
|
||||
@@ -689,7 +689,7 @@ const removeByDateAndWorker = async (date, worker_id, deletedBy, callback) => {
|
||||
|
||||
// 삭제 전 정보 저장 (감사 로그용)
|
||||
const [reportInfos] = await conn.query(
|
||||
'SELECT * FROM daily_work_reports WHERE report_date = ? AND worker_id = ?',
|
||||
'SELECT id, report_date, worker_id, project_id, work_type_id, work_status_id, error_type_id, work_hours, created_at, updated_at, created_by, updated_by FROM daily_work_reports WHERE report_date = ? AND worker_id = ?',
|
||||
[date, worker_id]
|
||||
);
|
||||
|
||||
@@ -948,7 +948,7 @@ const removeReportById = async (reportId, deletedByUserId) => {
|
||||
await conn.beginTransaction();
|
||||
|
||||
// 감사 로그를 위해 삭제 전 정보 조회
|
||||
const [reportInfo] = await conn.query('SELECT * FROM daily_work_reports WHERE id = ?', [reportId]);
|
||||
const [reportInfo] = await conn.query('SELECT id, report_date, worker_id, project_id, work_type_id, work_status_id, error_type_id, work_hours, created_at, updated_at, created_by, updated_by FROM daily_work_reports WHERE id = ?', [reportId]);
|
||||
|
||||
// 실제 삭제 작업
|
||||
const [result] = await conn.query('DELETE FROM daily_work_reports WHERE id = ?', [reportId]);
|
||||
|
||||
Reference in New Issue
Block a user