iboard/prisma/migrations/20260807104432_add_oil_price_history/migration.sql
2026-08-07 14:36:57 +08:00

18 lines
788 B
SQL
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 浙江省油价历史表
-- - date: 调价日次日 (即数据实际抓取日, 便于按时间排序)
-- - province + fuel: 浙江 / 92/95/0
-- - unique (date, province, fuel): 防 cron 重复入库
-- - DOUBLE 容纳 999.999 元/升
CREATE TABLE OilPriceHistory (
id INT NOT NULL AUTO_INCREMENT,
date DATETIME(3) NOT NULL,
province VARCHAR(191) NOT NULL,
fuel VARCHAR(8) NOT NULL,
price DOUBLE NOT NULL,
source VARCHAR(191) NOT NULL DEFAULT 'apizero',
createdAt DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
PRIMARY KEY (id),
UNIQUE INDEX OilPriceHistory_date_province_fuel_key(date, province, fuel),
INDEX OilPriceHistory_province_fuel_date_idx(province, fuel, date)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;