feat(db): 新增 portfolio_snapshots 表与每日快照记录 Action
This commit is contained in:
+14
-1
@@ -1,4 +1,4 @@
|
||||
import { pgTable, uuid, varchar, timestamp, pgEnum, numeric, uniqueIndex } from "drizzle-orm/pg-core";
|
||||
import { pgTable, uuid, varchar, timestamp, pgEnum, numeric, uniqueIndex, date } from "drizzle-orm/pg-core";
|
||||
|
||||
export const users = pgTable("users", {
|
||||
id: uuid("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
||||
@@ -65,3 +65,16 @@ export const exchangeRates = pgTable("exchange_rates", {
|
||||
}, (table) => [
|
||||
uniqueIndex("currency_pair_idx").on(table.fromCurrency, table.toCurrency),
|
||||
]);
|
||||
|
||||
export const portfolioSnapshots = pgTable("portfolio_snapshots", {
|
||||
id: uuid("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
||||
date: date("date", { mode: "string" }).notNull().unique(),
|
||||
totalValueCny: numeric("total_value_cny", { precision: 36, scale: 18 }).notNull(),
|
||||
totalCostCny: numeric("total_cost_cny", { precision: 36, scale: 18 }).notNull(),
|
||||
createdAt: timestamp("created_at", { withTimezone: true, mode: "date" })
|
||||
.defaultNow()
|
||||
.notNull(),
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true, mode: "date" })
|
||||
.defaultNow()
|
||||
.notNull(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user