FRN313[info]Types
Length-limited text type
varchar(n) and char(n) make a later length change a migration of its own.
Why it's risky in PostgreSQL
In PostgreSQL text, varchar and varchar(n) are stored the same way; the limit only adds a check. Lowering it later rewrites the table, and char(n) pads values with spaces, which surprises comparisons.
Use text, with a CHECK constraint when the limit is a real business rule.
What triggers it, and the safer way
CREATE TABLE users (id bigint, email varchar(255), country char(2));CREATE TABLE users (id bigint, email text, country text CHECK (length(country) = 2));Suppress it when you're sure
Put this comment on the line before the statement. The reason is required and shows in the report.
-- fronelta:allow FRN313 <why this is safe here>Applies to PostgreSQL 14, 15, 16, 17.