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]: Column conflicts are not getting resolved by drizzle-kit #2346

Closed
SabirKhanek opened this issue May 18, 2024 · 2 comments
Closed

[BUG]: Column conflicts are not getting resolved by drizzle-kit #2346

SabirKhanek opened this issue May 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@SabirKhanek
Copy link

SabirKhanek commented May 18, 2024

What version of drizzle-orm are you using?

0.21.2

What version of drizzle-kit are you using?

0.30.6

Describe the Bug

Simulate the column conflicts:

  1. Write schema for demo_table:
export const demo_user = pgTable("demo_user", {
  username: text("username").primaryKey(),
  password: text("password")
})
  1. Generate migration file for the schema:
drizzle-kit generate
  1. Check the migration file (0001_opposite_thena.sql in my case):
CREATE TABLE IF NOT EXISTS "demo_user" (
	"username" text PRIMARY KEY NOT NULL,
	"password" text
);
  1. Now update the schema:
export const user = pgTable("user", {
  username: text("username").primaryKey(),
  password_hash: text("password_hash")
})

Notice I altered table name from demo_user -> user to simulate table level conflict, similarly I altered password -> password_hash to simulate column level conflict.
5. Now run the generate command again:

drizzle-kit generate

drizzle-kit prompts to choose if user is new table or renamed from demo_user.
6. Check the migration file 0002_stormy_dreadnoughts.sql in my case:

ALTER TABLE "demo_user" RENAME TO "user";

Expected behavior

  1. drizzle-kit should've prompted to resolve column conflicts (if password_hash renamed from password)
  2. Generated migration file should've included
ALTER TABLE "user" RENAME COLUMN "password" TO "password_hash";

Environment & setup

This issue only occurs if we have table conflict as well. I have tested while only simulating column conflict and it worked as expected. I've been using drizzle-kit@^0.20.0 and this issue wasn't there. I observed this issue after updating to drizzle-kit@^0.21.2

@SabirKhanek SabirKhanek added the bug Something isn't working label May 18, 2024
@SabirKhanek
Copy link
Author

this issue seems to be related with #2336 #2335

@AndriiSherman
Copy link
Member

This should be fixed in drizzle-kit@0.21.3. If the issue persists, feel free to reopen it!

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