Open
Conversation
…of alias handling for views in `from` clause
…to effect-cache-fix
…object mode (@Sukairo-02 commit)
…tentional imports
Removed not valid test
…ded some more tests on multiple mysql dbs
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.
D1 up-migrations
1. An additional file
migrator.internal.tswas added todrizzle.orm/src/sqlite-proxyThis file exports a
migrateInternalfunction, which is used bydrizzle-orm/src/sqlite-proxy/migratoranddrizzle-kit/src/cli/connections (connectToSQLite)Drizzle-Kit reuses the sqlite-proxy migrator for its migrate command, since it communicates with the D1 database over HTTP. However, the
up-migrationstep in the sqlite-proxy migrator used a transaction only, which is unavailable in D1. Two approaches were considered:a. fully copy the sqlite-proxy migrator into a
d1/migrator-proxy.tsfileb. introduce an optional
modeflag on the sqlite-proxy migrate function so that the migrator knows how to execute statementsChose option
bTo avoid changing the public API (since the mode flag is only needed internally by drizzle-kit), all core logic was extracted into
migrateInternalinsidemigrator.internal.ts. The public-facing API remains unchanged. Drizzle-Kit can now explicitly pass the mode flag internallyflowchart TD A["sqlite-proxy/migrator.ts migrate(db, ...)"] -->|"call with explicit 'transaction' mode migrateInternal(db, ..., 'mode': transaction)"| B B["sqlite-proxy/migrator.internal.ts migrateInternal(db, ..., 'mode': transaction | batch)"] C[drizzle-kit migrate command] --> |"call with explicit 'batch' mode migrateInternal(db, ..., 'mode': 'batch')"| BDrizzle-Kit and D1
As said above - Drizzle Kit uses the sqlite-proxy driver under the hood
A function called
remoteMigrateBatchCallbackwas added indrizzle-kit/src/cli/connections.ts(connectToSQLite function) to support compatibility with the sqlite-proxy batch method. This enables the use of batch operations within the migrator when running drizzle-kit migrate2 D1 Migrator
The D1 migrator itself (
drizzle-orm/src/d1/migrator.ts) was also updated to use batch operationsSome research was made to find out whether
migrate()could be executed inside a Worker. No viable solution was found as Cloudflare Workers do not have access to a persistent filesystem, making it impossible to use migrate() inside of a Worker. This might work if migrations were bundled similarly to how it is done inExpo SQLite, but tests are neededHowever, for local development it is possible to use
Miniflare. Therefore,migrate()was updated to support Miniflare casesOther
Some issues were fixed