Show More
@@ -1,90 +1,100 b'' | |||||
1 | import logging |
|
1 | import logging | |
2 | import datetime |
|
2 | import datetime | |
3 |
|
3 | |||
4 | from sqlalchemy import * |
|
4 | from sqlalchemy import * | |
5 | from sqlalchemy.exc import DatabaseError |
|
5 | from sqlalchemy.exc import DatabaseError | |
6 | from sqlalchemy.orm import relation, backref, class_mapper |
|
6 | from sqlalchemy.orm import relation, backref, class_mapper | |
7 | from sqlalchemy.orm.session import Session |
|
7 | from sqlalchemy.orm.session import Session | |
8 |
|
8 | |||
9 | from rhodecode.lib.dbmigrate.migrate import * |
|
9 | from rhodecode.lib.dbmigrate.migrate import * | |
10 | from rhodecode.lib.dbmigrate.migrate.changeset import * |
|
10 | from rhodecode.lib.dbmigrate.migrate.changeset import * | |
11 |
|
11 | |||
12 | from rhodecode.model.meta import Base |
|
12 | from rhodecode.model.meta import Base | |
13 | from rhodecode.model.db import BaseModel |
|
13 | from rhodecode.model.db import BaseModel | |
14 |
|
14 | |||
15 | log = logging.getLogger(__name__) |
|
15 | log = logging.getLogger(__name__) | |
16 |
|
16 | |||
17 | def upgrade(migrate_engine): |
|
17 | def upgrade(migrate_engine): | |
18 | """ Upgrade operations go here. |
|
18 | """ Upgrade operations go here. | |
19 | Don't create your own engine; bind migrate_engine to your metadata |
|
19 | Don't create your own engine; bind migrate_engine to your metadata | |
20 | """ |
|
20 | """ | |
21 |
|
21 | |||
22 | #========================================================================== |
|
22 | #========================================================================== | |
23 | # Add table `groups`` |
|
23 | # Add table `groups`` | |
24 | #========================================================================== |
|
24 | #========================================================================== | |
25 | from rhodecode.model.db import Group |
|
25 | from rhodecode.model.db import Group | |
26 | Group().__table__.create() |
|
26 | Group().__table__.create() | |
27 |
|
27 | |||
28 | #========================================================================== |
|
28 | #========================================================================== | |
29 | # Add table `group_to_perm` |
|
29 | # Add table `group_to_perm` | |
30 | #========================================================================== |
|
30 | #========================================================================== | |
31 | from rhodecode.model.db import GroupToPerm |
|
31 | from rhodecode.model.db import GroupToPerm | |
32 | GroupToPerm().__table__.create() |
|
32 | GroupToPerm().__table__.create() | |
33 |
|
33 | |||
34 | #========================================================================== |
|
34 | #========================================================================== | |
35 | # Add table `users_groups` |
|
35 | # Add table `users_groups` | |
36 | #========================================================================== |
|
36 | #========================================================================== | |
37 | from rhodecode.model.db import UsersGroup |
|
37 | from rhodecode.model.db import UsersGroup | |
38 | UsersGroup().__table__.create() |
|
38 | UsersGroup().__table__.create() | |
39 |
|
39 | |||
40 | #========================================================================== |
|
40 | #========================================================================== | |
41 | # Add table `users_groups_members` |
|
41 | # Add table `users_groups_members` | |
42 | #========================================================================== |
|
42 | #========================================================================== | |
43 | from rhodecode.model.db import UsersGroupMember |
|
43 | from rhodecode.model.db import UsersGroupMember | |
44 | UsersGroupMember().__table__.create() |
|
44 | UsersGroupMember().__table__.create() | |
45 |
|
45 | |||
46 | #========================================================================== |
|
46 | #========================================================================== | |
47 | # Add table `users_group_to_perm` |
|
47 | # Add table `users_group_to_perm` | |
48 | #========================================================================== |
|
48 | #========================================================================== | |
49 | from rhodecode.model.db import UsersGroupToPerm |
|
49 | from rhodecode.model.db import UsersGroupToPerm | |
50 | UsersGroupToPerm().__table__.create() |
|
50 | UsersGroupToPerm().__table__.create() | |
51 |
|
51 | |||
52 |
|
52 | |||
53 | #========================================================================== |
|
53 | #========================================================================== | |
54 | # Upgrade of `users` table |
|
54 | # Upgrade of `users` table | |
55 | #========================================================================== |
|
55 | #========================================================================== | |
56 | from rhodecode.model.db import User |
|
56 | from rhodecode.model.db import User | |
57 |
|
57 | |||
58 | #add column |
|
58 | #add column | |
59 | ldap_dn = Column("ldap_dn", String(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
|
59 | ldap_dn = Column("ldap_dn", String(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) | |
60 | ldap_dn.create(User().__table__) |
|
60 | ldap_dn.create(User().__table__) | |
61 |
|
61 | |||
|
62 | api_key = Column("api_key", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) | |||
|
63 | api_key.create(User().__table__) | |||
62 |
|
64 | |||
63 | #remove old column |
|
65 | #remove old column | |
64 | is_ldap = Column("is_ldap", Boolean(), nullable=False, unique=None, default=False) |
|
66 | is_ldap = Column("is_ldap", Boolean(), nullable=False, unique=None, default=False) | |
65 | is_ldap.drop(User().__table__) |
|
67 | is_ldap.drop(User().__table__) | |
66 |
|
68 | |||
67 |
|
69 | |||
68 | #========================================================================== |
|
70 | #========================================================================== | |
69 | # Upgrade of `repositories` table |
|
71 | # Upgrade of `repositories` table | |
70 | #========================================================================== |
|
72 | #========================================================================== | |
71 | from rhodecode.model.db import Repository |
|
73 | from rhodecode.model.db import Repository | |
72 |
|
74 | |||
73 | #ADD downloads column# |
|
75 | #ADD downloads column# | |
74 | enable_downloads = Column("downloads", Boolean(), nullable=True, unique=None, default=True) |
|
76 | enable_downloads = Column("downloads", Boolean(), nullable=True, unique=None, default=True) | |
75 | enable_downloads.create(Repository().__table__) |
|
77 | enable_downloads.create(Repository().__table__) | |
76 |
|
78 | |||
77 | #ADD group_id column# |
|
79 | #ADD group_id column# | |
78 | group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), |
|
80 | group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), | |
79 | nullable=True, unique=False, default=None) |
|
81 | nullable=True, unique=False, default=None) | |
80 |
|
82 | |||
81 | group_id.create(Repository().__table__) |
|
83 | group_id.create(Repository().__table__) | |
82 |
|
84 | |||
|
85 | ||||
|
86 | #ADD clone_uri column# | |||
|
87 | ||||
|
88 | clone_uri = Column("clone_uri", String(length=255, convert_unicode=False, | |||
|
89 | assert_unicode=None), | |||
|
90 | nullable=True, unique=False, default=None) | |||
|
91 | ||||
|
92 | clone_uri.create(Repository().__table__) | |||
83 | return |
|
93 | return | |
84 |
|
94 | |||
85 |
|
95 | |||
86 | def downgrade(migrate_engine): |
|
96 | def downgrade(migrate_engine): | |
87 | meta = MetaData() |
|
97 | meta = MetaData() | |
88 | meta.bind = migrate_engine |
|
98 | meta.bind = migrate_engine | |
89 |
|
99 | |||
90 |
|
100 |
General Comments 0
You need to be logged in to leave comments.
Login now