-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[db] Fix duplicate calls to recreate tables on startup #10919
Conversation
🦋 Changeset detectedLatest commit: 3b014fd The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Does this mean you can't access things from the Vite part anymore inside seeding? ex: content collections using |
@Princesseuh This is correct, though this was in an inconsistent state before as it did not work with |
I am myself 😅 Both for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving in principle as #NWTWWHB — happy to let you figure out what makes sense w/r/t availability of other virtual modules. Seems nice to do if possible (maybe in a follow-up PR?)
Spotted a bit of unused code which I’m not sure why linting isn’t flagging?
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
145409d
to
1b41be4
Compare
* feat: load seed files with full vite dev server * chore: remove unused export
Changes
This simplifies table initialization by pulling table creation and seeding out of Vite.
Before
astro:db
is loadedastro:db
callsrecreateTables
with top-levelawait
.astro:db
callsseedLocal()
with top-levelawait
. Seed files are loaded as Vite modules.After
astro:db
is loadedrecreateTables
is called.db execute
CLI command.Changes
astro:db:seed
virtual module used for deduping. This dramatically simplifies the DB vite plugin by removing theresolveId
special case.invalidateModule()
call on theastro:db
module, which introduced a race condition when unit testing. This removal means that, if you edit the seed file, we no longer "eagerly" re-seed the database; you still need to refresh your dev server to trigger a seed. We still have eager seeding on dev startup though, so SQLite inspectors should still have a nice experience.seed-local.ts
queries.js
out of runtime and into core. Less code shipped to SSR!Testing
Ensure all tests still pass. Also tested against
@astrojs/web-vitals
to ensure tests pass when this merges.Docs
N/A