feat(db): 新增 asset_prices_history 表用于存储手动导入的历史标的价格
This commit is contained in:
@@ -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),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user