Skip to content

서비스별 데이터베이스 환경 변수 적용#58

Open
eajnoeyeel wants to merge 1 commit into
mainfrom
fix/database-configuration
Open

서비스별 데이터베이스 환경 변수 적용#58
eajnoeyeel wants to merge 1 commit into
mainfrom
fix/database-configuration

Conversation

@eajnoeyeel

@eajnoeyeel eajnoeyeel commented Oct 31, 2025

Copy link
Copy Markdown
Contributor

📌 변경 내용 요약

  • 기존에 공통으로 사용하던 환경 변수(POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD)를
    각 서비스 전용 환경 변수(DB_GAME_NAME, DB_GAME_USER, DB_GAME_PASSWORD)로 분리했습니다.
  • 이제 Game 서비스는 전용 데이터베이스(game_db) 에만 연결되며,
    모든 서비스가 같은 DB(mydatabase)를 공유하던 문제를 해결했습니다.
  • 이 변경은 마이크로서비스 간 데이터베이스 격리 개선 작업의 일부입니다.

🔗 관련 이슈

💡 주요 변경 사항

  • config/settings.py에서 서비스별 DB 환경 변수로 변경
    • POSTGRES_DBDB_GAME_NAME
    • POSTGRES_USERDB_GAME_USER
    • POSTGRES_PASSWORDDB_GAME_PASSWORD
  • 서비스 간 데이터베이스 충돌 방지
  • 마이크로서비스 아키텍처 내 데이터 독립성 확보

🧩 리뷰어 참고 사항

  • .env 파일의 값이 변경되었으므로, 로컬 환경에서 테스트 시 .env를 새로 적용해야 합니다.
  • 기존 데이터(mydatabase)는 더 이상 사용하지 않으며, game_db 데이터베이스가 생성됩니다.
  • 데이터베이스 및 사용자 생성 필요:
    docker exec database_game psql -U myuser -d postgres -c "CREATE DATABASE game_db OWNER myuser;"
    docker exec database_game psql -U myuser -d postgres -c "CREATE USER game_user WITH PASSWORD 'game_pass';"
    docker exec database_game psql -U myuser -d game_db -c "GRANT ALL ON SCHEMA public TO game_user;"
  • 관련 마이그레이션 명령어:
    docker exec game python manage.py migrate

✅ 테스트 방법

  1. Game 서비스가 올바른 데이터베이스에 연결되는지 확인:

    docker exec game python manage.py shell -c "from django.conf import settings; print(settings.DATABASES['default']['NAME'])"
    # 예상 출력: game_db
  2. 게임 관련 API 테스트 (예시):

    # 토너먼트 목록 조회 등
    curl http://localhost/api/game/tournaments/

- Changed from generic POSTGRES_DB/USER/PASSWORD to DB_GAME_NAME/USER/PASSWORD
- Ensures game service connects to its own database (game_db) instead of shared mydatabase
- Fixes issue where all services were connecting to the same database
- Part of microservices database isolation improvements
Copilot AI review requested due to automatic review settings October 31, 2025 08:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR renames PostgreSQL database environment variable names to use a more specific naming convention. The environment variables for database name, user, and password are changed from generic POSTGRES_* prefixes to DB_GAME_* prefixes to better reflect the purpose of this specific database.

  • Changed database name, user, and password environment variable names from POSTGRES_DB/USER/PASSWORD to DB_GAME_NAME/USER/PASSWORD

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@eajnoeyeel eajnoeyeel changed the title 🐛 fix: 서비스별 데이터베이스 환경 변수 적용 서비스별 데이터베이스 환경 변수 적용 Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] 공통 데이터베이스에 연결되는 문제

2 participants