[PR #8539] refactor(test): use snapshot assertions for migration SQL output tests #16294

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

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

State: open
Merged: No


Summary

  • Use CREATE INDEX instead of MySQL-specific ALTER TABLE ... ADD INDEX when adding indexed columns to existing tables, fixing PostgreSQL compatibility
  • Refactor migration SQL output tests to use Vitest snapshot assertions instead of string matching

Changes

  • Switch added-column index generation from alterTable(...).addIndex(...) to createIndex(...).on(...).columns(...)
  • Handle unique indexes by emitting .unique() when the field is unique
  • Add PostgreSQL and SQLite regression tests for the CREATE INDEX fix
  • Replace toContain/regex assertions with toMatchSnapshot() for compiled migration SQL

Fixes #8536
Ported from better-auth/ai#57

Test plan

  • SQLite snapshot test passes locally
  • PostgreSQL tests pass in CI (require Docker)
**Original Pull Request:** https://github.com/better-auth/better-auth/pull/8539 **State:** open **Merged:** No --- ## Summary - Use `CREATE INDEX` instead of MySQL-specific `ALTER TABLE ... ADD INDEX` when adding indexed columns to existing tables, fixing PostgreSQL compatibility - Refactor migration SQL output tests to use Vitest snapshot assertions instead of string matching ## Changes - Switch added-column index generation from `alterTable(...).addIndex(...)` to `createIndex(...).on(...).columns(...)` - Handle unique indexes by emitting `.unique()` when the field is unique - Add PostgreSQL and SQLite regression tests for the CREATE INDEX fix - Replace `toContain`/regex assertions with `toMatchSnapshot()` for compiled migration SQL ## Related Issues Fixes #8536 Ported from better-auth/ai#57 ## Test plan - [x] SQLite snapshot test passes locally - [ ] PostgreSQL tests pass in CI (require Docker)
GiteaMirror added the pull-request label 2026-04-13 10:29:11 -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#16294