diff options
author | Florian Pritz <bluewind@xinu.at> | 2020-10-14 14:24:09 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2020-10-14 14:35:23 +0200 |
commit | 2d251f7bf9a370f1f5c9f2774639349eb9dc3871 (patch) | |
tree | 76d89c82820064bf9c21b1f27961aa9559391c75 /lib | |
parent | 7dd1847bb84719e8a4a6fa47d2efcd9499f52312 (diff) | |
download | App-BorgRestore-2d251f7bf9a370f1f5c9f2774639349eb9dc3871.tar.gz App-BorgRestore-2d251f7bf9a370f1f5c9f2774639349eb9dc3871.tar.xz |
DB: Vacuum database after schema migrations
Migrations may remove data and it doesn't hurt to vacuum afterwards to
reduce the file size.
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/App/BorgRestore/DB.pm | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/App/BorgRestore/DB.pm b/lib/App/BorgRestore/DB.pm index 3d1d6ad..6fb8c7c 100644 --- a/lib/App/BorgRestore/DB.pm +++ b/lib/App/BorgRestore/DB.pm @@ -96,6 +96,7 @@ method _migrate() { $self->{dbh}->do('delete from `files`'); }, }; + my $ran_migrations = 0; for my $target_version (sort { $a <=> $b } keys %$schema) { if ($version < $target_version) { @@ -105,8 +106,13 @@ method _migrate() { $self->_set_db_version($target_version); $self->{dbh}->commit(); $log->debugf("Schema upgrade to version %s complete", $target_version); + $ran_migrations = 1; } } + if ($ran_migrations) { + $log->debug("Vacuuming database"); + $self->{dbh}->do("vacuum"); + } } method _get_db_version() { |