fix betterauth db serial issue

This commit is contained in:
Face 2025-05-22 14:37:19 +03:00
parent 6b6a1d170e
commit 9aa4ba157b
6 changed files with 32 additions and 32 deletions

View file

@ -20,21 +20,21 @@ export const user = pgTable("user", {
});
export const session = pgTable("session", {
id: text("id").primaryKey(),
id: serial("id").primaryKey(),
expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
token: text("token").notNull().unique(),
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
ipAddress: text("ip_address"),
userAgent: text("user_agent"),
userId: serial("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
userId: integer("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
});
export const account = pgTable("account", {
id: text("id").primaryKey(),
id: serial("id").primaryKey(),
accountId: text("account_id").notNull(),
providerId: text("provider_id").notNull(),
userId: serial("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
userId: integer("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
accessToken: text("access_token"),
refreshToken: text("refresh_token"),
idToken: text("id_token"),
@ -47,7 +47,7 @@ export const account = pgTable("account", {
});
export const verification = pgTable("verification", {
id: text("id").primaryKey(),
id: serial("id").primaryKey(),
identifier: text("identifier").notNull(),
value: text("value").notNull(),
expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
@ -59,7 +59,7 @@ export const coin = pgTable("coin", {
id: serial("id").primaryKey(),
name: varchar("name", { length: 255 }).notNull(),
symbol: varchar("symbol", { length: 10 }).notNull().unique(),
creatorId: serial("creator_id").references(() => user.id, { onDelete: "set null", }), // Coin can exist even if creator is deleted
creatorId: integer("creator_id").references(() => user.id, { onDelete: "set null", }), // Coin can exist even if creator is deleted
initialSupply: decimal("initial_supply", { precision: 28, scale: 8 }).notNull(),
circulatingSupply: decimal("circulating_supply", { precision: 28, scale: 8 }).notNull(),
currentPrice: decimal("current_price", { precision: 19, scale: 8 }).notNull(), // Price in base currency
@ -74,7 +74,7 @@ export const coin = pgTable("coin", {
});
export const userPortfolio = pgTable("user_portfolio", {
userId: serial("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
userId: integer("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
coinId: integer("coin_id").notNull().references(() => coin.id, { onDelete: "cascade" }),
quantity: decimal("quantity", { precision: 28, scale: 8 }).notNull(),
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
@ -88,7 +88,7 @@ export const userPortfolio = pgTable("user_portfolio", {
export const transaction = pgTable("transaction", {
id: serial("id").primaryKey(),
userId: serial("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
userId: integer("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
coinId: integer("coin_id").notNull().references(() => coin.id, { onDelete: "cascade" }),
type: transactionTypeEnum("type").notNull(),
quantity: decimal("quantity", { precision: 28, scale: 8 }).notNull(),