Atlas generates ALTER TYPE
statements without schema qualification, causing migrations to fail.
Expected:
ALTER TYPE "myschema"."my_type" ADD ATTRIBUTE "field_b" text;
Actual:
ALTER TYPE "my_type" ADD ATTRIBUTE "field_b" text;
PostgreSQL cannot find the type without schema qualification when it's not in the search_path.
- Atlas CLI - https://atlasgo.io/getting-started
- Docker - For PostgreSQL container
make # Cleans, reproduces bug, and verifies it
The bug is in migrations/*_add_field.sql
- check it yourself!
Initial migration (already committed in migrations/*_initial.sql
):
-- Generated by Atlas - correct schema qualification
CREATE SCHEMA "myschema";
CREATE TYPE "myschema"."my_type" AS ("field_a" text); -- ✓ Only field_a
Current schema (schemas/schema.sql
- already has field_b added):
create schema myschema;
create type myschema.my_type as (
field_a text,
field_b text -- Added (this triggers the bug)
);
atlas migrate diff --config file://atlas/atlas.hcl --env local add_field
# or: make reproduce
This creates migrations/*_add_field.sql
:
ALTER TYPE "my_type" ADD ATTRIBUTE "field_b" text; -- ✗ Missing schema!
Bug confirmed: Should be ALTER TYPE "myschema"."my_type"
Check the file yourself:
cat migrations/*_add_field.sql
make clean
Why it fails:
- PostgreSQL cannot find type without schema when it's not in
search_path
- Inconsistent: Atlas correctly qualifies
CREATE TYPE
but notALTER TYPE
- Can modify wrong type if same name exists in multiple schemas
Environment:
- Atlas: v0.37.1-8ee9008-canary (tested 2025-10-06)
- PostgreSQL: 15 (via built-in Docker image)
Workaround: Manually add schema qualification to generated migrations
Project: https://github.com/pgflow-dev/pgflow