Show More
@@ -60,14 +60,14 b' def notify(msg):' | |||||
60 | class DbManage(object): |
|
60 | class DbManage(object): | |
61 |
|
61 | |||
62 | def __init__(self, log_sql, dbconf, root, tests=False, |
|
62 | def __init__(self, log_sql, dbconf, root, tests=False, | |
63 |
SESSION=None, cli_args= |
|
63 | SESSION=None, cli_args=None): | |
64 | self.dbname = dbconf.split('/')[-1] |
|
64 | self.dbname = dbconf.split('/')[-1] | |
65 | self.tests = tests |
|
65 | self.tests = tests | |
66 | self.root = root |
|
66 | self.root = root | |
67 | self.dburi = dbconf |
|
67 | self.dburi = dbconf | |
68 | self.log_sql = log_sql |
|
68 | self.log_sql = log_sql | |
69 | self.db_exists = False |
|
69 | self.db_exists = False | |
70 | self.cli_args = cli_args |
|
70 | self.cli_args = cli_args or {} | |
71 | self.init_db(SESSION=SESSION) |
|
71 | self.init_db(SESSION=SESSION) | |
72 | self.ask_ok = self.get_ask_ok_func(self.cli_args.get('force_ask')) |
|
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 | import logging |
|
25 | import logging | |
26 |
|
26 | |||
27 |
from rhodecode.lib.utils import BasePasterCommand, Command |
|
27 | from rhodecode.lib.utils import BasePasterCommand, Command | |
28 | from rhodecode.lib.db_manage import DbManage |
|
|||
29 |
|
28 | |||
30 | log = logging.getLogger(__name__) |
|
29 | log = logging.getLogger(__name__) | |
31 |
|
30 | |||
@@ -44,15 +43,9 b' class UpgradeDb(BasePasterCommand):' | |||||
44 | parser = Command.standard_parser(verbose=True) |
|
43 | parser = Command.standard_parser(verbose=True) | |
45 |
|
44 | |||
46 | def command(self): |
|
45 | def command(self): | |
47 | from pylons import config |
|
46 | from rhodecode.lib.rc_commands import upgrade_db | |
48 | add_cache(config) |
|
47 | upgrade_db.command( | |
49 | self.logging_file_config(self.path_to_ini_file) |
|
48 | self.path_to_ini_file, self.options.__dict__.get('force_ask')) | |
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() |
|
|||
56 |
|
49 | |||
57 | def update_parser(self): |
|
50 | def update_parser(self): | |
58 | self.parser.add_option('--sql', |
|
51 | self.parser.add_option('--sql', |
@@ -18,18 +18,35 b'' | |||||
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 |
|
20 | |||
|
21 | import logging | |||
|
22 | ||||
21 | import click |
|
23 | import click | |
|
24 | import pyramid.paster | |||
22 |
|
25 | |||
23 | from rhodecode.lib.pyramid_utils import bootstrap |
|
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 | @click.command() |
|
32 | @click.command() | |
28 | @click.argument('ini_path', type=click.Path(exists=True)) |
|
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 | pyramid.paster.setup_logging(ini_path) |
|
41 | pyramid.paster.setup_logging(ini_path) | |
31 |
|
42 | |||
32 | with bootstrap(ini_path) as env: |
|
43 | with bootstrap(ini_path) as env: | |
33 | print(env['request'].application_url) |
|
44 | config = env['registry'].settings | |
34 |
|
45 | db_uri = config['sqlalchemy.db1.url'] | ||
35 |
|
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