Skip to content

Conversation

@john-royal
Copy link
Collaborator

@john-royal john-royal commented Dec 11, 2025

Specify importDir on D1Database to specify SQL files to import. Uses the D1 import API, which it turns out we already had implemented for database cloning.

Notes:

  • Imports are run as migrations on the local database. To fix the statement-splitting problem, I split by semicolons at the end of new lines - not 100% bulletproof but should be more than good enough given what an import file will typically look like.
  • I updated the listMigrationsFiles function:
    • rename to listSqlFiles since it's also used for imports
    • mark the sql property as non-enumerable (keeps it out of state, to prevent state store issues caused by massive files)
    • include a hash property (so we can still accurately diff props based on file contents)

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 11, 2025

Open in StackBlitz

npm i https://pkg.pr.new/alchemy-run/alchemy@1254

commit: 0af344d

@github-actions
Copy link

github-actions bot commented Dec 11, 2025

🚀 Website Preview Deployed

Your website preview is ready!

Preview URL: https://04ce7ee3-alchemy-website.alchemy-run.workers.dev

This preview was built from commit a1d768c


🤖 This comment will be updated automatically when you push new commits to this PR.

@john-royal john-royal marked this pull request as ready for review December 11, 2025 20:45
@sam-goodwin
Copy link
Collaborator

I split by semicolons at the end of new lines - not 100% bulletproof but should be more than good enough given what an import file will typically look like.

Won't that not work for a drizzle migration script which adds a comment?

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.

3 participants