All rules

Performance

postgresql/consistent-create-index-concurrently

Enforce a consistent stance on `CONCURRENTLY` for `CREATE INDEX`.

  • Type suggestion
  • Recommended off
  • Fixable no

Why this matters

Two valid stances exist: (a) always use `CREATE INDEX CONCURRENTLY` so the build avoids the table-level `SHARE` lock and doesn't block writers, or (b) never use it so each `CREATE INDEX` can run inside a migration transaction. Pick one with the `style` option. Off by default because the right answer depends on your migration framework.

Examples

Incorrect

Incorrect
CREATE INDEX idx_users_email ON users (email);

Correct

Correct
CREATE INDEX CONCURRENTLY idx_users_email ON users (email);

Configure it

// eslint.config.js
import postgresql from "eslint-plugin-postgresql";

export default [
  {
    files: ["**/*.sql"],
    languageOptions: {
      parser: postgresql.configs.recommended.languageOptions.parser,
    },
    plugins: { postgresql },
    rules: {
      "postgresql/consistent-create-index-concurrently": [
        "warn",
        {
          style: "always",
        },
      ],
    },
  },
];

Options

style "always" | "never" default: "always"
Which stance to enforce. `always` (default) requires `CONCURRENTLY` so the build doesn't block writers. `never` forbids it so each `CREATE INDEX` can run inside a migration transaction.
Try this rule

Edit the SQL — only consistent-create-index-concurrently is enabled.

Pre-filled with the first incorrect example. Toggle off in the rule shelf to see how the diagnostic disappears.

0 errors 0 warnings parse 0ms · rules 0ms
Diagnostics

No issues found.

2 rules enabled.

Rule under test consistent-create-index-concurrently — plus no-syntax-error as a safety net.
eslint-plugin-postgresql

An ESLint plugin that lints .sql files with real PostgreSQL grammar and a curated set of best-practice rules.

© 2026 eslint-plugin-postgresql contributors Built on libpg-query · PostgreSQL 17