##// END OF EJS Templates
rc-upgrade-db: added option to force update a version.
marcink -
r3406:1afbe459 default
parent child
Show More
@@ -156,8 +156,11 class DbManage(object):
156 'rhodecode/lib/dbmigrate')
156 'rhodecode/lib/dbmigrate')
157 db_uri = self.dburi
157 db_uri = self.dburi
158
158
159 if version:
160 DbMigrateVersion.set_version(version)
161
159 try:
162 try:
160 curr_version = version or api.db_version(db_uri, repository_path)
163 curr_version = api.db_version(db_uri, repository_path)
161 msg = ('Found current database db_uri under version '
164 msg = ('Found current database db_uri under version '
162 'control with version {}'.format(curr_version))
165 'control with version {}'.format(curr_version))
163
166
@@ -25,6 +25,7 import pyramid.paster
25
25
26 from rhodecode.lib.pyramid_utils import bootstrap
26 from rhodecode.lib.pyramid_utils import bootstrap
27 from rhodecode.lib.db_manage import DbManage
27 from rhodecode.lib.db_manage import DbManage
28 from rhodecode.lib.utils2 import safe_int
28
29
29 log = logging.getLogger(__name__)
30 log = logging.getLogger(__name__)
30
31
@@ -33,11 +34,13 log = logging.getLogger(__name__)
33 @click.argument('ini_path', type=click.Path(exists=True))
34 @click.argument('ini_path', type=click.Path(exists=True))
34 @click.option('--force-yes/--force-no', default=None,
35 @click.option('--force-yes/--force-no', default=None,
35 help="Force yes/no to every question")
36 help="Force yes/no to every question")
36 def main(ini_path, force_yes):
37 @click.option('--force-version', default=None,
37 return command(ini_path, force_yes)
38 help="Force upgrade from version")
39 def main(ini_path, force_yes, force_version):
40 return command(ini_path, force_yes, force_version)
38
41
39
42
40 def command(ini_path, force_yes):
43 def command(ini_path, force_yes, force_version):
41 pyramid.paster.setup_logging(ini_path)
44 pyramid.paster.setup_logging(ini_path)
42
45
43 with bootstrap(ini_path, env={'RC_CMD_UPGRADE_DB': '1'}) as env:
46 with bootstrap(ini_path, env={'RC_CMD_UPGRADE_DB': '1'}) as env:
@@ -49,4 +52,4 def command(ini_path, force_yes):
49 dbmanage = DbManage(
52 dbmanage = DbManage(
50 log_sql=True, dbconf=db_uri, root='.', tests=False,
53 log_sql=True, dbconf=db_uri, root='.', tests=False,
51 cli_args=options)
54 cli_args=options)
52 dbmanage.upgrade()
55 dbmanage.upgrade(version=safe_int(force_version))
General Comments 0
You need to be logged in to leave comments. Login now