Skip to content

feat: add rollback/down migrations support#1

Open
roor0 wants to merge 1358 commits intomainfrom
feat/down-migrations
Open

feat: add rollback/down migrations support#1
roor0 wants to merge 1358 commits intomainfrom
feat/down-migrations

Conversation

@roor0
Copy link
Copy Markdown
Owner

@roor0 roor0 commented Mar 7, 2026

Summary

  • Adds bidirectional migration support across all 25 drivers — each .sql migration file can now have a corresponding .down.sql that reverses the changes
  • readMigrationFiles extended to parse .down.sql alongside each .sql; MigrationMeta gains optional downSql?: string[]
  • New rollback(db, config, steps?) exported from every driver migrator
  • drizzle-kit auto-generates down SQL by running the diff with swapped snapshots; writeResult writes .down.sql files; embeddedMigrations bundles down SQL imports for embedded drivers (expo-sqlite, op-sqlite, durable-sqlite)
  • Journal entry type gains optional hasDown?: boolean flag
  • SQLite rollback uses rowid for precise single-row deletion and falls back to folderMillis matching for bundled drivers that set hash: ''

Drivers covered

All 25 drivers: node-postgres, postgres-js, pglite, neon-serverless, neon-http, vercel-postgres, aws-data-api/pg, pg-proxy, mysql2, planetscale-serverless, tidb-serverless, singlestore, singlestore-proxy, mysql-proxy, better-sqlite3, bun-sqlite, bun-sql, sql-js, sqlite-proxy, libsql, d1, expo-sqlite, op-sqlite, durable-sqlite, xata-http

Test plan

  • pnpm vitest run tests/migrate/down-sql.test.ts (drizzle-kit) — 10 tests
  • pnpm vitest run tests/sqlite/rollback.test.ts (integration-tests) — 17 tests including bundled empty-hash scenario
  • pnpm vitest run tests/pg/pglite.test.ts (integration-tests) — PGlite rollback tests

AleksandrSherman and others added 27 commits December 31, 2025 16:09
* [update]: int tests removed skipIf in some tests

* [update-kit]: changelog

* [update-kit]: pg index issue fixed

* [kit-fix]: pg + cockroach issue

* [kit]: mssql issue

