Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/main/resources/db/migration/V010__project_activity_read.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
-- 프로젝트 멤버별 최근활동 읽음 상태를 활동 로그 단위로 저장한다.
-- 이전 확인 시각 방식이 일부 DB에 반영된 경우를 함께 정리한다.

ALTER TABLE project_member
DROP COLUMN IF EXISTS last_activity_read_at;

-- MySQL 8.0 호환: DROP 후 CREATE (CREATE IF NOT EXISTS는 MySQL 8.0.13+에서만 지원)
DROP INDEX IF EXISTS idx_activity_log_project_created_id ON activity_log;
CREATE INDEX idx_activity_log_project_created_id
ON activity_log (project_id, created_at, id);
-- MySQL 은 DROP COLUMN IF EXISTS / CREATE INDEX IF NOT EXISTS 같은 조건부 DDL 을
-- 지원하지 않으므로(MariaDB 전용 확장) 조건부 없이 작성한다.

CREATE TABLE project_activity_read (
id BIGINT NOT NULL AUTO_INCREMENT,
Expand All @@ -21,3 +14,6 @@ CREATE TABLE project_activity_read (
CONSTRAINT fk_project_activity_read_activity_log
FOREIGN KEY (activity_log_id) REFERENCES activity_log (id)
);

-- activity_log (project_id, created_at, id) 인덱스는 운영 DB에 이미 존재하며
-- FK(project_id -> project.id) 를 떠받치고 있어 제거할 수 없으므로 마이그레이션에 포함하지 않는다.
Comment on lines +17 to +19

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

rg -n -C 6 \
  'activity_log|project_id|created_at|CREATE[[:space:]]+INDEX|FOREIGN KEY' \
  --glob '*.sql' .

Repository: SLAT-TO/SLATE-TO-BE

Length of output: 11690


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf 'SQL migration files:\n'
git ls-files 'src/main/resources/db/migration/*.sql' | sort

printf '\nactivity_log references and DDL patterns:\n'
rg -n -C 8 \
  'CREATE\s+TABLE\s+(?i:activity_log)|activity_log|INDEX|KEY|\bFOREIGN\s+KEY\b|REFERENCES\s+\(?\s*id' \
  --glob '*.sql' src/main/resources/db/migration

printf '\nEntity/controller usage of activity_log indexes/created_at/project_id:\n'
rg -n -C 4 \
  'activityLog|ActivityLog|createdAt|created_at|project_id|projectId' \
  src/main/java || true

Repository: SLAT-TO/SLATE-TO-BE

Length of output: 50376


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf 'activity_log file candidates:\n'
fd -a 'activity_log|ActivityLog|notification' src/main/resources src/main/java | sed 's#^\./##' | head -200

printf '\nMigrations mentioning activity_log explicitly:\n'
for f in $(git ls-files 'src/main/resources/db/migration/*.sql'); do
  if grep -qi 'activity_log' "$f"; then
    echo "--- $f"
    cat -n "$f"
  fi
done

printf '\nRepository/projection files related to ActivityLog:\n'
fd -a 'ActivityLog|activity' src/main/java | sed 's#^\./##' | while read -r f; do
  if grep -qiE 'activity_log|ActivityLog|last_activity_at|lastActivityAt|findLatest|created_at|created' "$f"; then
    echo "--- $f"
    sed -n '1,220p' "$f"
  fi
done

Repository: SLAT-TO/SLATE-TO-BE

Length of output: 15866


activity_log의 최신 조회용 복합 인덱스를 마이그레이션에 포함하세요.

V004/V007activity_log를 삭제하거나 변경하지 않으며, V009V010(project_id, created_at, id) 인덱스 생성을 하지 않습니다. ActivityLogRepository.findRecentActivitiesByCursor()projectId, createdAt, id로 정렬/필터하므로, 운영 DB 의존성 없이 신규 DB에도 동일한 동등 인덱스를 생성하도록 변경하세요.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/resources/db/migration/V010__project_activity_read.sql` around lines
17 - 19, Update the V010 migration to create the equivalent composite index on
activity_log(project_id, created_at, id), rather than omitting it based on the
operational database assumption. Keep the index aligned with
ActivityLogRepository.findRecentActivitiesByCursor() filtering and ordering so
new databases receive the required index.

Loading