[PR #8538] fix(db): use CREATE INDEX for postgres migration #16293

Closed
opened 2026-04-13 10:29:10 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/8538

State: closed
Merged: Yes


Fixes: https://github.com/better-auth/better-auth/issues/8536

When adding indexed fields to existing tables, the migration code was using
Kysely's alterTable(...).addIndex(...) which generates MySQL-specific
ALTER TABLE ... ADD INDEX syntax, invalid in PostgreSQL.

Replace with createIndex(...) (matching the approach already used when
creating new tables) to generate valid CREATE INDEX SQL for all databases.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/8538 **State:** closed **Merged:** Yes --- Fixes: https://github.com/better-auth/better-auth/issues/8536 When adding indexed fields to existing tables, the migration code was using Kysely's `alterTable(...).addIndex(...)` which generates MySQL-specific `ALTER TABLE ... ADD INDEX` syntax, invalid in PostgreSQL. Replace with `createIndex(...)` (matching the approach already used when creating new tables) to generate valid `CREATE INDEX` SQL for all databases.
GiteaMirror added the pull-request label 2026-04-13 10:29:10 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16293