schema - manage database schema
Manage database schema operations. The implemented subcommand today is pull.
Pull schema from database
sh
norm schema pull
norm schema pull --target default
norm schema pull -t defaultOptions
--target,-t: Pull schema for a specific target fromnorm.yaml.
What it does
- Requires
sql.engine: postgreson the target (other engines are rejected). - Uses
sql.migrations.connectionfrom the selected target. - Runs
pg_dumpin schema-only mode (includesCOMMENT ONstatements). - Strips pg_dump/psql noise (
SET, session config, psql meta commands). - Parses the full pulled DDL in one pass and reformats every statement with sqlglot.
- Writes the result to
sql.db_schema. - Without
--target, pulls schema for all targets (each must useengine: postgres).
Requirements
- Target
sql.enginemust bepostgres. pg_dumpmust be installed and available inPATH.- Each target must provide
sql.migrations.connectionin config.
Common errors
- Target uses an engine other than
postgres. - Missing
sql.migrations.connection. pg_dumpis not installed.- Invalid connection URL or insufficient DB permissions.
- Pulled SQL cannot be parsed (unsupported or unexpected pg_dump output).