summaryrefslogtreecommitdiff
path: root/db/schema/integration-log.ts
blob: d90a36ecafb917e37ed11cb6ca88737173d10401 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { pgTable, text, timestamp, varchar, serial, integer } from 'drizzle-orm/pg-core';
import { integrations } from './integration';

export const integrationLogTable = pgTable('integration_log', {
  id: serial("id").primaryKey(),
  integrationId: integer("integration_id").notNull().references(() => integrations.id),
  executionTime: timestamp('execution_time').notNull().defaultNow(),
  status: varchar('status', { length: 50 }).notNull(), // 'success', 'failed', 'timeout', 'pending'
  responseTime: integer('response_time'), // 응답시간 (ms)
  errorMessage: text('error_message'), // 에러 메시지
  httpStatusCode: integer('http_status_code'), // HTTP 상태 코드
  retryCount: integer('retry_count').default(0), // 재시도 횟수
  requestMethod: varchar('request_method', { length: 10 }), // GET, POST, PUT, DELETE
  requestUrl: text('request_url'), // 실제 요청 URL
  ipAddress: varchar('ip_address', { length: 45 }), // 요청 IP 주소
  userAgent: text('user_agent'), // User Agent
  sessionId: varchar('session_id', { length: 100 }), // 세션 ID
  correlationId: varchar('correlation_id', { length: 100 }), // 상관관계 ID
  createdAt: timestamp('created_at').notNull().defaultNow(),
});

// 타입 정의
export type IntegrationLog = typeof integrationLogTable.$inferSelect;
export type NewIntegrationLog = typeof integrationLogTable.$inferInsert;