Multi-File Schemas
Organize your schema across multiple files using directories or glob patterns.
Directories
Section titled “Directories”# Load all SQL files from a directory (recursive)pgmold apply -s sql:./schema/ -d postgres://localhost/mydbGlob patterns
Section titled “Glob patterns”pgmold apply -s "sql:schema/**/*.sql" -d postgres://localhost/mydbMultiple sources
Section titled “Multiple sources”pgmold apply -s sql:types.sql -s "sql:tables/*.sql" -d postgres://localhost/mydbRecommended directory structure
Section titled “Recommended directory structure”schema/├── enums.sql # CREATE TYPE statements├── tables/│ ├── users.sql # users table + indexes│ └── posts.sql # posts table + foreign keys└── functions/ └── triggers.sql # stored proceduresDuplicate definitions
Section titled “Duplicate definitions”If the same object is defined in multiple files, pgmold produces an error with the file locations of both definitions.