* Fixed bun-sqlite rqbv2 mapper error on empty get response (fixes drizzle-team#5189)

* Up all versions to 7 + orm changelog

* changelog update

* [update-kit]: tests on ignore migrations config schema/table + minor updates

* [fix-kit]: fixed all fromDatabaseForDrizzle params

* [fix-kit]: fixed broken tests

* [kit-fix]: broken tests

---------

Co-authored-by: OleksiiKH0240 <homenko0240@gmail.com>
Co-authored-by: Alex Blokh <aleksandrblokh@gmail.com>
Co-authored-by: AndriiSherman <andreysherman11@gmail.com>
Co-authored-by: Sukairo-02 <sreka9056@gmail.com>
* bug fixes

* +

* fix regex

* added min/max parameters to time, datetime, timestamp generators,
updated tests for using these generators(+date generator) with parameters,
added feature to ignore column in refinements

* fixes

* test for ignoring columns

* partly added seq update

* updates pg seq after seeding

* +

* updated uuid generator

* updated test

* fixed drizzle-seed build bug

* turbo.json fix

* turbo.json fix

* Update api for min max

---------

Co-authored-by: Andrii Sherman <andreysherman11@gmail.com>
Co-authored-by: Alon Amster <m@ster.am>
- Fixed lack of query result recalculation on pg dynamic update with joins
- Support for `@effect/sql-pg` driver
- `@effect/sql-pg` driver support  
- Reworked `pg`: `execute`-less core builders, `async`,`effect` `query-builders`,`session`,`preparedQuery` variants  
- Improved `PgColumn` types: better type performance, simpler declaration, reworked `.array()` to use `.array('[][]')` syntax instead of `.array().array()`  
---------

Co-authored-by: Alex Blokh <aleksandrblokh@gmail.com>
* Tagged effect errors for effect drivers, fixed kit `bun-sql` `sqlite`, `mysql` driver variants using `pg` functions

* Typo fix

* Extended type tests for columns with `strictNullChecks: false`

* Fixed broken type inferrence of `PgColumn`s with `"strictNullChecks": false` typescript option caused by updates in `1.0.0-beta.9`
* updated tests

* +

* updated tests

* [drizzle-kit] updated tests

* [drizzle-kit] added tests

* [drizzle-kit] added tests

* [drizzle-kit] updated test

* added tests

* updated pull tests

* +

* [integration-tests] updated tests

* corrected issue links

* [drizzle kit] added test

* [drizzle-kit] added test

* [drizzle-kit] added tests

* [feat-orm]: index logic

Added ability to pass table column to index, uniqueIndex, using in outer const. Without using 3rd param in table

* added tests

* updated tests

* [drizzle-kit] added tests

* [fix+update]: mysql use/force/ignore index update + pg asc/nullsFirst index update

Mysql:
- Added ability to handle unique constraints in use/force/ignore indexes in select queries
- Added tests

Pg:
- in drizzle-kit/drizzle.ts file updated logic regarding nullsFirst and asc/desc creation
pg docs: https://www.postgresql.org/docs/current/sql-createindex.html

* [update]: changelog

* [drizzle-kit] added tests

* [psql]: fixed broken tests in kit

* [mysql]: fixed some an issue in kit

* [sqlite]: isssue + fk introspect bugs fixed

* [mssql]: index bug fix in kit

* [cockroach]: fixed tests in kit

* [sqlite]: fk introspect fix

* [psql]: kit pk tests

* [update]: changelog for drizzle-kit

* [mssql]: kit fix

* [drizzle-kit] added tests

* [mssql-kit]: up to v2

* [kit]: psql + cockroach enum tests

* [drizzle-kit] added tests

* updated comments in tests

* [update]: kit tests update

* [update]: ignored ts error for deploy

* [update-casing]: removed casing from Name class

* [update]: isNull wrapped in ()

* [updates]: tests + bug fixes

- Fixed "buildIndex" method in mysql for `use/force/ignore` indexes
- Updated some integration tests

* [update]: fixed int:sqlite tests

* [update]: singlestore int test

* [update]: singlestore test

* [update]: changelog for kit + up of package.json versions of orm and kit

* [update]: changelog + test

* [drizzle-kit] added tests

* [drizzle-kit] added test

* updated test

* [update-kit]: psql test

* [update-kit]: fixed tests

Added:
- handling on column alters to serial in pg
- suggestions for diff in mysql

* [update-kit]: deprecated 'strict' flag

* [update-kit]: test

* [update-kit]: test

* [update-kit]: mssql test

* [update-kit]: fix

* [update-kit]: added explain to every dialect

* added tests

* fixed prompt for column conflicts; added tests

* [update-kit]: sqlite up fixes

- Added tests on up (like pg and mysql had)
- fixed some minor fixes

* [fix-kit]: errors in mocks

* [fix-kit]: mssql fixes

* [fix-kit]: tests fix to deploy

* [fix-kit]

* [fix-kit]

* [fix-kit]

* [update]: versions + changelog for sqlite

* [update]: comment

* [update-kit]: fixed mssql + new tests

* [fix-kit]: --explain handling

* Update release notes

* [sqlite-kit-fix]: introspect + explain

* [update-kit]: fixed two issues

* [fix-kit]: deepStrictEqual + fixed broken tests

* [update-kit]: fixed issues

* [update-kit]: added custom type for sqlite introspect + up all packages

* [fix-kit]: defaults for text

* added tests

* [fix-kit]: fixed + postponed tests

* [fix-kit]: sqlite def test

* added tests

* added tests

* removed migration prefix from drizzle-kit

* [update-kit]: handle custom migration schema and table in push + tests

* [kit-fix]: tables tests

* [kit-fix]: cli tests

* [fix-kit]

* [update-kit]

* [update]: int tests removed skipIf in some tests

* [update-kit]: changelog

* [update-kit]: pg index issue fixed

* [kit-fix]: pg + cockroach issue

* [kit]: mssql issue

* Fixed bun-sqlite rqbv2 mapper error on empty get response (fixes drizzle-team#5189)

* Up all versions to 7 + orm changelog

* changelog update

* [update-kit]: tests on ignore migrations config schema/table + minor updates

* [fix-kit]: fixed all fromDatabaseForDrizzle params

* [fix-kit]: fixed broken tests

* [kit-fix]: broken tests

* added tests

* added tests

* [kit-fix]: mysql fixes

* added tests

* [kit-fix]: fixed issues 5224 and 5212

* [kit-fix]: fixed psql issue

* [kit-fix]: entity filter update for pg

* [kit]: removed .only

* [kit-fix]: introspect fix for pk

* [kit-fix]: returned entity filter logic back as it was

* [kit-fix]: added some tests + tests on tsc relations

* fixed test

* orm timestamp batch + noop cache ignored from cache + mysql cyclic introspect

* Separated date and int-exclusive column methods from common pg builder

* added tests

* upped versions + upped skipped tests dates + changelogs + extra tests

* skipped tests

* extra fix + test

---------

Co-authored-by: OleksiiKH0240 <homenko0240@gmail.com>
Co-authored-by: Alex Blokh <aleksandrblokh@gmail.com>
Co-authored-by: AndriiSherman <andreysherman11@gmail.com>
Co-authored-by: Sukairo-02 <sreka9056@gmail.com>
* Added migrator from migration journal to `bun-sqlite`
* Fixed lack of placeholders in update

* Fixed broken test cases

* Additional test case fixes

* Additional test case fixes

* Fixed lack of alias proxying for view's `selectedFields`, fixed lack of alias handling for views in `from` clause

* Fixed broken test concurrency

* Fixed broken ternary condition

* Post-cache mapping of query result in effect-pg

* Extended test case skip duration

* Fixed drizzle-constructor not passing cache to EffectPgSession constructor

* Extended tests postpone date

* Improved config types for `exactOptionalPropertyTypes`

* +

* added tests

* Fixed bun-sqlite db.get(...) returning data in array mode instead of object mode (@Sukairo-02 commit)

* [kit-fix]: schema errors - added all cases for all dialects

* added orm changelog for beta 12

* moved formatToMillis in migrator.ts to migrate.utils.ts to avoid unintentional imports

* [kit-update]: ts schema error handling for generate + push

* [kit-update]: export command now throws errors if smthing wrong with the schema

* added tests

* added orm changelog

* Fixed `formatToMillis` import in migrators
Removed not valid test

* merged beta-fixes and updated changelog for orm

* postponed some tests

* fixed drizzle-team#4950 issue

* [kit-update]: tests

* [kit-fix]: fixed upper for pg

* postponed tests

* [kit-fix]: fixed test

* up package.json versions

* added tests

* [update]:

- Handled .inlineParams() for sql``
- Removed T['data'] from generatedAlwaysAs. It is now only SQL and () => SQL types

* updated changelogs

* remove .only from tests

* added tests

* fixed tests + build selection for single table

* added to all .generatedAlwaysAs tests sql`` instead of literals

* updated kit changelogs

* postponed + fixed tests

* postponed + fixed tests

---------

Co-authored-by: Sukairo-02 <sreka9056@gmail.com>
Co-authored-by: OleksiiKH0240 <homenko0240@gmail.com>
* Improve drizzle-effect integration, add type tests

* Update imports

* Remove comments

* Fix services providing

* Cleanup effect logger and cache

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update type tests

* Fix import

* Add attw concise mode

* fix(drizzle-kit): support top-level await in config and schema files

Replace require() with async loadModule() using jiti to enable top-level await in user config and schema files on Node.js.

- Add loadModule() function with jiti for TypeScript files
- Update config loading in utils.ts
- Update schema loading in studio.ts and dialect files
- Add Node version check (requires 18.19+, 20.6+, or 21+)
- Bun/Deno continue using native import()

* Removed unused tracing

* postpone more

* Update release notes

---------

Co-authored-by: Sukairo-02 <sreka9056@gmail.com>
Co-authored-by: AndriiSherman <andreysherman11@gmail.com>
…n mysql for improved performance and add progress callbacks for better tracking
* Fixed lack of placeholders in update

* Fixed broken test cases

* Additional test case fixes

* Additional test case fixes

* Fixed lack of alias proxying for view's `selectedFields`, fixed lack of alias handling for views in `from` clause

* Fixed broken test concurrency

* Fixed broken ternary condition

* Post-cache mapping of query result in effect-pg

* Extended test case skip duration

* Fixed drizzle-constructor not passing cache to EffectPgSession constructor

* Extended tests postpone date

* Improved config types for `exactOptionalPropertyTypes`

* +

* added tests

* Fixed bun-sqlite db.get(...) returning data in array mode instead of object mode (@Sukairo-02 commit)

* [kit-fix]: schema errors - added all cases for all dialects

* added orm changelog for beta 12

* moved formatToMillis in migrator.ts to migrate.utils.ts to avoid unintentional imports

* [kit-update]: ts schema error handling for generate + push

* [kit-update]: export command now throws errors if smthing wrong with the schema

* added tests

* added orm changelog

* Fixed `formatToMillis` import in migrators
Removed not valid test

* merged beta-fixes and updated changelog for orm

* postponed some tests

* fixed drizzle-team#4950 issue

* [kit-update]: tests

* [kit-fix]: fixed upper for pg

* postponed tests

* [kit-fix]: fixed test

* up package.json versions

* added tests

* [update]:

- Handled .inlineParams() for sql``
- Removed T['data'] from generatedAlwaysAs. It is now only SQL and () => SQL types

* updated changelogs

* remove .only from tests

* added tests

* fixed tests + build selection for single table

* added to all .generatedAlwaysAs tests sql`` instead of literals

* updated kit changelogs

* postponed + fixed tests

* postponed + fixed tests

* [kit-update]: Fix view ordering in schema serialization to respect dependencies in all dialects

This commit contains update login in `drizzle.ts` file
When using `prepareFromSchemaFiles` to read schema files, views were returned in an unpredictable order (not in order that is was declared in schema.ts). This caused dependent views to appear before their dependencies, which breaks migration

* added tests

* fixed drizzle-team#1227; added test; made pg drizzle-kit tests run on multiple PostgreSQL versions

* [update]: migrator for all dialects

The migrator now applies all changes that are missing in the database. Previously the migrator only looked for local migrations with a creation date later than the last migration applied in the database. It now detects and applies all missing migrations

Added tests for all dialects

* postponed tests

* postponed tests + update test

* postponed test

* [update]: merged drizzle-team#5272 issue fix + postponed some tests

* [update]: fixed kit + orm tests + updated changelogs

* Restricted usage of async functions in sync drivers' transactions

* added tests

* fixed drizzle-seed bug

* fix lockfile and package.json specifiers mismatch

* added tests

* [update-kit]: fixed issues + updated changelog

* [update-kit]: postponed + fixed tests

* [update]: kit + int postponed tests

* [update]: upped all packages versions. fixed failed tests

* fixed kit test

* [update-kit]: updated comment

* [update-kit]: fixed drop index

* [fix-kit]: serial introspect

* [update]: minor int tests updates

* upped packages versions

* +

* [fix-kit]: missed from merging

* added tests

* [update-orm]: fixed mssql transactions

* Update effect

* tests on migrator effect + postponed tests

* renamed test migration dir

* update effect migrator test

---------

Co-authored-by: Sukairo-02 <sreka9056@gmail.com>
Co-authored-by: OleksiiKH0240 <homenko0240@gmail.com>
Co-authored-by: AndriiSherman <andreysherman11@gmail.com>
* Added explicit origin to `SQL.Aliased` fields used in selections of views and CTEs

* Fixed tests

* Fixed `sqlite` select order & group by clauses not accepting `SQL.Aliased`, removed `SQL.Aliased` origin prefix for single table queries

* Kit test fix

* Autogenerated `name` for prepared queries (drizzle-team#5311)

* Made `query.prepare(name)` name param optional

* Added tests for nameless prepared statements

* Autogenerated prepared query names for `pg`, `cockroach`, `gel`, code cleanup

* @effect/Schema validator generator, validator generators in orm package (drizzle-team#5295)

- Added `@effect/Schema` validator generator
- Fixed validator generators having entities used for output types being marked as `@internal`
- Fixed validator generators generating wrong types for JSON columns when type does not satisfy `Record<string, unknown>`
- Moved validator generators to `drizzle-orm/validations`
- Moved legacy typebox (`@sinclair/typebox`) generator to `drizzle-orm/validations/typebox-legacy`
- Supported `typebox v1` generator in `drizzle-orm/validations/typebox` (fixes drizzle-team#5011, credits to drizzle-team#5076)  

---------

Co-authored-by: AndriiSherman <andreysherman11@gmail.com>

* Update release notes

---------

Co-authored-by: AndriiSherman <andreysherman11@gmail.com>
* Add new migrations versioning

* added up logic for migration tables for mssql, cockroach, sqlite, mysql

* updated all migrators for rest dbs

* moved CURRENT_MIGRATION_TABLE_VERSION to common folder

* fixed up migration table for sqlite

* updates in up migrators (name fix + sqlite fixes)

* cut millis to sec + 000

* Fix migrator utils

* updates + fixed up migrations

* updates in up migrators

* Fix mysql commutative

* updates in pg migrator - check on table shape and remove "version" column

* removed "version" column for all migrators + updated up-migrator for all dialects to detect by table shape

* check if drizzle_migrations table exists by validating result length instead of value

* added pg-effect up migrator

* up-migrators

- fixes in pg, effect-pg
- removed export for CURRENT_MIGRATION_TABLE_VERSION

* d1 migrator fix

* migrator-fixes

- postponed tests
- uncommented some tests
- fix integration tests with migrators
- updated logic for sqlite,mysql proxy up migrations
- fixed imports

* more fixes

* fixes in pg

* custom wrapper for pg up migration

* wrappers on sqlite and mysql up migrators

* singlestore fix: looks like final fix

* cockroach removed access to crdb_internal after v25. Fixed introspect

* Add last check for commutative

* Update brocli

* Fixed migration upgrade function

* Import fix

* update schema

* Update utils

* cockroach introspect query fix

* fix cockroach introspect query

* add static cockroach version for docker since problems in v26

* snapshot generator

* fixes in psql diff + updates in serializer-snapshot.test.ts

* fix: update privilege grantee and grantor formatting in SQL statements

* simplified generateLatestSnapshot and added tests

* Postgres add snapshot composer for leafs

* Finish skipif

* fix

* removed unnecessary statements

* fix

* up versions

* Update double-conflicts check

* ci/cd fix from codecs

* remove guide link for now

---------

Co-authored-by: Aleksandr Sherman <aleksandrserman@gmail.com>
Co-authored-by: Sukairo-02 <sreka9056@gmail.com>
Co-authored-by: RomanNabukhotnyi <nabukhotnyiroman@gmail.com>
* warnings and transactions on up pg migrations

* updates in pg up migrator

* Null property access guard for null-prototype objects

* `node-sqlite` (drizzle-team#5464)

* Updated to `node 25`, supported `node-sqlite` driver, changed `rmDirSync` to `rmSync` due to `recursive: true` deprecation, sync sqlite transaction rollback tests

* Reverted node versions outside of tests

* Reset node version

* Tests fix

* Fixed tests, fixed relational queries in `node-sqlite` returning null-prototype objects

* Removed useless dynamic import \& error message

* Update text

* remove prisma dev deps

* extra checks on sql up migrators

* package.json up versions

* sqlite up moved updated transaction

* moved up migration for cockroach to up folder

* fix

* fix imports

* changelog

---------

Co-authored-by: Sukairo-02 <sreka9056@gmail.com>
Co-authored-by: Sergey Reka <71607800+Sukairo-02@users.noreply.github.com>
Co-authored-by: AndriiSherman <andreysherman11@gmail.com>
* Fix tsconfig path aliases in drizzle-kit

* Fix typecheck and import whitelist for tsconfig tests

* Improve tsconfig alias resolution

* update tests

* support node sqlite for kit (drizzle-team#5475)

* added node:sqlite support driver to drizzle-kit

* fix

* updated compatibilityVersion

* added node version warn for node:sqlite

* bump to beta.18

* added transactions to up-pg

* fix

* fixed attw

* pass dbs to migrate instead of db.sessions + added batch for neon-http in up migrate

* fix

* changed type: "http" to mode: "transaction" | "execute"

* fixed attw + added batch mode

* `hanjiv0.0.8` update, removed unused dependency

* Fixed type errors

* fix: Correct string interpolation for database name in DuckDB introspection queries (drizzle-team#5486)

* Build fix, postponed tests

* Updated deprecated configs

* Reverted kit's tsdown to working version, updated config

* Reverted tsdown

* Updated configs

* Reverted configs

* Config fix

* Updated tsdown, returned global tsdown, switched build scripts to use bun as was intended

* Updated seeder shebang to use bun

* Switched to compatible `tsdown` ver

* Fixed builder exiting with wrong code

* Fixed builder exiting with wrong code

* Fixed wrong exit usage

* remove as number

---------

Co-authored-by: AndriiSherman <andreysherman11@gmail.com>
Co-authored-by: Aleksandr Sherman <102579553+AleksandrSherman@users.noreply.github.com>
Co-authored-by: Aleksandr Sherman <aleksandrserman@gmail.com>
Co-authored-by: Sukairo-02 <sreka9056@gmail.com>
Co-authored-by: Roman Nabukhotnyi <97584054+RomanNabukhotnyi@users.noreply.github.com>
* Fixed lack of placeholders in update

* Fixed broken test cases

* Additional test case fixes

* Additional test case fixes

* Fixed lack of alias proxying for view's `selectedFields`, fixed lack of alias handling for views in `from` clause

* Fixed broken test concurrency

* Fixed broken ternary condition

* Post-cache mapping of query result in effect-pg

* Extended test case skip duration

* Fixed drizzle-constructor not passing cache to EffectPgSession constructor

* Extended tests postpone date

* Improved config types for `exactOptionalPropertyTypes`

* +

* added tests

* Fixed bun-sqlite db.get(...) returning data in array mode instead of object mode (@Sukairo-02 commit)

* [kit-fix]: schema errors - added all cases for all dialects

* added orm changelog for beta 12

* moved formatToMillis in migrator.ts to migrate.utils.ts to avoid unintentional imports

* [kit-update]: ts schema error handling for generate + push

* [kit-update]: export command now throws errors if smthing wrong with the schema

* added tests

* added orm changelog

* Fixed `formatToMillis` import in migrators
Removed not valid test

* merged beta-fixes and updated changelog for orm

* postponed some tests

* fixed drizzle-team#4950 issue

* [kit-update]: tests

* [kit-fix]: fixed upper for pg

* postponed tests

* [kit-fix]: fixed test

* up package.json versions

* added tests

* [update]:

- Handled .inlineParams() for sql``
- Removed T['data'] from generatedAlwaysAs. It is now only SQL and () => SQL types

* updated changelogs

* remove .only from tests

* added tests

* fixed tests + build selection for single table

* added to all .generatedAlwaysAs tests sql`` instead of literals

* updated kit changelogs

* postponed + fixed tests

* postponed + fixed tests

* [kit-update]: Fix view ordering in schema serialization to respect dependencies in all dialects

This commit contains update login in `drizzle.ts` file
When using `prepareFromSchemaFiles` to read schema files, views were returned in an unpredictable order (not in order that is was declared in schema.ts). This caused dependent views to appear before their dependencies, which breaks migration

* added tests

* fixed drizzle-team#1227; added test; made pg drizzle-kit tests run on multiple PostgreSQL versions

* [update]: migrator for all dialects

The migrator now applies all changes that are missing in the database. Previously the migrator only looked for local migrations with a creation date later than the last migration applied in the database. It now detects and applies all missing migrations

Added tests for all dialects

* postponed tests

* postponed tests + update test

* postponed test

* [update]: merged drizzle-team#5272 issue fix + postponed some tests

* [update]: fixed kit + orm tests + updated changelogs

* Restricted usage of async functions in sync drivers' transactions

* added tests

* fixed drizzle-seed bug

* fix lockfile and package.json specifiers mismatch

* added tests

* [update-kit]: fixed issues + updated changelog

* [update-kit]: postponed + fixed tests

* [update]: kit + int postponed tests

* [update]: upped all packages versions. fixed failed tests

* fixed kit test

* [update-kit]: updated comment

* [update-kit]: fixed drop index

* [fix-kit]: serial introspect

* [update]: minor int tests updates

* upped packages versions

* +

* [fix-kit]: missed from merging

* added tests

* [update-orm]: fixed mssql transactions

* Update effect

* tests on migrator effect + postponed tests

* renamed test migration dir

* update effect migrator test

* fixed weightedRandom generator in drizzle-seed; added tests to integration-tests

* added tests; fixed defineRelations function error message.

* [drizzle-seed] fixed seq update with casing

* postponed tests + fixed issue

* updates in introspect tests + fixed issue

* filter schema files by file extension + removed duplicated prepareFilenames

* updates in kit changelogs file

* added test cases

* postponed tests + fixed issue 5495 + fixed cli tests

* drizzle-seed fix

* fixed drizzle-team#5493 issue

* updated changelog

* fixed drizzle-team#5489 issue

* consolidate SQLite/LibSQL push commands with unified batch interface

* removed transactions for sqlite push for proper PRAGMA work

* fixed drizzle-team#5488 (added guard on this.requestLayout)

* postponed tests + removed Object.freeze

* fixed tests

* handling multiple databases in mysql migrate()

* tests update

* fixed again

* updated singlestore session.all to use .query instead of .execute. Added some more tests on multiple mysql dbs

* updated comment

* upped packages + updated changelog

* fixed test

* updates in pg introspect to fix drizzle-team#5308

* skipped tests

* updated changelog

* make release without hash for beta branch

* SqlCommenter (drizzle-team#5508)

* `sqlcommenter` comments support for `postgres`, `mysql` query builders & prepared queries

* Fixed imports

* Test fix

* Implemented comment merging, string-type comments

* Fixed tests

* Removed post-prepare comment editing

* Removed sql.if calls

* Switched integration tests for comments to full query comparison

* Extended postpone date

* Fixed tests

* release notes comments

---------

Co-authored-by: Sukairo-02 <sreka9056@gmail.com>
Co-authored-by: OleksiiKH0240 <homenko0240@gmail.com>
Co-authored-by: AndriiSherman <andreysherman11@gmail.com>
Co-authored-by: Sergey Reka <71607800+Sukairo-02@users.noreply.github.com>
Generate down.sql files alongside migration.sql during `drizzle-kit generate`.
Down SQL is produced by running the schema diff in reverse with rename-aware
resolvers so that renames produce RENAME statements instead of DROP/CREATE.

Adds `rollback()` export to every driver migrator and dialect class.
Rollback reads the N most-recently-applied migrations from the tracking table,
executes their down SQL in reverse order, and removes the tracking rows.

Bundled migration support (Expo, Durable SQLite, OP-SQLite) gains a
`downMigrations` record in the generated migrations.js file.
@roor0 roor0 force-pushed the feat/down-migrations branch from 5755197 to c3f9e83 Compare March 25, 2026 02:03
roor0 added 2 commits March 24, 2026 23:48
- Use sql.identifier() in proxy rollback DELETE statements instead of
  raw string interpolation (mysql-proxy, pg-proxy, sqlite-proxy,
  singlestore-proxy)
- Use path.dirname() instead of string replace for Windows-safe
  down.sql detection in embeddedMigrations
- Standardize SELECT id (not rowid) in SQLite/durable-sqlite rollback
- Tighten invertRenames matching to include schema/table properties,
  not just name, to correctly handle column renames across tables
- Fix embeddedMigrations output indentation
- Remove redundant downSqlDelimiter variable
- Add TODO comments for missing node-mssql and effect-postgres rollback
- Expand test coverage: breakpoints:false, multiple captures,
  schema/table disambiguation, partial match, breakpoint count/order
…e-hash collision

When two migrations have identical SQL content they share the same hash.
The previous `migrations.find(m => m.hash === dbMigration.hash)` could
return the wrong migration's downSql. Now all rollback lookups fetch
`name` from the tracking table and match on both hash and name, with a
guard for old rows that lack a name value.
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.

9 participants