Skip to content

Export programmatic migration APIs for MSSQL, SQLite, and MySQL from drizzle-kit#5787

Open
r1tsuu wants to merge 1 commit into
drizzle-team:betafrom
r1tsuu:payload/export-mssql-api
Open

Export programmatic migration APIs for MSSQL, SQLite, and MySQL from drizzle-kit#5787
r1tsuu wants to merge 1 commit into
drizzle-team:betafrom
r1tsuu:payload/export-mssql-api

Conversation

@r1tsuu
Copy link
Copy Markdown

@r1tsuu r1tsuu commented May 20, 2026

Summary

  • Add drizzle-kit/api-mssql entry point exposing generateDrizzleJson, generateMigration, pushSchema, up, and startStudioServer — unblocking Payload's db-mssql adapter which needs programmatic access to the snapshot/migration/push pipeline
  • Restore generateDrizzleJson, generateMigration, pushSchema, up exports to api-sqlite and api-mysql (dropped in 1.x, only had startStudioServer)
  • Export fromExports from src/dialects/mssql/drizzle.ts (was private fromExport)
  • Register api-mssql in both build systems (build.ts, scripts/build.ts) and package.json exports
  • Add mssql to the external drivers list

Context

Payload CMS uses drizzle-kit's programmatic API (generateDrizzleJson, generateMigration, pushSchema) to power its database adapter pattern. In drizzle-kit 1.x, only api-postgres retained these exports — api-sqlite and api-mysql were reduced to startStudioServer only, and api-mssql didn't exist at all. This blocks both the Payload drizzle-kit upgrade and the new db-mssql adapter.

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 build succeeds — all API bundles (CJS + ESM) and declaration files produced
  • All 5 exports (generateDrizzleJson, generateMigration, pushSchema, startStudioServer, up) resolve in CJS, ESM, and .d.ts for all three dialects
  • generateDrizzleJson + generateMigration round-trip: empty→schema produces correct CREATE TABLE for MSSQL, SQLite, MySQL
  • generateDrizzleJson + generateMigration diff: v1→v2 schema produces correct ALTER TABLE ... ADD for all three dialects
  • pushSchema against live in-memory SQLite: create table, add column (data preserved), no-op on re-push
  • up functions resolve to correct version upgraders (upToV2 MSSQL, updateToV7 SQLite, upToV6 MySQL)

…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
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