Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Drizzle pg UUID support on types #1661

Open
versecafe opened this issue Aug 14, 2024 · 0 comments
Open

[Feature Request]: Drizzle pg UUID support on types #1661

versecafe opened this issue Aug 14, 2024 · 0 comments
Labels
feature request New feature requests

Comments

@versecafe
Copy link

Package

​@lucia-auth/session-drizzle

Description

Allow drizzle pg uuid types for session and user id fields instead of requiring a string

also just a note package should be @lucia-auth/adapter-drizzle

Should allow something like this

import {
  pgTable,
  timestamp,
  varchar,
  primaryKey,
  uuid,
  index,
} from "drizzle-orm/pg-core";
import { v7 as uuidv7 } from "uuid";

export const usersTable = pgTable(
  "users",
  {
    id: uuid("id").primaryKey().$defaultFn(uuidv7),
    username: varchar("username", { length: 60 }).unique().notNull(),
    avatar: varchar("avatar", { length: 2048 }),
    email: varchar("email", { length: 255 }),
    createdAt: timestamp("created_at").defaultNow().notNull(),
    lastLogin: timestamp("last_login").defaultNow().notNull(),
  },
  (table) => {
    return {
      usernameIndex: index("username_index").on(table.username),
    };
  },
);

export const sessionsTable = pgTable("sessions", {
  id: uuid("id").primaryKey().$defaultFn(uuidv7),
  userId: uuid("user_id")
    .notNull()
    .references(() => usersTable.id),
  expiresAt: timestamp("expires_at", {
    withTimezone: true,
    mode: "date",
  }).notNull(),
});
@versecafe versecafe added the feature request New feature requests label Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature requests
Projects
None yet
Development

No branches or pull requests

1 participant