MySQL declares an
ENUMinline, right on the column definition. PostgreSQL has no inline enum — youCREATE TYPEa named enum type first, then use it as a column type. pgloader bridges this automatically, with no casting rule required for the default case.
What pgloader’s own docs say
Straight from pgloader’s MySQL reference documentation:
Enum types are declared inline in MySQL and separately with a
CREATE TYPEcommand in PostgreSQL, so each column of Enum Type is converted to a type named after the table and column names defined with the same labels in the same order.
In other words: for a MySQL column like
CREATE TABLE orders (
id int PRIMARY KEY,
status ENUM('pending', 'shipped', 'delivered')
);
pgloader automatically issues the PostgreSQL equivalent, naming the new type after the table and column it came from:
CREATE TYPE orders_status AS ENUM ('pending', 'shipped', 'delivered');
CREATE TABLE orders (
id int PRIMARY KEY,
status orders_status
);
Same labels, same order, no manual CREATE TYPE statement to write by
hand, and no casting rule needed in your .load file for the common case
— this is pgloader’s default behavior, not something you opt into.
When you’d still write a rule
If you want a specific type name instead of the auto-generated
tablename_columnname pattern, or you’re consolidating the same set of
labels used across several MySQL columns into one shared PostgreSQL enum
type, that’s where a custom CAST rule comes in — the same casting-rules
mechanism covered in the Casting Rules & Schema Mapping module
of the full course. For the default case, though, there’s nothing to
configure.