Show More
@@ -1,116 +1,119 | |||||
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 |
|
13 | |||
14 | log = logging.getLogger(__name__) |
|
14 | log = logging.getLogger(__name__) | |
15 |
|
15 | |||
16 | def upgrade(migrate_engine): |
|
16 | def upgrade(migrate_engine): | |
17 | """ Upgrade operations go here. |
|
17 | """ Upgrade operations go here. | |
18 | Don't create your own engine; bind migrate_engine to your metadata |
|
18 | Don't create your own engine; bind migrate_engine to your metadata | |
19 | """ |
|
19 | """ | |
20 |
|
20 | |||
21 | #========================================================================== |
|
21 | #========================================================================== | |
22 | # Add table `groups`` |
|
22 | # Add table `groups`` | |
23 | #========================================================================== |
|
23 | #========================================================================== | |
24 | from rhodecode.model.db import Group |
|
24 | from rhodecode.model.db import Group | |
25 | Group().__table__.create() |
|
25 | Group().__table__.create() | |
26 |
|
26 | |||
27 | #========================================================================== |
|
27 | #========================================================================== | |
28 | # Add table `group_to_perm` |
|
28 | # Add table `group_to_perm` | |
29 | #========================================================================== |
|
29 | #========================================================================== | |
30 | from rhodecode.model.db import GroupToPerm |
|
30 | from rhodecode.model.db import GroupToPerm | |
31 | GroupToPerm().__table__.create() |
|
31 | GroupToPerm().__table__.create() | |
32 |
|
32 | |||
33 | #========================================================================== |
|
33 | #========================================================================== | |
34 | # Add table `users_groups` |
|
34 | # Add table `users_groups` | |
35 | #========================================================================== |
|
35 | #========================================================================== | |
36 | from rhodecode.model.db import UsersGroup |
|
36 | from rhodecode.model.db import UsersGroup | |
37 | UsersGroup().__table__.create() |
|
37 | UsersGroup().__table__.create() | |
38 |
|
38 | |||
39 | #========================================================================== |
|
39 | #========================================================================== | |
40 | # Add table `users_groups_members` |
|
40 | # Add table `users_groups_members` | |
41 | #========================================================================== |
|
41 | #========================================================================== | |
42 | from rhodecode.model.db import UsersGroupMember |
|
42 | from rhodecode.model.db import UsersGroupMember | |
43 | UsersGroupMember().__table__.create() |
|
43 | UsersGroupMember().__table__.create() | |
44 |
|
44 | |||
45 | #========================================================================== |
|
45 | #========================================================================== | |
46 | # Add table `users_group_repo_to_perm` |
|
46 | # Add table `users_group_repo_to_perm` | |
47 | #========================================================================== |
|
47 | #========================================================================== | |
48 | from rhodecode.model.db import UsersGroupRepoToPerm |
|
48 | from rhodecode.model.db import UsersGroupRepoToPerm | |
49 | UsersGroupRepoToPerm().__table__.create() |
|
49 | UsersGroupRepoToPerm().__table__.create() | |
50 |
|
50 | |||
51 | #========================================================================== |
|
51 | #========================================================================== | |
52 | # Add table `users_group_to_perm` |
|
52 | # Add table `users_group_to_perm` | |
53 | #========================================================================== |
|
53 | #========================================================================== | |
54 | from rhodecode.model.db import UsersGroupToPerm |
|
54 | from rhodecode.model.db import UsersGroupToPerm | |
55 | UsersGroupToPerm().__table__.create() |
|
55 | UsersGroupToPerm().__table__.create() | |
56 |
|
56 | |||
57 | #========================================================================== |
|
57 | #========================================================================== | |
58 | # Upgrade of `users` table |
|
58 | # Upgrade of `users` table | |
59 | #========================================================================== |
|
59 | #========================================================================== | |
60 | from rhodecode.model.db import User |
|
60 | from rhodecode.model.db import User | |
61 |
|
61 | |||
62 | #add column |
|
62 | #add column | |
63 | ldap_dn = Column("ldap_dn", String(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
|
63 | ldap_dn = Column("ldap_dn", String(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) | |
64 | ldap_dn.create(User().__table__) |
|
64 | ldap_dn.create(User().__table__) | |
65 |
|
65 | |||
66 | api_key = Column("api_key", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
|
66 | api_key = Column("api_key", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) | |
67 | api_key.create(User().__table__) |
|
67 | api_key.create(User().__table__) | |
68 |
|
68 | |||
69 | #remove old column |
|
69 | #remove old column | |
70 | is_ldap = Column("is_ldap", Boolean(), nullable=False, unique=None, default=False) |
|
70 | is_ldap = Column("is_ldap", Boolean(), nullable=False, unique=None, default=False) | |
71 | is_ldap.drop(User().__table__) |
|
71 | is_ldap.drop(User().__table__) | |
72 |
|
72 | |||
73 |
|
73 | |||
74 | #========================================================================== |
|
74 | #========================================================================== | |
75 | # Upgrade of `repositories` table |
|
75 | # Upgrade of `repositories` table | |
76 | #========================================================================== |
|
76 | #========================================================================== | |
77 | from rhodecode.model.db import Repository |
|
77 | from rhodecode.model.db import Repository | |
78 |
|
78 | |||
|
79 | #ADD clone_uri column# | |||
|
80 | ||||
|
81 | clone_uri = Column("clone_uri", String(length=255, convert_unicode=False, | |||
|
82 | assert_unicode=None), | |||
|
83 | nullable=True, unique=False, default=None) | |||
|
84 | ||||
|
85 | clone_uri.create(Repository().__table__) | |||
|
86 | ||||
79 | #ADD downloads column# |
|
87 | #ADD downloads column# | |
80 | enable_downloads = Column("downloads", Boolean(), nullable=True, unique=None, default=True) |
|
88 | enable_downloads = Column("downloads", Boolean(), nullable=True, unique=None, default=True) | |
81 | enable_downloads.create(Repository().__table__) |
|
89 | enable_downloads.create(Repository().__table__) | |
82 |
|
90 | |||
83 | #ADD column created_on |
|
91 | #ADD column created_on | |
84 | created_on = Column('created_on', DateTime(timezone=False), nullable=True, |
|
92 | created_on = Column('created_on', DateTime(timezone=False), nullable=True, | |
85 | unique=None, default=datetime.datetime.now) |
|
93 | unique=None, default=datetime.datetime.now) | |
86 | created_on.create(Repository().__table__) |
|
94 | created_on.create(Repository().__table__) | |
87 |
|
95 | |||
88 | #ADD group_id column# |
|
96 | #ADD group_id column# | |
89 | group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), |
|
97 | group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), | |
90 | nullable=True, unique=False, default=None) |
|
98 | nullable=True, unique=False, default=None) | |
91 |
|
99 | |||
92 | group_id.create(Repository().__table__) |
|
100 | group_id.create(Repository().__table__) | |
93 |
|
101 | |||
94 |
|
102 | |||
95 | #ADD clone_uri column# |
|
|||
96 |
|
||||
97 | clone_uri = Column("clone_uri", String(length=255, convert_unicode=False, |
|
|||
98 | assert_unicode=None), |
|
|||
99 | nullable=True, unique=False, default=None) |
|
|||
100 |
|
||||
101 | clone_uri.create(Repository().__table__) |
|
|||
102 |
|
||||
103 |
|
||||
104 | #========================================================================== |
|
103 | #========================================================================== | |
105 | # Upgrade of `user_followings` table |
|
104 | # Upgrade of `user_followings` table | |
106 | #========================================================================== |
|
105 | #========================================================================== | |
107 |
|
106 | |||
108 | follows_from = Column('follows_from', DateTime(timezone=False), nullable=True, unique=None, default=datetime.datetime.now) |
|
107 | from rhodecode.model.db import UserFollowing | |
109 | follows_from.create(Repository().__table__) |
|
108 | ||
|
109 | follows_from = Column('follows_from', DateTime(timezone=False), | |||
|
110 | nullable=True, unique=None, | |||
|
111 | default=datetime.datetime.now) | |||
|
112 | follows_from.create(UserFollowing().__table__) | |||
110 |
|
113 | |||
111 | return |
|
114 | return | |
112 |
|
115 | |||
113 |
|
116 | |||
114 | def downgrade(migrate_engine): |
|
117 | def downgrade(migrate_engine): | |
115 | meta = MetaData() |
|
118 | meta = MetaData() | |
116 | meta.bind = migrate_engine |
|
119 | meta.bind = migrate_engine |
General Comments 0
You need to be logged in to leave comments.
Login now