[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master] dak update-db: fixes to make it work on a fresh install



Also update docs/README.first to advise to run dak update-db
before dak init-db.

Signed-off-by: Raphael Hertzog <hertzog@debian.org>
---
 dak/dakdb/update3.py |    7 ++++++-
 dak/dakdb/update5.py |    1 -
 docs/README.first    |    1 +
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/dak/dakdb/update3.py b/dak/dakdb/update3.py
index eef7d4c..ccd463c 100755
--- a/dak/dakdb/update3.py
+++ b/dak/dakdb/update3.py
@@ -31,7 +31,12 @@ def do_update(self):
 
     try:
         c = self.db.cursor()
-        c.execute("DROP FUNCTION versioncmp(text, text);")
+        try:
+            # This might not exist on a fresh install, so don't fail
+            # needlessly
+            c.execute("DROP FUNCTION versioncmp(text, text);")
+        except:
+            pass
         c.execute("UPDATE config SET value = '3' WHERE name = 'db_revision'")
 
         self.db.commit()
diff --git a/dak/dakdb/update5.py b/dak/dakdb/update5.py
index 1d820de..c89813e 100755
--- a/dak/dakdb/update5.py
+++ b/dak/dakdb/update5.py
@@ -36,7 +36,6 @@ def do_update(self):
     print "Fixing bin_assoc_by_arch view"
     try:
         c = self.db.cursor()
-        c.execute("DROP VIEW bin_assoc_by_arch")
 
         c.execute("""CREATE OR REPLACE VIEW bin_assoc_by_arch AS
         SELECT ba.suite, ba.bin, a.id AS arch
diff --git a/docs/README.first b/docs/README.first
index 9b7aa9c..237d63c 100644
--- a/docs/README.first
+++ b/docs/README.first
@@ -114,6 +114,7 @@ o If you have an existing archive:
      which are needed for this.  After changing all occurences of "projectb"
      to the name of your database (as defined in DB::Name) you can run:
          psql <DB::Name> < init_pool.sql
+   * Run 'dak update-db' to upgrade the database schema.
    * Run 'dak init-db': it will populate your database with the values from
      dak.conf and apt.conf.
    * Run 'psql <DB::Name> < add_constraints.sql'.
-- 
1.5.6.5


Reply to: