accounts table and many other fixes

This commit is contained in:
2025-01-19 23:49:48 -05:00
parent 26ae83faac
commit e0688a1406
22 changed files with 208 additions and 43 deletions

View File

@@ -1,4 +1,4 @@
import { pgTable, integer, varchar, text, numeric, timestamp, unique, check, bigserial, date, boolean, uuid, bigint, real, doublePrecision, primaryKey } from "drizzle-orm/pg-core"
import { pgTable, integer, varchar, text, numeric, timestamp, unique, check, bigserial, date, boolean, uuid, bigint, real, doublePrecision, primaryKey, pgView } from "drizzle-orm/pg-core"
import { sql } from "drizzle-orm"
export const products = pgTable("products", {
@@ -21,7 +21,7 @@ export const users = pgTable("users", {
.$defaultFn(() => crypto.randomUUID()),
username: varchar({ length: 50 }).notNull(),
email: varchar({ length: 255 }).notNull(),
emailVerifiedOn: timestamp("emailVerifiedOn", { mode: "date" }),
emailVerifiedOn: timestamp("email_verified_on", { mode: "date" }),
password_hash: varchar("password_hash", { length: 255 }).notNull(),
first_name: varchar("first_name", { length: 50 }),
last_name: varchar("last_name", { length: 50 }),
@@ -425,10 +425,11 @@ export const authenticator = pgTable("authenticator", {
});
export const accounts = pgTable("accounts", {
userId: text().notNull(),
uuid: uuid().defaultRandom(),
userId: text("user_id").notNull(),
type: text().notNull(),
provider: text().notNull(),
providerAccountId: text().notNull(),
providerAccountId: text("provider_account_id").notNull(),
refreshToken: text("refresh_token"),
accessToken: text("access_token"),
expiresAt: integer("expires_at"),
@@ -441,3 +442,21 @@ export const accounts = pgTable("accounts", {
accountProviderProviderAccountIdPk: primaryKey({ columns: [table.provider, table.providerAccountId], name: "account_provider_providerAccountId_pk"}),
}
});
export const vw_accounts = pgView("vw_accounts", {
uuid: uuid().defaultRandom(),
userId: text("user_id").notNull(),
type: text().notNull(),
provider: text().notNull(),
providerAccountId: text("provider_account_id").notNull(),
refreshToken: text("refresh_token"),
accessToken: text("access_token"),
expiresAt: integer("expires_at"),
tokenType: text("token_type"),
scope: text(),
idToken: text("id_token"),
sessionState: text("session_state"),
first_name: text("first_name"),
last_name: text("last_name"),
},).existing();