Exclude objects the project does not own
A dump from a managed database holds objects your application does not
author: a migration runner’s history table (Diesel’s
__diesel_schema_migrations), extensions the hosting provider installs
(pg_stat_statements), schemas it creates (auth, vault). Declare them
once in retrofit.toml, and every command that reads SQL sets them aside
before it reads the rest.
Project exclusions is the reference: what each command prints for an entry, and each refusal.
Declare an object you do not own
Add one [[exclude]] entry per object to retrofit.toml:
[[exclude]]
kind = "table"
schema = "public"
name = "__diesel_schema_migrations"
reason = "Diesel migration history; written by the migration runner"
[[exclude]]
kind = "extension"
name = "pg_stat_statements"
reason = "installed by the hosting provider"
kind is table, extension or schema. name and schema are the
stored identifiers exactly as the catalog holds them: case-sensitive,
never quoted, no globs. Every entry needs a reason.
import, identify, drift, migrate --from-dump and data capture
remove every statement an entry owns before they read the input. The
entries are read from the retrofit.toml that locates your oplogs, and
no flag adds to them or overrides them. A run with -f outside a
project applies none.
When identify or drift reports an object you do not own as a
difference, declare it here.
Check what was set aside
Each command prints one line on stderr per entry it applied, naming the
object, the number of statements it removed and your reason. The
entries that owned nothing in a run are named together on one line, so
check that line for a misspelt name: its object stays in the input.
When a kept statement depends on an excluded object
A statement you keep may depend on an object you excluded: a foreign key
into an excluded table, a view reading it, a call to an excluded
extension’s functions. The command then exits non-zero before it writes
anything, and names the statement and the entry. When the statement
belongs to a table, an extension or a schema you do not own either, add
that object to [[exclude]] so the statement leaves with the entry. A
view or a function cannot be an entry: remove the entry, or remove the
statement from the input.
An entry naming an object your oplog already holds exits non-zero the same way. The oplog is never edited to honour an entry.
Related
retrofit drift: what drift does with the entries.retrofit migrate: the entries and a dumpmigrate --from-dumpreads.- Import existing SQL: bootstrap an oplog from a dump.
- Work with several schemas: register the schemas your project does own.