Skip to content

Commit

Permalink
Fix UserVersion not being copied on datafile upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
lbnascimento committed May 4, 2020
1 parent 17d317e commit a3246ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions LiteDB/Engine/Engine/Upgrade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public static bool Upgrade(string filename, string password = null)

// re-enable auto-checkpoint pragma
engine.Pragma(Pragmas.CHECKPOINT, 1000);

// copy userVersion from old datafile
engine.Pragma("USER_VERSION", (reader as FileReaderV7).UserVersion);
}
}

Expand Down
2 changes: 2 additions & 0 deletions LiteDB/Engine/FileReader/FileReaderV7.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ private BsonDocument ReadPage(uint pageID)
return page;
}

public int UserVersion => (int)_header["userVersion"];

/// <summary>
/// Read extend data block
/// </summary>
Expand Down

1 comment on commit a3246ec

@lbnascimento
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix for #1668

Please sign in to comment.