diff --git a/src/alpm_config.vala b/src/alpm_config.vala
index ab7279b3b3d8e53d36d09bd2d9df39a07faf6ac2..e4c6cd67ea043ea0d33d70c67b0643db6b4f9f3d 100644
--- a/src/alpm_config.vala
+++ b/src/alpm_config.vala
@@ -137,6 +137,14 @@ class AlpmConfig {
 	public Alpm.Handle? get_handle () {
 		Alpm.Errno error;
 		Alpm.Handle? handle = new Alpm.Handle (rootdir, dbpath, out error);
+		if (error == Alpm.Errno.DB_VERSION) {
+			try {
+				Process.spawn_command_line_sync ("pacman-db-upgrade", null, null, null);
+			} catch (SpawnError e) {
+				stdout.printf ("Error: %s\n", e.message);
+			}
+			handle = new Alpm.Handle (rootdir, dbpath, out error);
+		}
 		if (handle == null) {
 			stderr.printf ("Failed to initialize alpm library" + " (%s)\n".printf (Alpm.strerror (error)));
 			return null;