adding clerk authentication

This commit is contained in:
2025-01-22 23:11:25 -05:00
parent 1a59ac8373
commit 9931980114
8 changed files with 370 additions and 52 deletions

View File

@@ -16,9 +16,8 @@ export const products = pgTable("products", {
export const users = pgTable("users", {
id: text("id")
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
id: uuid("id").primaryKey().defaultRandom(),
name: varchar("name").notNull(),
username: varchar({ length: 50 }).notNull(),
email: varchar({ length: 255 }).notNull(),
emailVerifiedOn: timestamp("email_verified_on", { mode: "date" }),
@@ -27,6 +26,7 @@ export const users = pgTable("users", {
last_name: varchar("last_name", { length: 50 }),
full_name: varchar("full_name", { length: 50 }),
profilePicture: varchar("profile_picture", { length: 255 }),
image: text("image"),
dateOfBirth: date("date_of_birth"),
phoneNumber: varchar("phone_number", { length: 20 }),
createdAt: timestamp("created_at", { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`),
@@ -92,10 +92,11 @@ export const brands = pgTable("brands", {
});
export const sessions = pgTable("sessions", {
sessionToken: text().primaryKey().notNull(),
userId: text().notNull(),
expires: timestamp({ mode: 'string' }).notNull(),
});
id: uuid("id").primaryKey().defaultRandom(),
sessionToken: varchar("session_token").notNull(),
userId: uuid("user_id").notNull(),
expires: timestamp("expires").notNull(),
});
export const manufacturer = pgTable("manufacturer", {
id: integer().primaryKey().generatedAlwaysAsIdentity({ name: "manufacturer_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }),
@@ -399,13 +400,9 @@ export const balResellers = pgTable("bal_resellers", {
});
export const verificationTokens = pgTable("verificationTokens", {
identifier: text().notNull(),
token: text().notNull(),
expires: timestamp({ mode: 'string' }).notNull(),
}, (table) => {
return {
verificationTokenIdentifierTokenPk: primaryKey({ columns: [table.identifier, table.token], name: "verificationToken_identifier_token_pk"}),
}
identifier: varchar("identifier").notNull(),
token: varchar("token").notNull(),
expires: timestamp("expires").notNull(),
});
export const authenticator = pgTable("authenticator", {
@@ -425,25 +422,23 @@ export const authenticator = pgTable("authenticator", {
});
export const accounts = pgTable("accounts", {
uuid: uuid().defaultRandom(),
userId: text("user_id").notNull(),
type: text().notNull(),
id: uuid("id").primaryKey().defaultRandom(),
uuid: uuid("uuid").defaultRandom(),
userId: uuid("user_id").notNull(),
type: varchar("type").notNull(),
provider: text().notNull(),
providerAccountId: text("provider_account_id").notNull(),
providerAccountId: varchar("provider_account_id").notNull(),
refreshToken: text("refresh_token"),
accessToken: text("access_token"),
expiresAt: integer("expires_at"),
tokenType: text("token_type"),
scope: text(),
tokenType: varchar("token_type"),
idToken: text("id_token"),
sessionState: text("session_state"),
}, (table) => {
return {
accountProviderProviderAccountIdPk: primaryKey({ columns: [table.provider, table.providerAccountId], name: "account_provider_providerAccountId_pk"}),
}
});
sessionState: varchar("session_state"),
scope: text(),
}
);
export const vw_accounts = pgView("vw_accounts", {
/* export const vw_accounts = pgView("vw_accounts", {
uuid: uuid().defaultRandom(),
userId: text("user_id").notNull(),
type: text().notNull(),
@@ -459,4 +454,4 @@ export const vw_accounts = pgView("vw_accounts", {
first_name: text("first_name"),
last_name: text("last_name"),
},).existing();
},).existing(); */