--- database.cc 2007-02-19 16:37:46.000000000 -0800 +++ database.fix.cc 2007-02-19 16:57:07.000000000 -0800 @@ -166,9 +166,27 @@ bool have_heights = !res.empty(); // Find out if the manifest tables even exist. + bool have_manifests; fetch(res, one_col, any_rows, query("SELECT name FROM sqlite_master WHERE name LIKE 'manifest%'")); if (res.empty()) + have_manifests = false; + else + { + // If the manifest tables exist, but "manifests" and "manifest_deltas" + // are empty, the database has been changesetified. "manifest_certs" + // is not necessarily empty in this state. + fetch(res, one_col, any_rows, query("SELECT 1 FROM manifests LIMIT 1")); + have_manifests = !res.empty(); + fetch(res, one_col, any_rows, query("SELECT 1 FROM manifest_deltas LIMIT 1")); + have_manifests |= !res.empty(); + + // Could just leave this out? + W(F("your database contains obsolete 'manifest' tables\n" + "(see UPGRADE if you wish to remove them)")); + } + + if (!have_manifests) { // Must have been changesetified and rosterified already. // Or else the database was just created. @@ -180,11 +198,6 @@ } else { - // The manifest tables exist. They should not be empty. (Empty - // manifest tables are deleted during schema migration.) - fetch(res, one_col, any_rows, query("SELECT 1 FROM manifests LIMIT 1")); - I(!res.empty()); - // The rosters and heights tables should be empty. I(!have_rosters && !have_heights);