fix betterauth db serial issue
This commit is contained in:
parent
6b6a1d170e
commit
9aa4ba157b
6 changed files with 32 additions and 32 deletions
|
|
@ -1,10 +1,7 @@
|
|||
import { betterAuth } from "better-auth";
|
||||
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
||||
import { apiKey } from "better-auth/plugins";
|
||||
import { env } from '$env/dynamic/private';
|
||||
|
||||
import { db } from "./server/db";
|
||||
import { eq } from "drizzle-orm";
|
||||
|
||||
if (!env.GOOGLE_CLIENT_ID) throw new Error('GOOGLE_CLIENT_ID is not set');
|
||||
if (!env.GOOGLE_CLIENT_SECRET) throw new Error('GOOGLE_CLIENT_SECRET is not set');
|
||||
|
|
@ -53,4 +50,7 @@ export const auth = betterAuth({
|
|||
},
|
||||
deleteUser: { enabled: true }
|
||||
},
|
||||
advanced: {
|
||||
generateId: false,
|
||||
}
|
||||
});
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
import { type VariantProps, tv } from "tailwind-variants";
|
||||
|
||||
export const buttonVariants = tv({
|
||||
base: "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
||||
base: "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0 cursor-pointer",
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
Reference in a new issue