Skip to content

[Drizzle Kit][Pg]: Altering a UNIQUE constraint: generated SQL ignores the new changes#5586

Open
CedricDsmet wants to merge 1 commit intodrizzle-team:betafrom
CedricDsmet:bug/alter-unique-constraint
Open

[Drizzle Kit][Pg]: Altering a UNIQUE constraint: generated SQL ignores the new changes#5586
CedricDsmet wants to merge 1 commit intodrizzle-team:betafrom
CedricDsmet:bug/alter-unique-constraint

Conversation

@CedricDsmet
Copy link
Copy Markdown

@CedricDsmet CedricDsmet commented Apr 3, 2026

Fixes #5585

The cause of the bug seems to be at

statements.push(addUniqueConvertor.convert({ unique: st.diff.$left }) as string);

const alterUniqueConvertor = convertor('alter_unique', (st) => {
	const statements: string[] = [];

	statements.push(dropUniqueConvertor.convert({ unique: st.diff.$left }) as string);
	statements.push(addUniqueConvertor.convert({ unique: st.diff.$left }) as string); // --> st.diff.$left should be change to st.diff.$right

	return statements;
});

@CedricDsmet CedricDsmet force-pushed the bug/alter-unique-constraint branch from ae38247 to 75a1bb8 Compare April 3, 2026 13:24
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

Successfully merging this pull request may close these issues.

1 participant