All rules

Schema

postgresql/consistent-timestamptz

Enforce a consistent stance on `timestamptz` vs `timestamp` for wall-clock columns.

  • Type suggestion
  • Recommended warn
  • Fixable no

Why this matters

Two valid stances exist: (a) require `timestamptz` so the database anchors everything to UTC at storage time and converts on read (avoiding the timezone-naive trap of `timestamp`), or (b) forbid `timestamptz` so the type is consistent across a project that treats every timestamp as UTC at the application layer and doesn't want implicit per-session `TimeZone` conversions. Pick one with the `style` option.

Examples

Incorrect

Incorrect
CREATE TABLE t (created_at TIMESTAMP);

Correct

Correct
CREATE TABLE t (created_at TIMESTAMPTZ);
Correct
CREATE TABLE t (created_at TIMESTAMP WITH TIME ZONE);

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-timestamptz": [
        "warn",
        {
          style: "always",
        },
      ],
    },
  },
];

Options

style "always" | "never" default: "always"
Which stance to enforce. `always` (default) requires `timestamptz` over `timestamp`. `never` requires `timestamp` over `timestamptz` — useful when the application treats every value as UTC and doesn't want implicit per-session conversions.
Try this rule

Edit the SQL — only consistent-timestamptz 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-timestamptz — 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