about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2007-08-13T11·37+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2007-08-13T11·37+0000
commit3757ee589f46a401fdacaa2126e6bf4902eee23d (patch)
treedd9580bf95c8c9e59c7a025e6a8ac76b0dff98b6 /src
parent59afc1a15cfb90c333aa7423e46be32cc0635b12 (diff)
* Bump the Nix database schema version number; delete the substitutes
  table.

Diffstat (limited to 'src')
-rw-r--r--src/libstore/local-store.cc32
-rw-r--r--src/libstore/local-store.hh6
2 files changed, 33 insertions, 5 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index bffefbaa780e..4378f0ba6101 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -58,6 +58,7 @@ static TableId dbDerivers = 0;
 
 static void upgradeStore07();
 static void upgradeStore09();
+static void upgradeStore11();
 
 
 void checkStoreNotSymlink()
@@ -131,6 +132,8 @@ LocalStore::LocalStore(bool reserveSpace)
             upgradeStore07();
         if (curSchema == 2)
             upgradeStore09();
+        if (curSchema == 3)
+            upgradeStore11();
         writeFile(schemaFN, (format("%1%") % nixSchemaVersion).str());
     }
 }
@@ -1042,10 +1045,10 @@ static void upgradeStore09()
 {
     /* !!! we should disallow concurrent upgrades */
     
-    printMsg(lvlError, "upgrading Nix store to new schema (this may take a while)...");
-
     if (!pathExists(nixDBPath + "/referers")) return;
 
+    printMsg(lvlError, "upgrading Nix store to new schema (this may take a while)...");
+
     Transaction txn(nixDB);
 
     std::cerr << "converting referers to referrers...";
@@ -1082,4 +1085,29 @@ static void upgradeStore09()
 }
 
  
+/* Upgrade from schema 3 (Nix 0.10) to schema 4 (Nix >= 0.11).  The
+   only thing to do here is to delete the substitutes table and get
+   rid of invalid but substitutable references/referrers.  */
+static void upgradeStore11()
+{
+    if (!pathExists(nixDBPath + "/substitutes")) return;
+
+    printMsg(lvlError, "upgrading Nix store to new schema (this may take a while)...");
+
+    Transaction txn(nixDB);
+    TableId dbSubstitutes = nixDB.openTable("substitutes");
+
+    Paths subKeys;
+    nixDB.enumTable(txn, dbSubstitutes, subKeys);
+    for (Paths::iterator i = subKeys.begin(); i != subKeys.end(); ++i) {
+        if (!isValidPathTxn(txn, *i))
+            invalidatePath(txn, *i);
+    }
+    
+    txn.commit();
+    nixDB.closeTable(dbSubstitutes);
+    nixDB.deleteTable("substitutes");
+}
+
+
 }
diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh
index ffcef60716bb..8bd37bc0a3af 100644
--- a/src/libstore/local-store.hh
+++ b/src/libstore/local-store.hh
@@ -13,9 +13,9 @@ class Transaction;
 
 
 /* Nix store and database schema version.  Version 1 (or 0) was Nix <=
-   0.7.  Version 2 was Nix 0.8 and 0.9.  Version 3 is Nix 0.10 and
-   up. */
-const int nixSchemaVersion = 3;
+   0.7.  Version 2 was Nix 0.8 and 0.9.  Version 3 is Nix 0.10.
+   Version 4 is Nix 0.11. */
+const int nixSchemaVersion = 4;
 
 
 extern string drvsLogDir;