12 lines
483 B
SQL
12 lines
483 B
SQL
-- 거래 이력 테이블에 새로운 컬럼 추가
|
|
ALTER TABLE trade_history
|
|
ADD COLUMN IF NOT EXISTS total_amount NUMERIC(15, 2),
|
|
ADD COLUMN IF NOT EXISTS entry_reason TEXT,
|
|
ADD COLUMN IF NOT EXISTS exit_reason TEXT,
|
|
ADD COLUMN IF NOT EXISTS signals JSONB;
|
|
|
|
-- 기존 데이터에 대한 total_amount 계산
|
|
UPDATE trade_history
|
|
SET total_amount = executed_price * executed_quantity
|
|
WHERE total_amount IS NULL AND executed_price IS NOT NULL AND executed_quantity IS NOT NULL;
|