Show More
@@ -1,45 +1,45 b'' | |||
|
1 | 1 | import logging |
|
2 | 2 | import datetime |
|
3 | 3 | |
|
4 | 4 | from sqlalchemy import * |
|
5 | 5 | from sqlalchemy.exc import DatabaseError |
|
6 | 6 | from sqlalchemy.orm import relation, backref, class_mapper, joinedload |
|
7 | 7 | from sqlalchemy.orm.session import Session |
|
8 | 8 | from sqlalchemy.ext.declarative import declarative_base |
|
9 | 9 | |
|
10 | 10 | from rhodecode.lib.dbmigrate.migrate import * |
|
11 | 11 | from rhodecode.lib.dbmigrate.migrate.changeset import * |
|
12 | 12 | from rhodecode.lib.utils2 import str2bool |
|
13 | 13 | |
|
14 | 14 | from rhodecode.model.meta import Base |
|
15 | 15 | from rhodecode.model import meta |
|
16 | 16 | from rhodecode.lib.dbmigrate.versions import _reset_base, notify |
|
17 | 17 | |
|
18 | 18 | log = logging.getLogger(__name__) |
|
19 | 19 | |
|
20 | 20 | |
|
21 | 21 | def upgrade(migrate_engine): |
|
22 | 22 | """ |
|
23 | 23 | Upgrade operations go here. |
|
24 | 24 | Don't create your own engine; bind migrate_engine to your metadata |
|
25 | 25 | """ |
|
26 | 26 | _reset_base(migrate_engine) |
|
27 | 27 | from rhodecode.lib.dbmigrate.schema import db_2_2_3 |
|
28 | 28 | |
|
29 | 29 | # issue fixups |
|
30 | 30 | fixups(db_2_2_3, meta.Session) |
|
31 | 31 | |
|
32 | 32 | |
|
33 | 33 | def downgrade(migrate_engine): |
|
34 | 34 | meta = MetaData() |
|
35 | 35 | meta.bind = migrate_engine |
|
36 | 36 | |
|
37 | 37 | |
|
38 | 38 | def fixups(models, _SESSION): |
|
39 | 39 | notify('Creating repository states') |
|
40 | 40 | _state = models.Repository.STATE_CREATED |
|
41 | 41 | for repo in models.Repository.get_all(): |
|
42 |
|
|
|
42 | log.info('setting repo %s state to "%s"', repo, _state) | |
|
43 | 43 | repo.repo_state = _state |
|
44 | 44 | _SESSION().add(repo) |
|
45 | 45 | _SESSION().commit() |
@@ -1,45 +1,45 b'' | |||
|
1 | 1 | import logging |
|
2 | 2 | import datetime |
|
3 | 3 | |
|
4 | 4 | from sqlalchemy import * |
|
5 | 5 | from sqlalchemy.exc import DatabaseError |
|
6 | 6 | from sqlalchemy.orm import relation, backref, class_mapper, joinedload |
|
7 | 7 | from sqlalchemy.orm.session import Session |
|
8 | 8 | from sqlalchemy.ext.declarative import declarative_base |
|
9 | 9 | |
|
10 | 10 | from rhodecode.lib.dbmigrate.migrate import * |
|
11 | 11 | from rhodecode.lib.dbmigrate.migrate.changeset import * |
|
12 | 12 | from rhodecode.lib.utils2 import str2bool |
|
13 | 13 | |
|
14 | 14 | from rhodecode.model.meta import Base |
|
15 | 15 | from rhodecode.model import meta |
|
16 | 16 | from rhodecode.lib.dbmigrate.versions import _reset_base, notify |
|
17 | 17 | |
|
18 | 18 | log = logging.getLogger(__name__) |
|
19 | 19 | |
|
20 | 20 | |
|
21 | 21 | def upgrade(migrate_engine): |
|
22 | 22 | """ |
|
23 | 23 | Upgrade operations go here. |
|
24 | 24 | Don't create your own engine; bind migrate_engine to your metadata |
|
25 | 25 | """ |
|
26 | 26 | _reset_base(migrate_engine) |
|
27 | 27 | from rhodecode.lib.dbmigrate.schema import db_2_3_0_0 |
|
28 | 28 | |
|
29 | 29 | # issue fixups |
|
30 | 30 | fixups(db_2_3_0_0, meta.Session) |
|
31 | 31 | |
|
32 | 32 | |
|
33 | 33 | def downgrade(migrate_engine): |
|
34 | 34 | meta = MetaData() |
|
35 | 35 | meta.bind = migrate_engine |
|
36 | 36 | |
|
37 | 37 | |
|
38 | 38 | def fixups(models, _SESSION): |
|
39 | 39 | notify('Fixing auth tokens roles') |
|
40 | 40 | _role = models.UserApiKeys.ROLE_ALL |
|
41 | 41 | for token in models.UserApiKeys.get_all(): |
|
42 |
|
|
|
42 | log.info('setting key %s role to "%s"', token, _role) | |
|
43 | 43 | token.role = _role |
|
44 | 44 | _SESSION().add(token) |
|
45 | 45 | _SESSION().commit() |
@@ -1,47 +1,47 b'' | |||
|
1 | 1 | import logging |
|
2 | 2 | import datetime |
|
3 | 3 | |
|
4 | 4 | from sqlalchemy import * |
|
5 | 5 | from sqlalchemy.exc import DatabaseError |
|
6 | 6 | from sqlalchemy.orm import relation, backref, class_mapper, joinedload |
|
7 | 7 | from sqlalchemy.orm.session import Session |
|
8 | 8 | from sqlalchemy.ext.declarative import declarative_base |
|
9 | 9 | |
|
10 | 10 | from rhodecode.lib.dbmigrate.migrate import * |
|
11 | 11 | from rhodecode.lib.dbmigrate.migrate.changeset import * |
|
12 | 12 | from rhodecode.lib.utils2 import str2bool |
|
13 | 13 | |
|
14 | 14 | from rhodecode.model.meta import Base |
|
15 | 15 | from rhodecode.model import meta |
|
16 | 16 | from rhodecode.lib.dbmigrate.versions import _reset_base, notify |
|
17 | 17 | |
|
18 | 18 | log = logging.getLogger(__name__) |
|
19 | 19 | |
|
20 | 20 | |
|
21 | 21 | def upgrade(migrate_engine): |
|
22 | 22 | """ |
|
23 | 23 | Upgrade operations go here. |
|
24 | 24 | Don't create your own engine; bind migrate_engine to your metadata |
|
25 | 25 | """ |
|
26 | 26 | _reset_base(migrate_engine) |
|
27 | 27 | from rhodecode.lib.dbmigrate.schema import db_3_0_0_0 |
|
28 | 28 | |
|
29 | 29 | # issue fixups |
|
30 | 30 | fixups(db_3_0_0_0, meta.Session) |
|
31 | 31 | |
|
32 | 32 | |
|
33 | 33 | def downgrade(migrate_engine): |
|
34 | 34 | meta = MetaData() |
|
35 | 35 | meta.bind = migrate_engine |
|
36 | 36 | |
|
37 | 37 | |
|
38 | 38 | def fixups(models, _SESSION): |
|
39 | 39 | # ** create default permissions ** # |
|
40 | 40 | from rhodecode.model.permission import PermissionModel |
|
41 | 41 | PermissionModel(_SESSION()).create_permissions() |
|
42 | 42 | _SESSION().commit() |
|
43 | 43 | |
|
44 | 44 | res = PermissionModel(_SESSION()).create_default_user_permissions( |
|
45 | 45 | models.User.DEFAULT_USER) |
|
46 | print res | |
|
46 | log.info('created default permission %s', res) | |
|
47 | 47 | _SESSION().commit() |
@@ -1,37 +1,37 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | import logging |
|
4 | 4 | |
|
5 | 5 | from sqlalchemy.orm.attributes import flag_modified |
|
6 | 6 | |
|
7 | 7 | from rhodecode.lib.dbmigrate.versions import _reset_base |
|
8 | 8 | from rhodecode.model import init_model_encryption, meta |
|
9 | 9 | |
|
10 | 10 | log = logging.getLogger(__name__) |
|
11 | 11 | |
|
12 | 12 | |
|
13 | 13 | def upgrade(migrate_engine): |
|
14 | 14 | """ |
|
15 | 15 | Upgrade operations go here. |
|
16 | 16 | Don't create your own engine; bind migrate_engine to your metadata |
|
17 | 17 | """ |
|
18 | 18 | _reset_base(migrate_engine) |
|
19 | 19 | from rhodecode.lib.dbmigrate.schema import db_3_7_0_0 |
|
20 | 20 | init_model_encryption(db_3_7_0_0) |
|
21 | 21 | fixups(db_3_7_0_0, meta.Session) |
|
22 | 22 | |
|
23 | 23 | |
|
24 | 24 | def downgrade(migrate_engine): |
|
25 | 25 | pass |
|
26 | 26 | |
|
27 | 27 | |
|
28 | 28 | def fixups(models, Session): |
|
29 | 29 | for repo in models.Repository.get_all(): |
|
30 | 30 | if repo.clone_uri: |
|
31 |
|
|
|
31 | log.info('Encrypting clone uri in repo %s', repo) | |
|
32 | 32 | flag_modified(repo, 'clone_uri') |
|
33 | 33 | Session().add(repo) |
|
34 | 34 | |
|
35 | 35 | Session().commit() |
|
36 | 36 | |
|
37 | 37 |
General Comments 0
You need to be logged in to leave comments.
Login now