-
Notifications
You must be signed in to change notification settings - Fork 1.2k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Syntax to specify indexes and unique constraints (ie.isIndexed
, isUnique
) across multiple fields
#2304
Comments
I am supportive of multi-field indexes |
It looks like there hasn't been any activity here in over 6 months. Sorry about that! We've flagged this issue for special attention. It wil be manually reviewed by maintainers, not automatically closed. If you have any additional information please leave us a comment. It really helps! Thank you for you contribution. :) |
anyone looking at this there is possibility to have multi field indexes for mongodb. see this #3025 |
It looks like there hasn't been any activity here in over 6 months. Sorry about that! We've flagged this issue for special attention. It wil be manually reviewed by maintainers, not automatically closed. If you have any additional information please leave us a comment. It really helps! Thank you for you contribution. :) |
Are multi-field indexes available now? |
This has become critical for me. I have a many-many relationship, and I wanted to add a 'refcount' column to it. So as suggested in prisma doc, I made the table explicit (but in Keystone then). I then needed to use upsert : if create fails, I need to increase 'refcount'. I can do all that in prisma, as long as I have a primary key @id[a, b]. But since I can't have this or a unique key on 2 columns, I can't use Prisma's upsert, because it works only on unique field selectors. Therefore, I made this in raw SQL, with Postgres "ON CONFLICT ...", after adding the unique key on [a, b] manually. But now, each time I start Keystone, Prisma fails to start because I have this unique key in the table but not in Prisma's schema. So I can't auto-restart the server, etc. I'm only left with doing manual migrations so Prisma doesn't delete my table, and I have to remove every reference to this table from Keystone and lose the GraphQL query ability. It is really CRITICAL for me to have this feature, multi-columns primary keys and unique indices. It is already well supported by Prisma. Thanks. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Most field types support the
isIndexed
andisUnique
config options. Behind the scenes these options creates an index (with or without an additional unique constraint) on the field at the database level. There's currently no way (within Keystone) to configure indexes that include more than one field; app developers are left to create the required indexes manually.Any syntax developed here should allow for:
asc
ordesc
)Partial indexes and some basic full-text stuff would also be super great.
Syntax
Maybe something like...
This still only exposes a small subset of the indexing options afforded by most DBs. Anything requiring non-default collations, other methods (eg.
hash
), fill factor, etc. would require manual creation.Upserts
In addition to being generally handy, knowing about multi-field indexes might allow us to (better) support
upsert
operations. There are some notes on this in the issue #182.Implementation Notes
Currently, the
isIndexed
andisUnique
options are handled by individual field types. From one perspective, this makes a lot of sense -- only fields types know enough about what they store and how they store it to make decisions about what "being indexed" means, and some field types (eg.Checkbox
) don't support them at all. Once you get into multi-field indexes though, some of the responsibility needs to picked up by the database adapter though. I'm not clear on what kind of refactoring this would require.Related
This stuff is probably related to: #319, #343, #1654 and #182.
The text was updated successfully, but these errors were encountered: