Skip to content

Multi-File Schemas

Organize your schema across multiple files using directories or glob patterns.

Terminal window
# Load all SQL files from a directory (recursive)
pgmold apply -s sql:./schema/ -d postgres://localhost/mydb
Terminal window
pgmold apply -s "sql:schema/**/*.sql" -d postgres://localhost/mydb
Terminal window
pgmold apply -s sql:types.sql -s "sql:tables/*.sql" -d postgres://localhost/mydb
schema/
├── enums.sql # CREATE TYPE statements
├── tables/
│ ├── users.sql # users table + indexes
│ └── posts.sql # posts table + foreign keys
└── functions/
└── triggers.sql # stored procedures

If the same object is defined in multiple files, pgmold produces an error with the file locations of both definitions.