feat(api): 构建汇率流水表与定时抓取 API,实现 USD/HKD 对人民币的双点数据入库

This commit is contained in:
2026-05-02 00:07:02 +08:00
parent 9ff48f37d1
commit b7077ec9d3
3 changed files with 171 additions and 0 deletions
+12
View File
@@ -92,3 +92,15 @@ export const assetPricesHistory = pgTable("asset_prices_history", {
}, (table) => [
uniqueIndex("asset_price_date_idx").on(table.assetId, table.date),
]);
export const exchangeRatesHistory = pgTable("exchange_rates_history", {
id: uuid("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
fromCurrency: varchar("from_currency", { length: 10 }).notNull(),
toCurrency: varchar("to_currency", { length: 10 }).notNull(),
rate: numeric("rate", { precision: 20, scale: 8 }).notNull(),
fetchTime: timestamp("fetch_time", { withTimezone: true, mode: "date" })
.notNull(),
createdAt: timestamp("created_at", { withTimezone: true, mode: "date" })
.defaultNow()
.notNull(),
});