Files
dbx-main/scripts/sql/performance_db_005_ad_spend.sql
T
king ef38140673 feat(performance): 광고비 탭(구글·메타·쿠팡 윙/로켓) + 탭 개편·설정 톱니
- 탭: [매출 실적](검정) · [광고비](주황) 큰 탭 + 맨 오른쪽 설정 톱니(Material Symbols settings)
- /performance/ads: 연·월·일 표(채널 × 날짜)·추이·비중·월/연 누적, 매출 대비 광고비 KPI
- 날짜 칸 직접 입력(PUT /api/ad-spend/{channel}/{day}), 쿠팡(로켓) 광고 보고서 업로드
  (CSV/엑셀, 1열 날짜·19열 청구금액(+부가가치세), 잘못된 줄 있으면 전부 거절)
- performance_db 마이그레이션 005 perf_ad_spend
- 설정 화면 쇼핑몰 순서 jsdom 기대값을 003 열 순서로 갱신(기존 실패)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 18:20:44 +09:00

37 lines
2.2 KiB
PL/PgSQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- =====================================================================
-- performance_db 마이그레이션 005 — 광고비(채널 × 날짜)
-- =====================================================================
-- 멱등(idempotent). 새 표 하나만 만든다(기존 표·데이터 그대로). 운영: /opt/www/main 에서 superuser 로 적용.
-- docker exec -i postgres-db psql -v ON_ERROR_STOP=1 -U postgres -d performance_db \
-- < scripts/sql/performance_db_005_ad_spend.sql
--
-- 왜(2026-10-13 사용자 요청): 실적 모듈 "광고비" 탭 — 구글·메타·쿠팡(윙)·쿠팡(로켓) 광고비를 연·월·일로.
-- 쿠팡(로켓)은 광고 보고서 파일 업로드(1열 날짜, 19열 청구금액(+부가가치세)), 나머지는 날짜 칸 직접 입력.
-- 채널 목록은 앱(app/modules/performance/ad_spend.py CHANNELS)이 정한다 — 채널을 늘려도 이 표는 그대로.
-- 되돌리기: DROP TABLE perf_ad_spend; (광고비 데이터만 사라짐 — 실행 전 백업)
-- =====================================================================
BEGIN;
CREATE TABLE IF NOT EXISTS perf_ad_spend (
channel_code TEXT NOT NULL,
spend_date DATE NOT NULL,
amount BIGINT NOT NULL,
source TEXT NOT NULL DEFAULT 'manual' CHECK (source IN ('manual', 'upload', 'api')),
updated_by TEXT NOT NULL DEFAULT '',
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
PRIMARY KEY (channel_code, spend_date)
);
COMMENT ON TABLE perf_ad_spend IS '광고비 — 채널(google·meta·coupang_wing·coupang_rocket) × 날짜 하나에 금액 하나(원)';
COMMENT ON COLUMN perf_ad_spend.source IS 'manual=화면 직접 입력, upload=파일 업로드, api=광고 API 수집';
CREATE INDEX IF NOT EXISTS idx_perf_ad_spend_date ON perf_ad_spend (spend_date);
DROP TRIGGER IF EXISTS trg_perf_ad_spend_updated ON perf_ad_spend;
CREATE TRIGGER trg_perf_ad_spend_updated
BEFORE UPDATE ON perf_ad_spend
FOR EACH ROW EXECUTE FUNCTION perf_set_updated_at();
GRANT SELECT, INSERT, UPDATE, DELETE ON perf_ad_spend TO performance_app;
COMMIT;
SELECT 'performance_db 005 ad spend ready' AS status;