Skip to content

fix(v4): MySQL/MSSQL migration bugs found - #1776

Merged
dimitri merged 1 commit into
mainfrom
fix/v4-bugs
Sep 14, 2026
Merged

dimitri merged 1 commit into
mainfrom
fix/v4-bugs

Conversation

@dimitri

@dimitri dimitri commented Sep 14, 2026 •

Copy link
Copy Markdown
Owner

MySQL:

  • Create target schemas before sequences, ENUM types and tables. ENUM types were created before their schema, so the table using them was lost, along with its FKs and sequence reset.
  • AUTO_INCREMENT integer columns become serial/bigserial (mirroring the CL default cast rules), instead of plain integer columns with no sequence.
  • DECODING TABLE NAMES MATCHING … AS now reads text columns as CAST(… AS BINARY) and decodes the stored bytes with that charset. SET NAMES asked the server to convert, which double-encoded the very data the clause is meant to repair.

PostgreSQL target:

  • Fix the sequence reset off-by-one: setval(seq, MAX(col), true), or setval(seq, 1, false) on an empty table, so the first insert no longer collides with the last migrated row.
  • "Reset Sequences" counts sequences actually reset, not tables visited.

SQL Server:

  • DEFAULT (N'new') lands as 'new', not as the literal text N'new'; doubled quotes in string literal defaults are unescaped.
  • Translate T-SQL default functions: GETDATE(), GETUTCDATE(), SYSDATETIME(), SYSUTCDATETIME(), SYSDATETIMEOFFSET() → CURRENT_TIMESTAMP, NEWID(), NEWSEQUENTIALID() → gen_random_uuid().

Logging:

  • Mask passwords in the Source/Target/Connected log lines, for pgloader URIs (user:@) and JDBC URLs (password=).

Tests: unit tests for each fix; E2E coverage in the mysql suite (no more BEFORE LOAD DO create schema workaround, sequences, decoding) and a v4-only tsqldefaults database in the mssql suite. Baselines that recorded the missing nextval() defaults are updated.

…on course

MySQL:
- Create target schemas before sequences, ENUM types and tables. ENUM types
  were created before their schema, so the table using them was lost, along
  with its FKs and sequence reset.
- AUTO_INCREMENT integer columns become serial/bigserial (mirroring the CL
  default cast rules), instead of plain integer columns with no sequence.
- DECODING TABLE NAMES MATCHING … AS <charset> now reads text columns as
  CAST(… AS BINARY) and decodes the stored bytes with that charset. SET NAMES
  asked the server to convert, which double-encoded the very data the clause
  is meant to repair.

PostgreSQL target:
- Fix the sequence reset off-by-one: setval(seq, MAX(col), true), or
  setval(seq, 1, false) on an empty table, so the first insert no longer
  collides with the last migrated row.
- "Reset Sequences" counts sequences actually reset, not tables visited.

SQL Server:
- DEFAULT (N'new') lands as 'new', not as the literal text N'new'; doubled
  quotes in string literal defaults are unescaped.
- Translate T-SQL default functions: GETDATE(), GETUTCDATE(), SYSDATETIME(),
  SYSUTCDATETIME(), SYSDATETIMEOFFSET() → CURRENT_TIMESTAMP, NEWID(),
  NEWSEQUENTIALID() → gen_random_uuid().

Logging:
- Mask passwords in the Source/Target/Connected log lines, for pgloader URIs
  (user:****@) and JDBC URLs (password=****).

Tests: unit tests for each fix; E2E coverage in the mysql suite (no more
BEFORE LOAD DO create schema workaround, sequences, decoding) and a v4-only
tsqldefaults database in the mssql suite. Baselines that recorded the missing
nextval() defaults are updated.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@dimitri dimitri changed the title fix(v4): MySQL/MSSQL migration bugs found while capturing the Migrati… fix(v4): MySQL/MSSQL migration bugs found Sep 14, 2026
@dimitri
dimitri merged commit 231ab86 into main Sep 14, 2026
37 checks passed
@dimitri
dimitri deleted the fix/v4-bugs branch September 14, 2026 05:26
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