luckyframework / luckyframework/avram

Support creating INDEX with a WHERE

Open
#1,023 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Crystal
Stars
183
Forks
67
PR merge metrics
No merged PRs in 30d

Description

https://github.com/luckyframework/avram/blob/main/src/avram/migrator/create_index_statement.cr

Not sure how this would look, but maybe something like

```crystal
create_index :servers, [:enabled, :kind] where: ServerQuery.new.enabled(true)
# CREATE INDEX ... ON users (enabled, kind)
# WHERE enabled = true
```

The only thing with this is it ties your migrations to `ServerQuery`. If you remove that, then this breaks.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/avram/migrator/create_index_statement.cr and trace how index definitions become SQL. Compare the proposed create_index call with the requested PostgreSQL partial-index output, then resolve how the WHERE condition should be represented without making migrations depend on a removable ServerQuery. Done means the API and generated SQL behavior are defined and covered by appropriate tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
crystal, postgresql
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.