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

Support for Indexes & Constraints #79

Open
constantins2001 opened this issue Nov 1, 2024 · 0 comments
Open

Support for Indexes & Constraints #79

constantins2001 opened this issue Nov 1, 2024 · 0 comments

Comments

@constantins2001
Copy link

When defining Indexes in Prisma those aren't reflected in the resulting drizzle schema.
Example:

model User {
  id                 String              @id
  email              String?
  emailVerified      Boolean             @default(false)
  createdAt          Int                 @default(dbgenerated("(unixepoch('subsecond') * 1000)"))

  @@index([email])
}

Actual

export const users = sqliteTable('User', {
    id: text('id').primaryKey(),
    email: text('email'),
    emailVerified: integer('emailVerified', {mode: 'boolean'}).default(false).notNull(),
    createdAt: integer('createdAt', {mode: 'number'}).default(sql`(unixepoch('subsecond') * 1000)`).notNull()
});

Expected

export const users = sqliteTable('User', {
    id: text('id').primaryKey(),
    email: text('email'),
    emailVerified: integer('emailVerified', {mode: 'boolean'}).default(false).notNull(),
    createdAt: integer('createdAt', {mode: 'number'}).default(sql`(unixepoch('subsecond') * 1000)`).notNull()
}, (table) => {
    return {
        emailIdx: index('email_idx').on(table.email)
    }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant