kt-event-marketing/tools/check_tables.py
sunmingLee b0d8a6d10e distribution-service API 명세서를 실제 구현에 맞게 수정
- ChannelType 열거형 값 수정 (URIDONGNETV, RINGOBIZ, GINITV 등)
- DistributionRequest 스키마 변경 (title, description, imageUrl 추가)
- DistributionResponse 스키마 변경 (success, successCount, failureCount 등)
- ChannelDistributionResult 스키마 단순화
- 모든 예제 코드 실제 구현에 맞게 업데이트
- IntelliJ 서비스 실행 프로파일 추가
- Distribution 서비스 엔티티, 매퍼, 리포지토리 추가

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 13:45:45 +09:00

121 lines
4.1 KiB
Python

#!/usr/bin/env python3
"""
PostgreSQL 테이블 확인 스크립트
distribution-service의 테이블 생성 여부를 확인합니다.
"""
import psycopg2
import sys
# DB 연결 정보
DB_CONFIG = {
'host': '4.217.133.59',
'port': 5432,
'database': 'distributiondb',
'user': 'eventuser',
'password': 'Hi5Jessica!'
}
def main():
try:
# DB 연결
print(f"Connecting to database: {DB_CONFIG['host']}:{DB_CONFIG['port']}/{DB_CONFIG['database']}")
conn = psycopg2.connect(**DB_CONFIG)
cursor = conn.cursor()
# 테이블 목록 조회
print("\n=== Tables in distributiondb ===")
cursor.execute("""
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public'
ORDER BY table_name
""")
tables = cursor.fetchall()
if not tables:
print("No tables found.")
else:
for table in tables:
print(f" - {table[0]}")
# distribution_status 테이블 구조 확인
if any('distribution_status' in table for table in tables):
print("\n=== distribution_status table structure ===")
cursor.execute("""
SELECT column_name, data_type, character_maximum_length, is_nullable
FROM information_schema.columns
WHERE table_name = 'distribution_status'
ORDER BY ordinal_position
""")
columns = cursor.fetchall()
for col in columns:
nullable = "NULL" if col[3] == 'YES' else "NOT NULL"
max_len = f"({col[2]})" if col[2] else ""
print(f" - {col[0]}: {col[1]}{max_len} {nullable}")
# channel_status 테이블 구조 확인
if any('channel_status' in table for table in tables):
print("\n=== channel_status table structure ===")
cursor.execute("""
SELECT column_name, data_type, character_maximum_length, is_nullable
FROM information_schema.columns
WHERE table_name = 'channel_status'
ORDER BY ordinal_position
""")
columns = cursor.fetchall()
for col in columns:
nullable = "NULL" if col[3] == 'YES' else "NOT NULL"
max_len = f"({col[2]})" if col[2] else ""
print(f" - {col[0]}: {col[1]}{max_len} {nullable}")
# 인덱스 확인
print("\n=== Indexes ===")
cursor.execute("""
SELECT tablename, indexname, indexdef
FROM pg_indexes
WHERE schemaname = 'public'
AND tablename IN ('distribution_status', 'channel_status')
ORDER BY tablename, indexname
""")
indexes = cursor.fetchall()
for idx in indexes:
print(f" - {idx[0]}.{idx[1]}")
print(f" {idx[2]}")
# 외래 키 확인
print("\n=== Foreign Keys ===")
cursor.execute("""
SELECT
tc.table_name,
kcu.column_name,
ccu.table_name AS foreign_table_name,
ccu.column_name AS foreign_column_name
FROM information_schema.table_constraints AS tc
JOIN information_schema.key_column_usage AS kcu
ON tc.constraint_name = kcu.constraint_name
AND tc.table_schema = kcu.table_schema
JOIN information_schema.constraint_column_usage AS ccu
ON ccu.constraint_name = tc.constraint_name
AND ccu.table_schema = tc.table_schema
WHERE tc.constraint_type = 'FOREIGN KEY'
AND tc.table_name IN ('distribution_status', 'channel_status')
""")
fks = cursor.fetchall()
for fk in fks:
print(f" - {fk[0]}.{fk[1]} -> {fk[2]}.{fk[3]}")
# 연결 종료
cursor.close()
conn.close()
print("\n✅ Database connection successful!")
return 0
except Exception as e:
print(f"\n❌ Error: {e}", file=sys.stderr)
return 1
if __name__ == "__main__":
sys.exit(main())