feat(db): 新增 asset_prices_history 表用于存储手动导入的历史标的价格

This commit is contained in:
2026-04-30 10:05:42 +08:00
parent 838bb0ef95
commit 108023ae67
5 changed files with 487 additions and 0 deletions
+14
View File
@@ -78,3 +78,17 @@ export const portfolioSnapshots = pgTable("portfolio_snapshots", {
.defaultNow()
.notNull(),
});
export const assetPricesHistory = pgTable("asset_prices_history", {
id: uuid("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
assetId: uuid("asset_id")
.notNull()
.references(() => assets.id),
price: numeric("price", { precision: 36, scale: 18 }).notNull(),
date: date("date", { mode: "string" }).notNull(),
createdAt: timestamp("created_at", { withTimezone: true, mode: "date" })
.defaultNow()
.notNull(),
}, (table) => [
uniqueIndex("asset_price_date_idx").on(table.assetId, table.date),
]);