OptimumCredo.Check.Warning.RawSqlIndexInMigration (OptimumCredo v0.5.0)
View SourceBasics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of low and works with any version of Elixir.
Explanation
Prefer the migration DSL for indexes over raw SQL in execute/1.
Bad
execute("CREATE UNIQUE INDEX users_email_index ON users (email)")Good
create unique_index(:users, [:email])CREATE INDEX CONCURRENTLY and expression indexes are accepted by default.
Check-Specific Parameters
Use the following parameters to configure this check:
:allow_concurrent
Accept CREATE INDEX CONCURRENTLY.
This parameter defaults to true.
:allow_expression_indexes
Accept indexes over expressions such as lower(email).
This parameter defaults to true.
:ignore_files
Path suffixes or regexes for migrations to skip.
This parameter defaults to [].
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.