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