Document Revisions
-
Revisions configuration settings can be managed from the Document Revisions view.
-
Learn more about revisions here.
-
In this page:
Document revisions view
Document Revisions View
-
Document Revisions View
Click to open the Document Revisions view. -
Set Status
Check the selection box to select all configurations.
Click the Set Status dropdown list to Enable or Disable selected configurations.
-
Save
Click after modifying the configuration to apply your changes. -
Revert Revisions
Click to revert the database to its state at a specified point in time.
You can select whether to revert specific collections or revert all collections.
Only documents are reverted. Other entities (such as ongoing tasks) are not modified by this process. -
Enforce Configuration
Click to enforce the revisions configuration.
This operation may delete many revisions irrevocably and require substantial server resources.
Please read carefully the dedicated section. -
Create document defaults
Click to define default configuration that will apply to documents in all collections that don't have a
collection-specific configuration defined. -
Add a collection-specific configuration
Click to create a configuration for a specific collection.
If default settings were defined, the collection-specific configuration will override them for this collection. -
The defined Revisions configuration
Read more below.
Revisions configuration
-
The Revisions configuration can include:
- Default configuration - applies to all document collections.
- Collection-specific configurations - override the default settings for these collections.
-
When no default configuration or collection-specific configurations are defined and enabled,
no revisions will be created for any document. -
When a revision configuration is defined,
its rules are applied to the revisions of a document upon any modification of the document.
Defined Configuration
-
Document Defaults
This is the default revisions configuration that applies to all non-conflicting documents in all collections
that don't have a collection-specific configuration defined.
These settings are optional and can be removed. -
Conflicting Document Defaults
This pre-defined revisions configuration is for conflicting documents only.
When enabled, a revision is created for each conflicting item.
A revision is also created for the conflict resolution document.- The Conflicting Document Defaults configuration cannot be removed.
- You can modify this configuration,
or disable it if not interested in tracking document conflicts using revisions. - When "Document Defaults configuration" is defined, it overrides these conflict defaults.
- When a "Collection-specific configuration" is defined,
it also overrides these conflict defaults for the collection defined.
-
Collections
These are optional collection-specific configurations whose settings override the Document Defaults
and the Conflicting Document Defaults for the collections they are defined for. -
Selection Box
Click to select this configuration.
Selected configurations can be enabled or disabled using the Set status button. -
Configuration Settings
Read more about the available settings in the sections dedicated to defining them below. -
Controls
- Disable/Enable - Click to Enable or Disable the configuration.
- Edit - Click to modify the configuration.
- Remove - Click to remove the configuration.
Define default configuration
Define Default Settings
-
Create document defaults
Click to define default configuration that will apply to non-conflicting documents in all collections
that don't have a collection-specific configuration defined. -
Purge revisions on document delete
Enable if you want document revisions to be deleted when their parent document is deleted. -
Limit # of revisions to keep
Enable to limit the number of revisions that will be kept in the revisions storage per document.
Upon revision creation (when the parent document is modified), if the number of revisions exceeds this limit
then older revisions will be purged (starting from the oldest revision).- Enabling the # of revisions to keep will display the following setting as well:
Enable to limit the number of revisions that RavenDB is allowed to purge per document modification.
This will be the maximum number of revisions that RavenDB will purge per document modification,
even if the number of revisions that pend purging is greater.
Setting this limit can reserve server resources if many revisions pend purging,
by dividing the purging between multiple document modifications.
- Enabling the # of revisions to keep will display the following setting as well:
-
Limit # of revisions to keep By Age
Enable to set a revisions age limit.
Revisions older than the defined retention time will be purged when their parent document is modified.- Enabling the age limit setting will also display the Set # of revisions to delete upon document update
(see above).
- Enabling the age limit setting will also display the Set # of revisions to delete upon document update
-
Click OK to keep these default settings, or Cancel.
Confirming will add the new settings to the revisions configuration Defaults section:
Click Save when done.
Define collection-specific configuration
Define Collection-Specific Configurations
-
Add a collection-specific configuration
Click to define a configuration that applies to a specific collection.
This configuration will override Document Defaults and Conflicting Document Defaults configurations. -
Collection
Select or enter a collection to define a configuration for.
-
Configuration options
These options are similar to those explained above for the default configuration,
the only difference is the configuration scope. -
Click OK to keep the configuration, or Cancel.
Confirming will add the new configuration to the Collections section:
Click Save when done.
Edit conflicting document defaults
- Click the Edit button to edit the default configuration for conflicting documents.
Conflicting Document Defaults
Editing the Conflicting Document Defaults
-
The settings options are similar to those explained above for the default configuration.
-
Note: the Limit # of revisions to keep by age value is set to
45 Days
by default.
This means that revisions created for conflicting documents will start to be purged after 45 days,
whenever their parent documents are modified.
Conflicting documents example:
-
For this example, we created a conflict by replicating into the database a document with an ID similar to that of a local document.
-
Revisions will be created when the documents enter a conflict and when the conflict is resolved.
So in this case, three revisions were created:- when the replicated document arrived and entered a conflict state.
- when the local document entered a conflict state on the arrival of the replicated document.
- when the conflict was resolved by replacing the local document with the replicated one.
In this example, the conflict was resolved by placing the replicated version as the current document. Learn more about conflict resolution here.
-
To see these revisions, open the document's Revisions tab.
The revision state is indicated by:- A red title at the top (i.e. "Conflict revision" or "Resolved revision").
- An icon next to the revision's creation time in the right Properties pane.
- A flag in the revision's
@flags
metadata property (i.e. "Conflicted" or "Resolved").
1. Incoming Document in Conflict
2. Local Document in Conflict
3. Conflict Resolved
Enforce configuration
Enforce Configuration
- The revision configuration rules are usually applied to the revisions of a document when the document is modified.
- Executing Enforce will apply the current revision configuration rules on ALL existing revisions for ALL documents at once.
For collections that have a specific revision configuration:
- The collection-specific configuration will be executed per collection.
- Revisions that pend purging (according to the configuration) will be deleted.
For collections that DON'T have a specific revision configuration:
-
Non-conflicting documents:
- If Document Defaults are defined & enabled, they will be applied.
- If NOT defined, or if disabled, ALL non-conflicting document revisions will be deleted.
-
Conflicting documents:
- If Conflicting Document Defaults are enabled, they will be applied to the conflicting document revisions.
- If disabled, ALL conflicting document revisions will be deleted.
- Large databases may contain numerous revisions pending purging that Enforcing will purge all at once.
Be aware that this operation may require substantial server resources, and time it accordingly. - Revisions that no configuration currently applies to will be deleted.
Make sure your configuration includes the default settings and collection-specific configurations
that will keep the revisions you want to keep intact.