Show More
The requested changes are too big and content was truncated. Show full diff
@@ -0,0 +1,54 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
|
2 | ||||
|
3 | import logging | |||
|
4 | from sqlalchemy import * | |||
|
5 | from sqlalchemy.engine import reflection | |||
|
6 | ||||
|
7 | from alembic.migration import MigrationContext | |||
|
8 | from alembic.operations import Operations | |||
|
9 | ||||
|
10 | from rhodecode.lib.dbmigrate.versions import _reset_base | |||
|
11 | from rhodecode.model import meta, init_model_encryption | |||
|
12 | ||||
|
13 | ||||
|
14 | log = logging.getLogger(__name__) | |||
|
15 | ||||
|
16 | ||||
|
17 | def _get_indexes_list(migrate_engine, table_name): | |||
|
18 | inspector = reflection.Inspector.from_engine(migrate_engine) | |||
|
19 | return inspector.get_indexes(table_name) | |||
|
20 | ||||
|
21 | ||||
|
22 | def upgrade(migrate_engine): | |||
|
23 | """ | |||
|
24 | Upgrade operations go here. | |||
|
25 | Don't create your own engine; bind migrate_engine to your metadata | |||
|
26 | """ | |||
|
27 | _reset_base(migrate_engine) | |||
|
28 | from rhodecode.lib.dbmigrate.schema import db_4_20_0_0 | |||
|
29 | ||||
|
30 | init_model_encryption(db_4_20_0_0) | |||
|
31 | ||||
|
32 | # make sure we re-create api-keys indexes | |||
|
33 | ||||
|
34 | context = MigrationContext.configure(migrate_engine.connect()) | |||
|
35 | op = Operations(context) | |||
|
36 | ||||
|
37 | existing_indexes = _get_indexes_list( | |||
|
38 | migrate_engine, db_4_20_0_0.CacheKey.__tablename__) | |||
|
39 | ||||
|
40 | names = [idx['name'] for idx in existing_indexes] | |||
|
41 | ||||
|
42 | with op.batch_alter_table(db_4_20_0_0.CacheKey.__tablename__) as batch_op: | |||
|
43 | if 'cache_args_idx' not in names: | |||
|
44 | batch_op.create_index( | |||
|
45 | 'cache_args_idx', ['cache_args']) | |||
|
46 | ||||
|
47 | ||||
|
48 | def downgrade(migrate_engine): | |||
|
49 | meta = MetaData() | |||
|
50 | meta.bind = migrate_engine | |||
|
51 | ||||
|
52 | ||||
|
53 | def fixups(models, _SESSION): | |||
|
54 | pass |
@@ -1,60 +1,60 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2010-2020 RhodeCode GmbH |
|
3 | # Copyright (C) 2010-2020 RhodeCode GmbH | |
4 | # |
|
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
7 | # (only), as published by the Free Software Foundation. |
|
7 | # (only), as published by the Free Software Foundation. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License |
|
14 | # You should have received a copy of the GNU Affero General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | # |
|
16 | # | |
17 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
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 os |
|
21 | import os | |
22 | from collections import OrderedDict |
|
22 | from collections import OrderedDict | |
23 |
|
23 | |||
24 | import sys |
|
24 | import sys | |
25 | import platform |
|
25 | import platform | |
26 |
|
26 | |||
27 | VERSION = tuple(open(os.path.join( |
|
27 | VERSION = tuple(open(os.path.join( | |
28 | os.path.dirname(__file__), 'VERSION')).read().split('.')) |
|
28 | os.path.dirname(__file__), 'VERSION')).read().split('.')) | |
29 |
|
29 | |||
30 | BACKENDS = OrderedDict() |
|
30 | BACKENDS = OrderedDict() | |
31 |
|
31 | |||
32 | BACKENDS['hg'] = 'Mercurial repository' |
|
32 | BACKENDS['hg'] = 'Mercurial repository' | |
33 | BACKENDS['git'] = 'Git repository' |
|
33 | BACKENDS['git'] = 'Git repository' | |
34 | BACKENDS['svn'] = 'Subversion repository' |
|
34 | BACKENDS['svn'] = 'Subversion repository' | |
35 |
|
35 | |||
36 |
|
36 | |||
37 | CELERY_ENABLED = False |
|
37 | CELERY_ENABLED = False | |
38 | CELERY_EAGER = False |
|
38 | CELERY_EAGER = False | |
39 |
|
39 | |||
40 | # link to config for pyramid |
|
40 | # link to config for pyramid | |
41 | CONFIG = {} |
|
41 | CONFIG = {} | |
42 |
|
42 | |||
43 | # Populated with the settings dictionary from application init in |
|
43 | # Populated with the settings dictionary from application init in | |
44 | # rhodecode.conf.environment.load_pyramid_environment |
|
44 | # rhodecode.conf.environment.load_pyramid_environment | |
45 | PYRAMID_SETTINGS = {} |
|
45 | PYRAMID_SETTINGS = {} | |
46 |
|
46 | |||
47 | # Linked module for extensions |
|
47 | # Linked module for extensions | |
48 | EXTENSIONS = {} |
|
48 | EXTENSIONS = {} | |
49 |
|
49 | |||
50 | __version__ = ('.'.join((str(each) for each in VERSION[:3]))) |
|
50 | __version__ = ('.'.join((str(each) for each in VERSION[:3]))) | |
51 |
__dbversion__ = 11 |
|
51 | __dbversion__ = 114 # defines current db version for migrations | |
52 | __platform__ = platform.system() |
|
52 | __platform__ = platform.system() | |
53 | __license__ = 'AGPLv3, and Commercial License' |
|
53 | __license__ = 'AGPLv3, and Commercial License' | |
54 | __author__ = 'RhodeCode GmbH' |
|
54 | __author__ = 'RhodeCode GmbH' | |
55 | __url__ = 'https://code.rhodecode.com' |
|
55 | __url__ = 'https://code.rhodecode.com' | |
56 |
|
56 | |||
57 | is_windows = __platform__ in ['Windows'] |
|
57 | is_windows = __platform__ in ['Windows'] | |
58 | is_unix = not is_windows |
|
58 | is_unix = not is_windows | |
59 | is_test = False |
|
59 | is_test = False | |
60 | disable_error_handler = False |
|
60 | disable_error_handler = False |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
General Comments 0
You need to be logged in to leave comments.
Login now