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 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | # Copyright (C) 2010-2020 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 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | |
|
21 | 21 | import os |
|
22 | 22 | from collections import OrderedDict |
|
23 | 23 | |
|
24 | 24 | import sys |
|
25 | 25 | import platform |
|
26 | 26 | |
|
27 | 27 | VERSION = tuple(open(os.path.join( |
|
28 | 28 | os.path.dirname(__file__), 'VERSION')).read().split('.')) |
|
29 | 29 | |
|
30 | 30 | BACKENDS = OrderedDict() |
|
31 | 31 | |
|
32 | 32 | BACKENDS['hg'] = 'Mercurial repository' |
|
33 | 33 | BACKENDS['git'] = 'Git repository' |
|
34 | 34 | BACKENDS['svn'] = 'Subversion repository' |
|
35 | 35 | |
|
36 | 36 | |
|
37 | 37 | CELERY_ENABLED = False |
|
38 | 38 | CELERY_EAGER = False |
|
39 | 39 | |
|
40 | 40 | # link to config for pyramid |
|
41 | 41 | CONFIG = {} |
|
42 | 42 | |
|
43 | 43 | # Populated with the settings dictionary from application init in |
|
44 | 44 | # rhodecode.conf.environment.load_pyramid_environment |
|
45 | 45 | PYRAMID_SETTINGS = {} |
|
46 | 46 | |
|
47 | 47 | # Linked module for extensions |
|
48 | 48 | EXTENSIONS = {} |
|
49 | 49 | |
|
50 | 50 | __version__ = ('.'.join((str(each) for each in VERSION[:3]))) |
|
51 |
__dbversion__ = 11 |
|
|
51 | __dbversion__ = 114 # defines current db version for migrations | |
|
52 | 52 | __platform__ = platform.system() |
|
53 | 53 | __license__ = 'AGPLv3, and Commercial License' |
|
54 | 54 | __author__ = 'RhodeCode GmbH' |
|
55 | 55 | __url__ = 'https://code.rhodecode.com' |
|
56 | 56 | |
|
57 | 57 | is_windows = __platform__ in ['Windows'] |
|
58 | 58 | is_unix = not is_windows |
|
59 | 59 | is_test = False |
|
60 | 60 | disable_error_handler = False |
|
1 | 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