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