Show More
@@ -0,0 +1,64 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
|
2 | ||||
|
3 | import logging | |||
|
4 | from sqlalchemy import * | |||
|
5 | ||||
|
6 | from alembic.migration import MigrationContext | |||
|
7 | from alembic.operations import Operations | |||
|
8 | ||||
|
9 | from rhodecode.lib.dbmigrate.versions import _reset_base | |||
|
10 | from rhodecode.model import meta, init_model_encryption | |||
|
11 | ||||
|
12 | ||||
|
13 | log = logging.getLogger(__name__) | |||
|
14 | ||||
|
15 | ||||
|
16 | def upgrade(migrate_engine): | |||
|
17 | """ | |||
|
18 | Upgrade operations go here. | |||
|
19 | Don't create your own engine; bind migrate_engine to your metadata | |||
|
20 | """ | |||
|
21 | _reset_base(migrate_engine) | |||
|
22 | from rhodecode.lib.dbmigrate.schema import db_4_20_0_0 as db | |||
|
23 | ||||
|
24 | init_model_encryption(db) | |||
|
25 | ||||
|
26 | # issue fixups | |||
|
27 | fixups(db, meta.Session) | |||
|
28 | ||||
|
29 | ||||
|
30 | def downgrade(migrate_engine): | |||
|
31 | meta = MetaData() | |||
|
32 | meta.bind = migrate_engine | |||
|
33 | ||||
|
34 | ||||
|
35 | def fixups(models, _SESSION): | |||
|
36 | # now create new changed value of clone_url | |||
|
37 | Optional = models.Optional | |||
|
38 | ||||
|
39 | def get_by_name(cls, key): | |||
|
40 | return cls.query().filter(cls.app_settings_name == key).scalar() | |||
|
41 | ||||
|
42 | def create_or_update(cls, key, val=Optional(''), type_=Optional('unicode')): | |||
|
43 | res = get_by_name(cls, key) | |||
|
44 | if not res: | |||
|
45 | val = Optional.extract(val) | |||
|
46 | type_ = Optional.extract(type_) | |||
|
47 | res = cls(key, val, type_) | |||
|
48 | else: | |||
|
49 | res.app_settings_name = key | |||
|
50 | if not isinstance(val, Optional): | |||
|
51 | # update if set | |||
|
52 | res.app_settings_value = val | |||
|
53 | if not isinstance(type_, Optional): | |||
|
54 | # update if set | |||
|
55 | res.app_settings_type = type_ | |||
|
56 | return res | |||
|
57 | ||||
|
58 | clone_uri_tmpl = models.Repository.DEFAULT_CLONE_URI_ID | |||
|
59 | print('settings new clone by url template to %s' % clone_uri_tmpl) | |||
|
60 | ||||
|
61 | sett = create_or_update(models.RhodeCodeSetting, | |||
|
62 | 'clone_uri_id_tmpl', clone_uri_tmpl, 'unicode') | |||
|
63 | _SESSION().add(sett) | |||
|
64 | _SESSION.commit() |
@@ -48,7 +48,7 b' PYRAMID_SETTINGS = {}' | |||||
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__ = 113 # 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' |
General Comments 0
You need to be logged in to leave comments.
Login now