Show More
@@ -0,0 +1,50 b'' | |||||
|
1 | ||||
|
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 | from rhodecode.model import db as db_5_1_0_0 | |||
|
28 | ||||
|
29 | # issue fixups | |||
|
30 | fixups(db_5_1_0_0, meta.Session) | |||
|
31 | ||||
|
32 | ||||
|
33 | def downgrade(migrate_engine): | |||
|
34 | pass | |||
|
35 | ||||
|
36 | ||||
|
37 | def fixups(models, _SESSION): | |||
|
38 | for db_repo in _SESSION.query(models.Repository).all(): | |||
|
39 | ||||
|
40 | config = db_repo._config | |||
|
41 | config.set('extensions', 'largefiles', '') | |||
|
42 | ||||
|
43 | try: | |||
|
44 | scm = db_repo.scm_instance(cache=False, config=config) | |||
|
45 | if scm: | |||
|
46 | print(f'installing hook for repo: {db_repo}') | |||
|
47 | scm.install_hooks(force=True) | |||
|
48 | except Exception as e: | |||
|
49 | print(e) | |||
|
50 | print('continue...') |
@@ -1,91 +1,91 b'' | |||||
1 | # Copyright (C) 2010-2023 RhodeCode GmbH |
|
1 | # Copyright (C) 2010-2023 RhodeCode GmbH | |
2 | # |
|
2 | # | |
3 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
4 | # it under the terms of the GNU Affero General Public License, version 3 |
|
4 | # it under the terms of the GNU Affero General Public License, version 3 | |
5 | # (only), as published by the Free Software Foundation. |
|
5 | # (only), as published by the Free Software Foundation. | |
6 | # |
|
6 | # | |
7 | # This program is distributed in the hope that it will be useful, |
|
7 | # This program is distributed in the hope that it will be useful, | |
8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
10 | # GNU General Public License for more details. |
|
10 | # GNU General Public License for more details. | |
11 | # |
|
11 | # | |
12 | # You should have received a copy of the GNU Affero General Public License |
|
12 | # You should have received a copy of the GNU Affero General Public License | |
13 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
13 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
14 | # |
|
14 | # | |
15 | # This program is dual-licensed. If you wish to learn more about the |
|
15 | # This program is dual-licensed. If you wish to learn more about the | |
16 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
16 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
17 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
17 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
18 |
|
18 | |||
19 | import os |
|
19 | import os | |
20 | import datetime |
|
20 | import datetime | |
21 | import collections |
|
21 | import collections | |
22 | import logging |
|
22 | import logging | |
23 |
|
23 | |||
24 |
|
24 | |||
25 | now = datetime.datetime.now() |
|
25 | now = datetime.datetime.now() | |
26 | now = now.strftime("%Y-%m-%d %H:%M:%S") + '.' + f"{int(now.microsecond/1000):03d}" |
|
26 | now = now.strftime("%Y-%m-%d %H:%M:%S") + '.' + f"{int(now.microsecond/1000):03d}" | |
27 |
|
27 | |||
28 | log = logging.getLogger(__name__) |
|
28 | log = logging.getLogger(__name__) | |
29 | log.debug(f'{now} Starting RhodeCode imports...') |
|
29 | log.debug(f'{now} Starting RhodeCode imports...') | |
30 |
|
30 | |||
31 |
|
31 | |||
32 | VERSION = tuple(open(os.path.join( |
|
32 | VERSION = tuple(open(os.path.join( | |
33 | os.path.dirname(__file__), 'VERSION')).read().split('.')) |
|
33 | os.path.dirname(__file__), 'VERSION')).read().split('.')) | |
34 |
|
34 | |||
35 | BACKENDS = collections.OrderedDict() |
|
35 | BACKENDS = collections.OrderedDict() | |
36 |
|
36 | |||
37 | BACKENDS['hg'] = 'Mercurial repository' |
|
37 | BACKENDS['hg'] = 'Mercurial repository' | |
38 | BACKENDS['git'] = 'Git repository' |
|
38 | BACKENDS['git'] = 'Git repository' | |
39 | BACKENDS['svn'] = 'Subversion repository' |
|
39 | BACKENDS['svn'] = 'Subversion repository' | |
40 |
|
40 | |||
41 |
|
41 | |||
42 | CELERY_ENABLED = False |
|
42 | CELERY_ENABLED = False | |
43 | CELERY_EAGER = False |
|
43 | CELERY_EAGER = False | |
44 |
|
44 | |||
45 | # link to config for pyramid |
|
45 | # link to config for pyramid | |
46 | CONFIG = {} |
|
46 | CONFIG = {} | |
47 |
|
47 | |||
48 |
|
48 | |||
49 | class ConfigGet: |
|
49 | class ConfigGet: | |
50 | NotGiven = object() |
|
50 | NotGiven = object() | |
51 |
|
51 | |||
52 | def _get_val_or_missing(self, key, missing): |
|
52 | def _get_val_or_missing(self, key, missing): | |
53 | if key not in CONFIG: |
|
53 | if key not in CONFIG: | |
54 | if missing == self.NotGiven: |
|
54 | if missing == self.NotGiven: | |
55 | return missing |
|
55 | return missing | |
56 | # we don't get key, we don't get missing value, return nothing similar as config.get(key) |
|
56 | # we don't get key, we don't get missing value, return nothing similar as config.get(key) | |
57 | return None |
|
57 | return None | |
58 | else: |
|
58 | else: | |
59 | val = CONFIG[key] |
|
59 | val = CONFIG[key] | |
60 | return val |
|
60 | return val | |
61 |
|
61 | |||
62 | def get_str(self, key, missing=NotGiven): |
|
62 | def get_str(self, key, missing=NotGiven): | |
63 | from rhodecode.lib.str_utils import safe_str |
|
63 | from rhodecode.lib.str_utils import safe_str | |
64 | val = self._get_val_or_missing(key, missing) |
|
64 | val = self._get_val_or_missing(key, missing) | |
65 | return safe_str(val) |
|
65 | return safe_str(val) | |
66 |
|
66 | |||
67 | def get_int(self, key, missing=NotGiven): |
|
67 | def get_int(self, key, missing=NotGiven): | |
68 | from rhodecode.lib.str_utils import safe_int |
|
68 | from rhodecode.lib.str_utils import safe_int | |
69 | val = self._get_val_or_missing(key, missing) |
|
69 | val = self._get_val_or_missing(key, missing) | |
70 | return safe_int(val) |
|
70 | return safe_int(val) | |
71 |
|
71 | |||
72 | def get_bool(self, key, missing=NotGiven): |
|
72 | def get_bool(self, key, missing=NotGiven): | |
73 | from rhodecode.lib.type_utils import str2bool |
|
73 | from rhodecode.lib.type_utils import str2bool | |
74 | val = self._get_val_or_missing(key, missing) |
|
74 | val = self._get_val_or_missing(key, missing) | |
75 | return str2bool(val) |
|
75 | return str2bool(val) | |
76 |
|
76 | |||
77 | # Populated with the settings dictionary from application init in |
|
77 | # Populated with the settings dictionary from application init in | |
78 | # rhodecode.conf.environment.load_pyramid_environment |
|
78 | # rhodecode.conf.environment.load_pyramid_environment | |
79 | PYRAMID_SETTINGS = {} |
|
79 | PYRAMID_SETTINGS = {} | |
80 |
|
80 | |||
81 | # Linked module for extensions |
|
81 | # Linked module for extensions | |
82 | EXTENSIONS = {} |
|
82 | EXTENSIONS = {} | |
83 |
|
83 | |||
84 | __version__ = ('.'.join((str(each) for each in VERSION[:3]))) |
|
84 | __version__ = ('.'.join((str(each) for each in VERSION[:3]))) | |
85 |
__dbversion__ = 11 |
|
85 | __dbversion__ = 115 # defines current db version for migrations | |
86 | __license__ = 'AGPLv3, and Commercial License' |
|
86 | __license__ = 'AGPLv3, and Commercial License' | |
87 | __author__ = 'RhodeCode GmbH' |
|
87 | __author__ = 'RhodeCode GmbH' | |
88 | __url__ = 'https://code.rhodecode.com' |
|
88 | __url__ = 'https://code.rhodecode.com' | |
89 |
|
89 | |||
90 | is_test = os.getenv('RC_TEST', '0') == '1' |
|
90 | is_test = os.getenv('RC_TEST', '0') == '1' | |
91 | disable_error_handler = False |
|
91 | disable_error_handler = False |
General Comments 0
You need to be logged in to leave comments.
Login now