Show More
@@ -1,75 +1,78 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | # Copyright (C) 2010-2016 RhodeCode GmbH |
|
4 | 4 | # |
|
5 | 5 | # This program is free software: you can redistribute it and/or modify |
|
6 | 6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
7 | 7 | # (only), as published by the Free Software Foundation. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU Affero General Public License |
|
15 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | 16 | # |
|
17 | 17 | # This program is dual-licensed. If you wish to learn more about the |
|
18 | 18 | # AppEnlight Enterprise Edition, including its added features, Support |
|
19 | 19 | # services, and proprietary license terms, please see |
|
20 | 20 | # https://rhodecode.com/licenses/ |
|
21 | 21 | |
|
22 | 22 | import argparse |
|
23 | 23 | import logging |
|
24 | 24 | import sys |
|
25 | 25 | |
|
26 | 26 | from alembic.config import Config |
|
27 | 27 | from alembic import command |
|
28 | 28 | from pyramid.paster import setup_logging, bootstrap |
|
29 | 29 | from pyramid.threadlocal import get_current_registry, get_current_request |
|
30 | 30 | |
|
31 | 31 | from appenlight.lib import get_callable |
|
32 | 32 | from appenlight.models.services.config import ConfigService |
|
33 | 33 | |
|
34 | 34 | log = logging.getLogger(__name__) |
|
35 | 35 | |
|
36 | 36 | |
|
37 | 37 | def main(argv=sys.argv): |
|
38 | 38 | parser = argparse.ArgumentParser( |
|
39 | 39 | description='Migrate AppEnlight database to latest version', |
|
40 | 40 | add_help=False) |
|
41 | 41 | parser.add_argument('-c', '--config', required=True, |
|
42 | 42 | help='Configuration ini file of application') |
|
43 | 43 | args = parser.parse_args() |
|
44 | 44 | config_uri = args.config |
|
45 | 45 | |
|
46 | 46 | setup_logging(config_uri) |
|
47 | 47 | bootstrap(config_uri) |
|
48 | 48 | registry = get_current_registry() |
|
49 | 49 | alembic_cfg = Config() |
|
50 | alembic_cfg.set_main_option("sqlalchemy.echo", 'true') | |
|
50 | 51 | alembic_cfg.set_main_option("script_location", |
|
51 | 52 | "ziggurat_foundations:migrations") |
|
52 | 53 | alembic_cfg.set_main_option("sqlalchemy.url", |
|
53 | 54 | registry.settings["sqlalchemy.url"]) |
|
54 | 55 | command.upgrade(alembic_cfg, "head") |
|
55 | 56 | alembic_cfg = Config() |
|
57 | alembic_cfg.set_main_option("sqlalchemy.echo", 'true') | |
|
56 | 58 | alembic_cfg.set_main_option("script_location", "appenlight:migrations") |
|
57 | 59 | alembic_cfg.set_main_option("sqlalchemy.url", |
|
58 | 60 | registry.settings["sqlalchemy.url"]) |
|
59 | 61 | command.upgrade(alembic_cfg, "head") |
|
60 | 62 | |
|
61 | 63 | for plugin_name, config in registry.appenlight_plugins.items(): |
|
62 | 64 | if config['sqlalchemy_migrations']: |
|
63 | 65 | alembic_cfg = Config() |
|
64 | 66 | alembic_cfg.set_main_option("script_location", |
|
65 | 67 | config['sqlalchemy_migrations']) |
|
66 | 68 | alembic_cfg.set_main_option("sqlalchemy.url", |
|
67 | 69 | registry.settings["sqlalchemy.url"]) |
|
70 | alembic_cfg.set_main_option("sqlalchemy.echo", 'true') | |
|
68 | 71 | command.upgrade(alembic_cfg, "head") |
|
69 | 72 | |
|
70 | 73 | with get_current_request().tm: |
|
71 | 74 | ConfigService.setup_default_values() |
|
72 | 75 | |
|
73 | 76 | for plugin_name, config in registry.appenlight_plugins.items(): |
|
74 | 77 | if config['default_values_setter']: |
|
75 | 78 | get_callable(config['default_values_setter'])() |
General Comments 0
You need to be logged in to leave comments.
Login now