Show More
@@ -0,0 +1,61 b'' | |||||
|
1 | import os | |||
|
2 | import logging | |||
|
3 | import datetime | |||
|
4 | ||||
|
5 | from sqlalchemy import * | |||
|
6 | from sqlalchemy.exc import DatabaseError | |||
|
7 | from sqlalchemy.orm import relation, backref, class_mapper, joinedload | |||
|
8 | from sqlalchemy.orm.session import Session | |||
|
9 | from sqlalchemy.ext.declarative import declarative_base | |||
|
10 | ||||
|
11 | from rhodecode.lib.dbmigrate.migrate import * | |||
|
12 | from rhodecode.lib.dbmigrate.migrate.changeset import * | |||
|
13 | from rhodecode.lib.utils2 import str2bool | |||
|
14 | ||||
|
15 | from rhodecode.model.meta import Base | |||
|
16 | from rhodecode.model import meta | |||
|
17 | from rhodecode.lib.dbmigrate.versions import _reset_base, notify | |||
|
18 | ||||
|
19 | log = logging.getLogger(__name__) | |||
|
20 | ||||
|
21 | ||||
|
22 | def get_by_key(cls, key): | |||
|
23 | return cls.query().filter(cls.ui_key == key).scalar() | |||
|
24 | ||||
|
25 | ||||
|
26 | def get_repos_location(cls): | |||
|
27 | return get_by_key(cls, '/').ui_value | |||
|
28 | ||||
|
29 | ||||
|
30 | def upgrade(migrate_engine): | |||
|
31 | """ | |||
|
32 | Upgrade operations go here. | |||
|
33 | Don't create your own engine; bind migrate_engine to your metadata | |||
|
34 | """ | |||
|
35 | _reset_base(migrate_engine) | |||
|
36 | from rhodecode.lib.dbmigrate.schema import db_4_7_0_1 | |||
|
37 | ||||
|
38 | # issue fixups | |||
|
39 | fixups(db_4_7_0_1, meta.Session) | |||
|
40 | ||||
|
41 | ||||
|
42 | def downgrade(migrate_engine): | |||
|
43 | meta = MetaData() | |||
|
44 | meta.bind = migrate_engine | |||
|
45 | ||||
|
46 | ||||
|
47 | def fixups(models, _SESSION): | |||
|
48 | ||||
|
49 | repo_store_path = get_repos_location(models.RhodeCodeUi) | |||
|
50 | _store = os.path.join(repo_store_path, '.cache', 'lfs_store') | |||
|
51 | notify('Setting lfs_store to:%s' % _store) | |||
|
52 | ||||
|
53 | if not models.RhodeCodeUi.query().filter( | |||
|
54 | models.RhodeCodeUi.ui_key == 'store_location').scalar(): | |||
|
55 | lfsstore = models.RhodeCodeUi() | |||
|
56 | lfsstore.ui_section = 'vcs_git_lfs' | |||
|
57 | lfsstore.ui_key = 'store_location' | |||
|
58 | lfsstore.ui_value = _store | |||
|
59 | _SESSION().add(lfsstore) | |||
|
60 | _SESSION().commit() | |||
|
61 |
@@ -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__ = 71 # 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' |
General Comments 0
You need to be logged in to leave comments.
Login now