feat: KRW 가격 지원 및 GPU/G8/VPU 인스턴스 추가

## KRW 가격 기능
- pricing 테이블에 hourly_price_krw, monthly_price_krw 컬럼 추가
- 부가세 10% + 영업이익 10% + 환율 적용 (기본 1450원)
- 시간당: 1원 단위 반올림 (최소 1원)
- 월간: 100원 단위 반올림 (최소 100원)
- 환율/부가세/영업이익률 환경변수로 분리 (배포 없이 변경 가능)

## GPU/G8/VPU 인스턴스 지원
- gpu_instances, gpu_pricing 테이블 추가
- g8_instances, g8_pricing 테이블 추가
- vpu_instances, vpu_pricing 테이블 추가
- Linode/Vultr 커넥터에 GPU 동기화 로직 추가

## 환경변수 추가
- KRW_EXCHANGE_RATE: 환율 (기본 1450)
- KRW_VAT_RATE: 부가세율 (기본 1.1)
- KRW_MARKUP_RATE: 영업이익률 (기본 1.1)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
kappa
2026-01-22 18:57:51 +09:00
parent b1cb844c05
commit a2133ae5c9
20 changed files with 3517 additions and 690 deletions

View File

@@ -87,6 +87,8 @@ CREATE TABLE IF NOT EXISTS pricing (
region_id INTEGER NOT NULL,
hourly_price REAL NOT NULL,
monthly_price REAL NOT NULL,
hourly_price_krw REAL,
monthly_price_krw REAL,
currency TEXT NOT NULL DEFAULT 'USD',
available INTEGER NOT NULL DEFAULT 1, -- boolean: 1=true, 0=false
created_at TEXT NOT NULL DEFAULT (datetime('now')),
@@ -176,6 +178,64 @@ BEGIN
VALUES (NEW.id, NEW.hourly_price, NEW.monthly_price, datetime('now'));
END;
-- ============================================================
-- Table: gpu_instances
-- Description: GPU-specific instance types for specialized workloads
-- ============================================================
CREATE TABLE IF NOT EXISTS gpu_instances (
id INTEGER PRIMARY KEY AUTOINCREMENT,
provider_id INTEGER NOT NULL,
instance_id TEXT NOT NULL, -- provider's instance identifier
instance_name TEXT NOT NULL, -- display name
vcpu INTEGER NOT NULL,
memory_mb INTEGER NOT NULL,
storage_gb INTEGER NOT NULL,
transfer_tb REAL, -- data transfer limit
network_speed_gbps REAL,
gpu_count INTEGER NOT NULL CHECK (gpu_count > 0),
gpu_type TEXT NOT NULL, -- e.g., "NVIDIA A100", "NVIDIA RTX6000"
gpu_memory_gb INTEGER, -- GPU memory per GPU in GB
metadata TEXT, -- JSON for additional provider-specific data
created_at TEXT NOT NULL DEFAULT (datetime('now')),
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
FOREIGN KEY (provider_id) REFERENCES providers(id) ON DELETE CASCADE,
UNIQUE(provider_id, instance_id)
);
-- Indexes for GPU instance queries
CREATE INDEX IF NOT EXISTS idx_gpu_instances_provider_id ON gpu_instances(provider_id);
CREATE INDEX IF NOT EXISTS idx_gpu_instances_gpu_type ON gpu_instances(gpu_type);
CREATE INDEX IF NOT EXISTS idx_gpu_instances_gpu_count ON gpu_instances(gpu_count);
CREATE INDEX IF NOT EXISTS idx_gpu_instances_provider_type ON gpu_instances(provider_id, gpu_type);
-- ============================================================
-- Table: gpu_pricing
-- Description: Region-specific pricing for GPU instance types
-- ============================================================
CREATE TABLE IF NOT EXISTS gpu_pricing (
id INTEGER PRIMARY KEY AUTOINCREMENT,
gpu_instance_id INTEGER NOT NULL,
region_id INTEGER NOT NULL,
hourly_price REAL NOT NULL,
monthly_price REAL NOT NULL,
hourly_price_krw REAL,
monthly_price_krw REAL,
currency TEXT NOT NULL DEFAULT 'USD',
available INTEGER NOT NULL DEFAULT 1, -- boolean: 1=true, 0=false
created_at TEXT NOT NULL DEFAULT (datetime('now')),
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
FOREIGN KEY (gpu_instance_id) REFERENCES gpu_instances(id) ON DELETE CASCADE,
FOREIGN KEY (region_id) REFERENCES regions(id) ON DELETE CASCADE,
UNIQUE(gpu_instance_id, region_id)
);
-- Indexes for GPU pricing queries
CREATE INDEX IF NOT EXISTS idx_gpu_pricing_instance_id ON gpu_pricing(gpu_instance_id);
CREATE INDEX IF NOT EXISTS idx_gpu_pricing_region_id ON gpu_pricing(region_id);
CREATE INDEX IF NOT EXISTS idx_gpu_pricing_hourly_price ON gpu_pricing(hourly_price);
CREATE INDEX IF NOT EXISTS idx_gpu_pricing_monthly_price ON gpu_pricing(monthly_price);
CREATE INDEX IF NOT EXISTS idx_gpu_pricing_available ON gpu_pricing(available);
-- ============================================================
-- Composite Indexes: Query Performance Optimization
-- Description: Multi-column indexes to optimize common query patterns
@@ -198,3 +258,161 @@ ON pricing(instance_type_id, region_id, hourly_price);
-- Used in: Region filtering in main instance query
CREATE INDEX IF NOT EXISTS idx_regions_provider_code
ON regions(provider_id, region_code);
-- ============================================================
-- Triggers: GPU table auto-update timestamps
-- ============================================================
CREATE TRIGGER IF NOT EXISTS update_gpu_instances_updated_at
AFTER UPDATE ON gpu_instances
FOR EACH ROW
BEGIN
UPDATE gpu_instances SET updated_at = datetime('now') WHERE id = NEW.id;
END;
CREATE TRIGGER IF NOT EXISTS update_gpu_pricing_updated_at
AFTER UPDATE ON gpu_pricing
FOR EACH ROW
BEGIN
UPDATE gpu_pricing SET updated_at = datetime('now') WHERE id = NEW.id;
END;
-- ============================================================
-- Table: g8_instances
-- Description: G8 generation Dedicated instances
-- ============================================================
CREATE TABLE IF NOT EXISTS g8_instances (
id INTEGER PRIMARY KEY AUTOINCREMENT,
provider_id INTEGER NOT NULL,
instance_id TEXT NOT NULL, -- provider's instance identifier
instance_name TEXT NOT NULL, -- display name
vcpu INTEGER NOT NULL,
memory_mb INTEGER NOT NULL,
storage_gb INTEGER NOT NULL,
transfer_tb REAL, -- data transfer limit
network_speed_gbps REAL,
metadata TEXT, -- JSON for additional provider-specific data
created_at TEXT NOT NULL DEFAULT (datetime('now')),
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
FOREIGN KEY (provider_id) REFERENCES providers(id) ON DELETE CASCADE,
UNIQUE(provider_id, instance_id)
);
-- Indexes for G8 instance queries
CREATE INDEX IF NOT EXISTS idx_g8_instances_provider_id ON g8_instances(provider_id);
CREATE INDEX IF NOT EXISTS idx_g8_instances_instance_id ON g8_instances(instance_id);
-- ============================================================
-- Table: g8_pricing
-- Description: Region-specific pricing for G8 instance types
-- ============================================================
CREATE TABLE IF NOT EXISTS g8_pricing (
id INTEGER PRIMARY KEY AUTOINCREMENT,
g8_instance_id INTEGER NOT NULL,
region_id INTEGER NOT NULL,
hourly_price REAL NOT NULL,
monthly_price REAL NOT NULL,
hourly_price_krw REAL,
monthly_price_krw REAL,
currency TEXT NOT NULL DEFAULT 'USD',
available INTEGER NOT NULL DEFAULT 1, -- boolean: 1=true, 0=false
created_at TEXT NOT NULL DEFAULT (datetime('now')),
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
FOREIGN KEY (g8_instance_id) REFERENCES g8_instances(id) ON DELETE CASCADE,
FOREIGN KEY (region_id) REFERENCES regions(id) ON DELETE CASCADE,
UNIQUE(g8_instance_id, region_id)
);
-- Indexes for G8 pricing queries
CREATE INDEX IF NOT EXISTS idx_g8_pricing_instance_id ON g8_pricing(g8_instance_id);
CREATE INDEX IF NOT EXISTS idx_g8_pricing_region_id ON g8_pricing(region_id);
CREATE INDEX IF NOT EXISTS idx_g8_pricing_hourly_price ON g8_pricing(hourly_price);
CREATE INDEX IF NOT EXISTS idx_g8_pricing_monthly_price ON g8_pricing(monthly_price);
CREATE INDEX IF NOT EXISTS idx_g8_pricing_available ON g8_pricing(available);
-- ============================================================
-- Table: vpu_instances
-- Description: VPU (NETINT Quadra) accelerated instances
-- ============================================================
CREATE TABLE IF NOT EXISTS vpu_instances (
id INTEGER PRIMARY KEY AUTOINCREMENT,
provider_id INTEGER NOT NULL,
instance_id TEXT NOT NULL, -- provider's instance identifier
instance_name TEXT NOT NULL, -- display name
vcpu INTEGER NOT NULL,
memory_mb INTEGER NOT NULL,
storage_gb INTEGER NOT NULL,
transfer_tb REAL, -- data transfer limit
network_speed_gbps REAL,
vpu_type TEXT NOT NULL, -- e.g., "NETINT Quadra"
metadata TEXT, -- JSON for additional provider-specific data
created_at TEXT NOT NULL DEFAULT (datetime('now')),
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
FOREIGN KEY (provider_id) REFERENCES providers(id) ON DELETE CASCADE,
UNIQUE(provider_id, instance_id)
);
-- Indexes for VPU instance queries
CREATE INDEX IF NOT EXISTS idx_vpu_instances_provider_id ON vpu_instances(provider_id);
CREATE INDEX IF NOT EXISTS idx_vpu_instances_instance_id ON vpu_instances(instance_id);
CREATE INDEX IF NOT EXISTS idx_vpu_instances_vpu_type ON vpu_instances(vpu_type);
-- ============================================================
-- Table: vpu_pricing
-- Description: Region-specific pricing for VPU instance types
-- ============================================================
CREATE TABLE IF NOT EXISTS vpu_pricing (
id INTEGER PRIMARY KEY AUTOINCREMENT,
vpu_instance_id INTEGER NOT NULL,
region_id INTEGER NOT NULL,
hourly_price REAL NOT NULL,
monthly_price REAL NOT NULL,
hourly_price_krw REAL,
monthly_price_krw REAL,
currency TEXT NOT NULL DEFAULT 'USD',
available INTEGER NOT NULL DEFAULT 1, -- boolean: 1=true, 0=false
created_at TEXT NOT NULL DEFAULT (datetime('now')),
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
FOREIGN KEY (vpu_instance_id) REFERENCES vpu_instances(id) ON DELETE CASCADE,
FOREIGN KEY (region_id) REFERENCES regions(id) ON DELETE CASCADE,
UNIQUE(vpu_instance_id, region_id)
);
-- Indexes for VPU pricing queries
CREATE INDEX IF NOT EXISTS idx_vpu_pricing_instance_id ON vpu_pricing(vpu_instance_id);
CREATE INDEX IF NOT EXISTS idx_vpu_pricing_region_id ON vpu_pricing(region_id);
CREATE INDEX IF NOT EXISTS idx_vpu_pricing_hourly_price ON vpu_pricing(hourly_price);
CREATE INDEX IF NOT EXISTS idx_vpu_pricing_monthly_price ON vpu_pricing(monthly_price);
CREATE INDEX IF NOT EXISTS idx_vpu_pricing_available ON vpu_pricing(available);
-- ============================================================
-- Triggers: G8 and VPU table auto-update timestamps
-- ============================================================
CREATE TRIGGER IF NOT EXISTS update_g8_instances_updated_at
AFTER UPDATE ON g8_instances
FOR EACH ROW
BEGIN
UPDATE g8_instances SET updated_at = datetime('now') WHERE id = NEW.id;
END;
CREATE TRIGGER IF NOT EXISTS update_g8_pricing_updated_at
AFTER UPDATE ON g8_pricing
FOR EACH ROW
BEGIN
UPDATE g8_pricing SET updated_at = datetime('now') WHERE id = NEW.id;
END;
CREATE TRIGGER IF NOT EXISTS update_vpu_instances_updated_at
AFTER UPDATE ON vpu_instances
FOR EACH ROW
BEGIN
UPDATE vpu_instances SET updated_at = datetime('now') WHERE id = NEW.id;
END;
CREATE TRIGGER IF NOT EXISTS update_vpu_pricing_updated_at
AFTER UPDATE ON vpu_pricing
FOR EACH ROW
BEGIN
UPDATE vpu_pricing SET updated_at = datetime('now') WHERE id = NEW.id;
END;