Repository navigation
Undeclared Collections
Once your collections are declared with collection definitions, the tool can report or remove collections and views that no definition declares, e.g. leftovers from features that were removed.
collections.prune decides what happens to a collection or view in the
database that no definition declares:
collections.prune |
|
|---|---|
off (default) |
Nothing; they aren't listed. |
report |
Listed as keep with a warning. |
drop |
Views are dropped. Collections are dropped only if they're empty; one with documents is kept and reported. The listCollections entry and indexes are recorded in history first. |
collections:
prune: report
ignore: [ "audit_*", "tmp_*" ]- Names matching
collections.ignore. - The state collections (
<stateCollection>and<stateCollection>.*). See What Gets Stored. -
system.*collections. - Anything a declared or kept view depends on, directly or indirectly: a view's source as well as the collections and
views reached through
$lookup,$graphLookup,$unionWithand$facetin its pipeline, following the chain through intermediate views.
These are shown as (undeclared) in plan, status and up.
- Set
prune: reportand runplanto see what's undeclared. - Declare the collections you need, and add the rest to
ignoreor delete them. - Switch to
prune: droponce the report is clean, if you want empty leftovers removed automatically.
up counts a collection's documents again just before dropping it and keeps it if it isn't empty. The count and the
drop are separate commands, though, and the migration lock doesn't stop your application writing, so a document
inserted between them is dropped with the collection. Before using prune: drop, stop anything writing to the
collections it would drop, or add collections that are in use to ignore.
Kevsoft.MigrateMongo ·
NuGet ·
Releases ·
Issues ·
Found a mistake? These pages live in
wiki/ on main; pull requests welcome.
Get started
Migrations
- Writing Migrations
- Transactions
- Recording Results
- Dependency Injection
- Custom Templates
- Adopting an Existing Database
Collections
- Managing Collections
- Indexes
- Search Indexes
- Collection Options
- Validators
- Views
- Undeclared Collections
Deploying
Connecting
Reference
Concepts