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