Export programmatic migration APIs for MSSQL, SQLite, and MySQL from drizzle-kit#5787
Open
r1tsuu wants to merge 1 commit into
Open
Export programmatic migration APIs for MSSQL, SQLite, and MySQL from drizzle-kit#5787r1tsuu wants to merge 1 commit into
r1tsuu wants to merge 1 commit into
Conversation
…drizzle-kit Add `drizzle-kit/api-mssql` entry point exposing `generateDrizzleJson`, `generateMigration`, `pushSchema`, `up`, and `startStudioServer`. This unblocks Payload's db-mssql adapter which needs programmatic access to the snapshot/migration/push pipeline. Restore the same exports (`generateDrizzleJson`, `generateMigration`, `pushSchema`, `up`) to `api-sqlite` and `api-mysql`, which were dropped in the 1.x transition and only had `startStudioServer`. Changes: - New `src/ext/api-mssql.ts` wiring MSSQL dialect internals into the public API - Export `fromExports` from `src/dialects/mssql/drizzle.ts` (was private) - Add full migration API exports to `src/ext/api-sqlite.ts` and `src/ext/api-mysql.ts` - Register api-mssql in both build systems and package.json exports - Add `mssql` to the external drivers list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
drizzle-kit/api-mssqlentry point exposinggenerateDrizzleJson,generateMigration,pushSchema,up, andstartStudioServer— unblocking Payload'sdb-mssqladapter which needs programmatic access to the snapshot/migration/push pipelinegenerateDrizzleJson,generateMigration,pushSchema,upexports toapi-sqliteandapi-mysql(dropped in 1.x, only hadstartStudioServer)fromExportsfromsrc/dialects/mssql/drizzle.ts(was privatefromExport)api-mssqlin both build systems (build.ts,scripts/build.ts) andpackage.jsonexportsmssqlto the external drivers listContext
Payload CMS uses drizzle-kit's programmatic API (
generateDrizzleJson,generateMigration,pushSchema) to power its database adapter pattern. In drizzle-kit 1.x, onlyapi-postgresretained these exports —api-sqliteandapi-mysqlwere reduced tostartStudioServeronly, andapi-mssqldidn't exist at all. This blocks both the Payload drizzle-kit upgrade and the newdb-mssqladapter.All three new API surfaces follow the exact same pattern as the existing
api-postgres.ts, adapted for each dialect's resolver set, snapshot shape, and introspection interface.Test plan
Verified locally:
pnpm buildsucceeds — all API bundles (CJS + ESM) and declaration files producedgenerateDrizzleJson,generateMigration,pushSchema,startStudioServer,up) resolve in CJS, ESM, and.d.tsfor all three dialectsgenerateDrizzleJson+generateMigrationround-trip: empty→schema produces correctCREATE TABLEfor MSSQL, SQLite, MySQLgenerateDrizzleJson+generateMigrationdiff: v1→v2 schema produces correctALTER TABLE ... ADDfor all three dialectspushSchemaagainst live in-memory SQLite: create table, add column (data preserved), no-op on re-pushupfunctions resolve to correct version upgraders (upToV2MSSQL,updateToV7SQLite,upToV6MySQL)