Show More
@@ -0,0 +1,63 b'' | |||||
|
1 | import logging | |||
|
2 | ||||
|
3 | from sqlalchemy import * | |||
|
4 | from rhodecode.model import meta | |||
|
5 | from rhodecode.lib.dbmigrate.versions import _reset_base, notify | |||
|
6 | ||||
|
7 | log = logging.getLogger(__name__) | |||
|
8 | ||||
|
9 | ||||
|
10 | def get_by_key(cls, key): | |||
|
11 | return cls.query().filter(cls.ui_key == key).scalar() | |||
|
12 | ||||
|
13 | ||||
|
14 | def create_or_update_hook(cls, key, val, SESSION): | |||
|
15 | new_ui = get_by_key(cls, key) or cls() | |||
|
16 | new_ui.ui_section = 'hooks' | |||
|
17 | new_ui.ui_active = True | |||
|
18 | new_ui.ui_key = key | |||
|
19 | new_ui.ui_value = val | |||
|
20 | ||||
|
21 | SESSION().add(new_ui) | |||
|
22 | ||||
|
23 | ||||
|
24 | def upgrade(migrate_engine): | |||
|
25 | """ | |||
|
26 | Upgrade operations go here. | |||
|
27 | Don't create your own engine; bind migrate_engine to your metadata | |||
|
28 | """ | |||
|
29 | _reset_base(migrate_engine) | |||
|
30 | from rhodecode.lib.dbmigrate.schema import db_4_7_0_0 as db | |||
|
31 | ||||
|
32 | # issue fixups | |||
|
33 | fixups(db, meta.Session) | |||
|
34 | ||||
|
35 | ||||
|
36 | def downgrade(migrate_engine): | |||
|
37 | meta = MetaData() | |||
|
38 | meta.bind = migrate_engine | |||
|
39 | ||||
|
40 | ||||
|
41 | def fixups(models, _SESSION): | |||
|
42 | ||||
|
43 | cleanup_if_present = ( | |||
|
44 | 'pushkey.key_push', | |||
|
45 | ) | |||
|
46 | ||||
|
47 | for hook in cleanup_if_present: | |||
|
48 | ui_cfg = models.RhodeCodeUi.query().filter( | |||
|
49 | models.RhodeCodeUi.ui_key == hook).scalar() | |||
|
50 | if ui_cfg is not None: | |||
|
51 | log.info('Removing RhodeCodeUI for hook "%s".', hook) | |||
|
52 | _SESSION().delete(ui_cfg) | |||
|
53 | ||||
|
54 | to_add = [ | |||
|
55 | ('pushkey.key_push', | |||
|
56 | 'python:vcsserver.hooks.key_push'), | |||
|
57 | ] | |||
|
58 | ||||
|
59 | for hook, value in to_add: | |||
|
60 | log.info('Adding RhodeCodeUI for hook "%s".', hook) | |||
|
61 | create_or_update_hook(models.RhodeCodeUi, hook, value, _SESSION) | |||
|
62 | ||||
|
63 | _SESSION().commit() |
@@ -51,7 +51,7 b' PYRAMID_SETTINGS = {}' | |||||
51 | EXTENSIONS = {} |
|
51 | EXTENSIONS = {} | |
52 |
|
52 | |||
53 | __version__ = ('.'.join((str(each) for each in VERSION[:3]))) |
|
53 | __version__ = ('.'.join((str(each) for each in VERSION[:3]))) | |
54 |
__dbversion__ = 7 |
|
54 | __dbversion__ = 73 # defines current db version for migrations | |
55 | __platform__ = platform.system() |
|
55 | __platform__ = platform.system() | |
56 | __license__ = 'AGPLv3, and Commercial License' |
|
56 | __license__ = 'AGPLv3, and Commercial License' | |
57 | __author__ = 'RhodeCode GmbH' |
|
57 | __author__ = 'RhodeCode GmbH' |
@@ -358,6 +358,7 b' class RhodeCodeUi(Base, BaseModel):' | |||||
358 | HOOK_PRE_PUSH = 'prechangegroup.pre_push' |
|
358 | HOOK_PRE_PUSH = 'prechangegroup.pre_push' | |
359 | HOOK_PRETX_PUSH = 'pretxnchangegroup.pre_push' |
|
359 | HOOK_PRETX_PUSH = 'pretxnchangegroup.pre_push' | |
360 | HOOK_PUSH = 'changegroup.push_logger' |
|
360 | HOOK_PUSH = 'changegroup.push_logger' | |
|
361 | HOOK_PUSH_KEY = 'pushkey.key_push' | |||
361 |
|
362 | |||
362 | # TODO: johbo: Unify way how hooks are configured for git and hg, |
|
363 | # TODO: johbo: Unify way how hooks are configured for git and hg, | |
363 | # git part is currently hardcoded. |
|
364 | # git part is currently hardcoded. |
General Comments 0
You need to be logged in to leave comments.
Login now