##// END OF EJS Templates
fixed migration bug
marcink -
r2206:deb816e5 default
parent child Browse files
Show More
@@ -1,120 +1,120
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
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.lib.dbmigrate.schema.db_1_2_0 import RepoGroup as Group
25 from rhodecode.lib.dbmigrate.schema.db_1_2_0 import Group as 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.lib.dbmigrate.schema.db_1_2_0 import UserRepoGroupToPerm
31 from rhodecode.lib.dbmigrate.schema.db_1_2_0 import UserRepoGroupToPerm
32 UserRepoGroupToPerm().__table__.create()
32 UserRepoGroupToPerm().__table__.create()
33
33
34 #==========================================================================
34 #==========================================================================
35 # Add table `users_groups`
35 # Add table `users_groups`
36 #==========================================================================
36 #==========================================================================
37 from rhodecode.lib.dbmigrate.schema.db_1_2_0 import UsersGroup
37 from rhodecode.lib.dbmigrate.schema.db_1_2_0 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.lib.dbmigrate.schema.db_1_2_0 import UsersGroupMember
43 from rhodecode.lib.dbmigrate.schema.db_1_2_0 import UsersGroupMember
44 UsersGroupMember().__table__.create()
44 UsersGroupMember().__table__.create()
45
45
46 #==========================================================================
46 #==========================================================================
47 # Add table `users_group_repo_to_perm`
47 # Add table `users_group_repo_to_perm`
48 #==========================================================================
48 #==========================================================================
49 from rhodecode.lib.dbmigrate.schema.db_1_2_0 import UsersGroupRepoToPerm
49 from rhodecode.lib.dbmigrate.schema.db_1_2_0 import UsersGroupRepoToPerm
50 UsersGroupRepoToPerm().__table__.create()
50 UsersGroupRepoToPerm().__table__.create()
51
51
52 #==========================================================================
52 #==========================================================================
53 # Add table `users_group_to_perm`
53 # Add table `users_group_to_perm`
54 #==========================================================================
54 #==========================================================================
55 from rhodecode.lib.dbmigrate.schema.db_1_2_0 import UsersGroupToPerm
55 from rhodecode.lib.dbmigrate.schema.db_1_2_0 import UsersGroupToPerm
56 UsersGroupToPerm().__table__.create()
56 UsersGroupToPerm().__table__.create()
57
57
58 #==========================================================================
58 #==========================================================================
59 # Upgrade of `users` table
59 # Upgrade of `users` table
60 #==========================================================================
60 #==========================================================================
61 from rhodecode.lib.dbmigrate.schema.db_1_2_0 import User
61 from rhodecode.lib.dbmigrate.schema.db_1_2_0 import User
62
62
63 #add column
63 #add column
64 ldap_dn = Column("ldap_dn", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
64 ldap_dn = Column("ldap_dn", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
65 ldap_dn.create(User().__table__)
65 ldap_dn.create(User().__table__)
66
66
67 api_key = Column("api_key", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
67 api_key = Column("api_key", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
68 api_key.create(User().__table__)
68 api_key.create(User().__table__)
69
69
70 #remove old column
70 #remove old column
71 is_ldap = Column("is_ldap", Boolean(), nullable=False, unique=None, default=False)
71 is_ldap = Column("is_ldap", Boolean(), nullable=False, unique=None, default=False)
72 is_ldap.drop(User().__table__)
72 is_ldap.drop(User().__table__)
73
73
74
74
75 #==========================================================================
75 #==========================================================================
76 # Upgrade of `repositories` table
76 # Upgrade of `repositories` table
77 #==========================================================================
77 #==========================================================================
78 from rhodecode.lib.dbmigrate.schema.db_1_2_0 import Repository
78 from rhodecode.lib.dbmigrate.schema.db_1_2_0 import Repository
79
79
80 #ADD clone_uri column#
80 #ADD clone_uri column#
81
81
82 clone_uri = Column("clone_uri", String(length=255, convert_unicode=False,
82 clone_uri = Column("clone_uri", String(length=255, convert_unicode=False,
83 assert_unicode=None),
83 assert_unicode=None),
84 nullable=True, unique=False, default=None)
84 nullable=True, unique=False, default=None)
85
85
86 clone_uri.create(Repository().__table__)
86 clone_uri.create(Repository().__table__)
87
87
88 #ADD downloads column#
88 #ADD downloads column#
89 enable_downloads = Column("downloads", Boolean(), nullable=True, unique=None, default=True)
89 enable_downloads = Column("downloads", Boolean(), nullable=True, unique=None, default=True)
90 enable_downloads.create(Repository().__table__)
90 enable_downloads.create(Repository().__table__)
91
91
92 #ADD column created_on
92 #ADD column created_on
93 created_on = Column('created_on', DateTime(timezone=False), nullable=True,
93 created_on = Column('created_on', DateTime(timezone=False), nullable=True,
94 unique=None, default=datetime.datetime.now)
94 unique=None, default=datetime.datetime.now)
95 created_on.create(Repository().__table__)
95 created_on.create(Repository().__table__)
96
96
97 #ADD group_id column#
97 #ADD group_id column#
98 group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'),
98 group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'),
99 nullable=True, unique=False, default=None)
99 nullable=True, unique=False, default=None)
100
100
101 group_id.create(Repository().__table__)
101 group_id.create(Repository().__table__)
102
102
103
103
104 #==========================================================================
104 #==========================================================================
105 # Upgrade of `user_followings` table
105 # Upgrade of `user_followings` table
106 #==========================================================================
106 #==========================================================================
107
107
108 from rhodecode.lib.dbmigrate.schema.db_1_2_0 import UserFollowing
108 from rhodecode.lib.dbmigrate.schema.db_1_2_0 import UserFollowing
109
109
110 follows_from = Column('follows_from', DateTime(timezone=False),
110 follows_from = Column('follows_from', DateTime(timezone=False),
111 nullable=True, unique=None,
111 nullable=True, unique=None,
112 default=datetime.datetime.now)
112 default=datetime.datetime.now)
113 follows_from.create(UserFollowing().__table__)
113 follows_from.create(UserFollowing().__table__)
114
114
115 return
115 return
116
116
117
117
118 def downgrade(migrate_engine):
118 def downgrade(migrate_engine):
119 meta = MetaData()
119 meta = MetaData()
120 meta.bind = migrate_engine
120 meta.bind = migrate_engine
General Comments 0
You need to be logged in to leave comments. Login now