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

[BUG]: drizzle-kit generate creates broken SQL for postgres when creating compound primary key #2514

Closed
beermonsterdota opened this issue Jun 14, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@beermonsterdota
Copy link

What version of drizzle-orm are you using?

0.31.2

What version of drizzle-kit are you using?

0.22.7

Describe the Bug

Same issue as #2423 when creating compound primary key with camelCase in one of columns name

export const accounts = pgTable(
  'account',
  {
    userId: text('userId'),
    providerAccountId: text('providerAccountId').notNull()
  },
  (account) => ({
    compoundKey: primaryKey({
      columns: [account.provider, account.providerAccountId],
      name: 'compound_pk',
    }),
  })
)

will create SQL to migrate that will throw error during migration
ALTER TABLE "account" ADD CONSTRAINT compound_pk PRIMARY KEY(provider,providerAccountId);

Expected behavior

Should have quotes around "camelCase" field
ALTER TABLE "account" ADD CONSTRAINT compound_pk PRIMARY KEY(provider,"providerAccountId");

Environment & setup

No response

@beermonsterdota beermonsterdota added the bug Something isn't working label Jun 14, 2024
@AndriiSherman
Copy link
Member

It's fixed in new versions of drizzle-kit. Please upgrade and check. If you still see this issue - feel free to reopen this ticket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants