Skip to content

[Pg-kit]: Drop identity before changing a column's type - #1

Closed
yyuneu wants to merge 2 commits into
rc5from
fix/pg-drop-identity-before-type-change
Closed

[Pg-kit]: Drop identity before changing a column's type#1
yyuneu wants to merge 2 commits into
rc5from
fix/pg-drop-identity-before-type-change

Conversation

@yyuneu

@yyuneu yyuneu commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Fixes the statement order reported in drizzle-team#4178.

When a column loses its identity and changes type in the same alter, alterColumnConvertor emitted SET DATA TYPE (and SET DEFAULT) before DROP IDENTITY. Postgres rejects both while the identity is still attached (identity column type must be smallint, integer, or bigint / column ... is an identity column), so both generate output and push failed.

DROP IDENTITY is now emitted before the type and default changes. Added a regression test in tests/postgres/pg-identity.test.ts that runs the statements on PGlite.

Limitations: the integer → uuid case from the issue still needs a manual USING expression, since Postgres has no integer→uuid cast. The same ordering exists in dialects/cockroach/convertor.ts and is left for a follow-up.

Postgres allows identity only on integer types, so SET DATA TYPE issued before DROP IDENTITY failed (drizzle-team#4178).
Covers dropping identity while changing the column type and default in one alter.
@yyuneu yyuneu closed this Sep 2, 2026
@yyuneu yyuneu reopened this Sep 2, 2026
@yyuneu yyuneu closed this Sep 2, 2026
@yyuneu yyuneu reopened this Sep 2, 2026
@yyuneu yyuneu closed this Sep 2, 2026
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