Show More
@@ -60,14 +60,14 b' def notify(msg):' | |||
|
60 | 60 | class DbManage(object): |
|
61 | 61 | |
|
62 | 62 | def __init__(self, log_sql, dbconf, root, tests=False, |
|
63 |
SESSION=None, cli_args= |
|
|
63 | SESSION=None, cli_args=None): | |
|
64 | 64 | self.dbname = dbconf.split('/')[-1] |
|
65 | 65 | self.tests = tests |
|
66 | 66 | self.root = root |
|
67 | 67 | self.dburi = dbconf |
|
68 | 68 | self.log_sql = log_sql |
|
69 | 69 | self.db_exists = False |
|
70 | self.cli_args = cli_args | |
|
70 | self.cli_args = cli_args or {} | |
|
71 | 71 | self.init_db(SESSION=SESSION) |
|
72 | 72 | self.ask_ok = self.get_ask_ok_func(self.cli_args.get('force_ask')) |
|
73 | 73 |
@@ -24,8 +24,7 b' Database migration modules' | |||
|
24 | 24 | |
|
25 | 25 | import logging |
|
26 | 26 | |
|
27 |
from rhodecode.lib.utils import BasePasterCommand, Command |
|
|
28 | from rhodecode.lib.db_manage import DbManage | |
|
27 | from rhodecode.lib.utils import BasePasterCommand, Command | |
|
29 | 28 | |
|
30 | 29 | log = logging.getLogger(__name__) |
|
31 | 30 | |
@@ -44,15 +43,9 b' class UpgradeDb(BasePasterCommand):' | |||
|
44 | 43 | parser = Command.standard_parser(verbose=True) |
|
45 | 44 | |
|
46 | 45 | def command(self): |
|
47 | from pylons import config | |
|
48 | add_cache(config) | |
|
49 | self.logging_file_config(self.path_to_ini_file) | |
|
50 | ||
|
51 | db_uri = config['sqlalchemy.db1.url'] | |
|
52 | dbmanage = DbManage(log_sql=True, dbconf=db_uri, | |
|
53 | root=config['here'], tests=False, | |
|
54 | cli_args=self.options.__dict__) | |
|
55 | dbmanage.upgrade() | |
|
46 | from rhodecode.lib.rc_commands import upgrade_db | |
|
47 | upgrade_db.command( | |
|
48 | self.path_to_ini_file, self.options.__dict__.get('force_ask')) | |
|
56 | 49 | |
|
57 | 50 | def update_parser(self): |
|
58 | 51 | self.parser.add_option('--sql', |
@@ -18,18 +18,35 b'' | |||
|
18 | 18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | |
|
21 | import logging | |
|
22 | ||
|
21 | 23 | import click |
|
24 | import pyramid.paster | |
|
22 | 25 | |
|
23 | 26 | from rhodecode.lib.pyramid_utils import bootstrap |
|
24 | import pyramid.paster | |
|
27 | from rhodecode.lib.db_manage import DbManage | |
|
28 | ||
|
29 | log = logging.getLogger(__name__) | |
|
25 | 30 | |
|
26 | 31 | |
|
27 | 32 | @click.command() |
|
28 | 33 | @click.argument('ini_path', type=click.Path(exists=True)) |
|
29 | def main(ini_path): | |
|
34 | @click.option('--force-yes/--force-no', default=None, | |
|
35 | help="Force yes/no to every question") | |
|
36 | def main(ini_path, force_yes): | |
|
37 | return command(ini_path, force_yes) | |
|
38 | ||
|
39 | ||
|
40 | def command(ini_path, force_yes): | |
|
30 | 41 | pyramid.paster.setup_logging(ini_path) |
|
31 | 42 | |
|
32 | 43 | with bootstrap(ini_path) as env: |
|
33 | print(env['request'].application_url) | |
|
34 | ||
|
35 | ||
|
44 | config = env['registry'].settings | |
|
45 | db_uri = config['sqlalchemy.db1.url'] | |
|
46 | options = {} | |
|
47 | if force_yes is not None: | |
|
48 | options['force_ask'] = force_yes | |
|
49 | dbmanage = DbManage( | |
|
50 | log_sql=True, dbconf=db_uri, root='.', tests=False, | |
|
51 | cli_args=options) | |
|
52 | dbmanage.upgrade() |
General Comments 0
You need to be logged in to leave comments.
Login now