changeset 684:2abb398cd9a7 beta

upgrade-db command dummy
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 13 Nov 2010 02:33:50 +0100
parents 341beaa9edba
children 87943675813a
files rhodecode/lib/utils.py
diffstat 1 files changed, 27 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/utils.py	Sat Nov 13 02:29:46 2010 +0100
+++ b/rhodecode/lib/utils.py	Sat Nov 13 02:33:50 2010 +0100
@@ -32,8 +32,8 @@
 from rhodecode.model.repo import RepoModel
 from rhodecode.model.user import UserModel
 from vcs.backends.base import BaseChangeset
-from vcs.backends.git import GitRepository
-from vcs.backends.hg import MercurialRepository
+from paste.script import command
+import ConfigParser
 from vcs.utils.lazy import LazyProperty
 import traceback
 import datetime
@@ -517,3 +517,28 @@
     tar = tarfile.open(jn(cur_dir, 'tests', "vcs_test.tar.gz"))
     tar.extractall('/tmp')
     tar.close()
+
+class UpgradeDb(command.Command):
+    """Command used for paster to upgrade our database to newer version
+    """
+
+    max_args = 1
+    min_args = 1
+
+    usage = "CONFIG_FILE"
+    summary = "Upgrades current db to newer version given configuration file"
+    group_name = "RhodeCode"
+
+    parser = command.Command.standard_parser(verbose=True)
+
+    parser.add_option('--sql',
+                      action='store_true',
+                      dest='just_sql',
+                      help="Prints upgrade sql for further investigation",
+                      default=False)
+    def command(self):
+        config_name = self.args[0]
+        p = config_name.split('/')
+        root = '.' if len(p) == 1 else '/'.join(p[:-1])
+        config = ConfigParser.ConfigParser({'here':root})
+        config.read(config_name)