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

drizzle-kit push fails with "PostgresError: column "provider_id" is in a primary key" #4

Open
nickreynolds opened this issue Dec 22, 2024 · 1 comment

Comments

@nickreynolds
Copy link

I cloned this repo and successfully got it running. The drizzle-kit push command works the first time and my DB looks good.

However, if I add anything to the DB schema (adding a new table, not modifying existing ones at all), drizzle-kit push fails with this error:

[✓] Pulling schema from database...       
PostgresError: column "provider_id" is in 
a primary key

This seems related to this drizzle-kit issue: drizzle-team/drizzle-orm#2626

I was able to get around the issue once by adding a name to the primaryKey, but then it fails again on subsequent changes.

@dotnize
Copy link
Owner

dotnize commented Dec 23, 2024

The fix for me was adding .notNull() to both PKs.

61b9654

export const oauthAccount = pgTable(
  "oauth_account",
  {
-   provider_id: text(),
-   provider_user_id: text(),
+   provider_id: text().notNull(),
+   provider_user_id: text().notNull(),
    user_id: integer()
      .notNull()
      .references(() => user.id),
  },
  (table) => [primaryKey({ columns: [table.provider_id, table.provider_user_id] })],
);

Let me know if that works on your end :)

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

2 participants