Skip to content
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

Support for custom and advanced indexes #453

Open
aliendrew opened this issue Aug 3, 2023 · 0 comments
Open

Support for custom and advanced indexes #453

aliendrew opened this issue Aug 3, 2023 · 0 comments

Comments

@aliendrew
Copy link

Is your feature request related to a problem? Please describe.
Currently there's no option to add custom indexes as described in Contracts repository:
https://github.com/metarhia/Contracts/blob/c6e6b1053f30924ea002b67a4a2fff30a1a7fe18/doc/Database.md

Describe the solution you'd like
Support for custom index described as a string:

({
  name: 'string',
  location: 'point',

  akName: { index: 'gin (name gin_trgm_ops)' },
  akLocation: { index: 'gist (location)' },
});

However, even this implementation is unable to fully cover CREATE INDEX command. For example, such options as [CONCURRENTLY ], [ IF NOT EXISTS ] and [ ONLY ] are not supported with this implementation.

Describe alternatives you've considered
An alternative would be to use object fields to describe index and make it completely compatible with sql CREATE INDEX command:
https://www.postgresql.org/docs/current/sql-createindex.html
For instance:

{
  index: {
    concurrently: false,
    notExists: false,
    method: 'btree',
    fields: [
      { expression: 'field1', collate: 'de_DE', order: 'DESC', nulls: 'LAST' },
      { expression: '(lower(field2))', order: 'ASC', nulls: 'FIRST' },
    ],
    include: ['field3', 'field4'],
    with: '',
    tablespace: '',
    where: '',
  },
}
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

No branches or pull requests

1 participant