FluentDBFluentDB
PostgreSQL errors

PostgreSQL: type "..." does not exist

ERRORSQLSTATE 42704undefined_object
ERROR: type "<name>" does not exist

You referenced a data type Postgres does not know. Usually the type is a custom type, enum, or domain that was never created, lives in another schema, or comes from an extension you have not installed.

What this error means

Beyond built-in types, Postgres types can come from CREATE TYPE, CREATE DOMAIN, or extensions like citext and hstore. If the type is missing from every schema on your search_path, this error is raised.

A common case is running code or a restore that expects an extension type before the extension is installed.

How to fix it

01

The type was never created

Create the enum, domain, or composite type it needs.

sql
CREATE TYPE order_status AS ENUM ('pending', 'paid', 'shipped');
02

It comes from an extension

Install the extension that provides the type.

sql
CREATE EXTENSION IF NOT EXISTS citext;
03

It is in another schema

Schema-qualify the type, or add its schema to the search_path.

sql
SET search_path TO app, public;

How to avoid it next time

  • Create types and extensions in your migrations before any code references them.
  • Schema-qualify types shared across schemas so their location is unambiguous.

Frequently asked questions

Why does citext or hstore fail as a type?

They are provided by extensions. Run CREATE EXTENSION citext; (or hstore) before using the type.

How do I list defined types?

Run \dT in psql to see user-defined types in the current schemas.

Stop struggling with SQL

Use FluentDB, the AI database client for macOS.