-
-
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: Rework index config with generated index names #10589
Conversation
🦋 Changeset detectedLatest commit: 064d001 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 |
Kept to a |
@@ -0,0 +1,31 @@ | |||
--- | |||
"@astrojs/db": patch |
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.
Just to check, this is non-breaking, the old syntax is still supported for now, right?
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.
What will happen to people's existing indices? Will they be dropped and recreated?
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.
Old syntax is supported! And it shouldn't drop and recreate even when refactoring to the new syntax (unless you switch to using generated names of course). We handle everything with a Zod transform that matches the original object format. I'll add a unit test to confirm
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.
I guess what i'm asking is, currently the user can name them whatever they want. For example foobar_index
. But now with the automated index names, is it not going to try to add the new index and not know about the previous index?
I guess you're saying that when you do push, it will see the old index and the new index and drop the old one (assuming it doesn't match) and create a new one?
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.
Update: confirmed there are no migrations when upgrading to the new syntax
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.
@matthewp Yep, it will drop and recreate the indexes if you don't pass a name
option. If you pass a name
to the new indexes that matches the old name, it'll run without any migrations 👍
Changes
This introduces generated index names when passing an array to
indexes
. The object configuration syntax is now deprecated. See changelogdbConfig
with a transformation step to generate index names by table and column namesResolvedDbConfig
type for migration queriesmapObject
utility to remap object values with type safetyTesting
Add tests for new array format, and move old tests to "legacy"
Docs
withastro/docs#7639