Show More
@@ -40,7 +40,6 b' from rhodecode.model.db import User, Per' | |||
|
40 | 40 | UserRepoGroupToPerm |
|
41 | 41 | |
|
42 | 42 | from sqlalchemy.engine import create_engine |
|
43 | from sqlalchemy.schema import MetaData | |
|
44 | 43 | from rhodecode.model.repos_group import ReposGroupModel |
|
45 | 44 | #from rhodecode.model import meta |
|
46 | 45 | from rhodecode.model.meta import Session, Base |
@@ -49,6 +48,14 b' from rhodecode.model.meta import Session' | |||
|
49 | 48 | log = logging.getLogger(__name__) |
|
50 | 49 | |
|
51 | 50 | |
|
51 | def notify(msg): | |
|
52 | """ | |
|
53 | Notification for migrations messages | |
|
54 | """ | |
|
55 | ml = len(msg) + (4 * 2) | |
|
56 | print >> sys.stdout, ('*** %s ***\n%s' % (msg, '*' * ml)).upper() | |
|
57 | ||
|
58 | ||
|
52 | 59 | class DbManage(object): |
|
53 | 60 | def __init__(self, log_sql, dbconf, root, tests=False): |
|
54 | 61 | self.dbname = dbconf.split('/')[-1] |
@@ -130,7 +137,7 b' class DbManage(object):' | |||
|
130 | 137 | ' as version %s' % curr_version) |
|
131 | 138 | api.version_control(db_uri, repository_path, curr_version) |
|
132 | 139 | |
|
133 |
|
|
|
140 | notify(msg) | |
|
134 | 141 | |
|
135 | 142 | if curr_version == __dbversion__: |
|
136 | 143 | sys.exit('This database is already at the newest version') |
@@ -138,6 +145,7 b' class DbManage(object):' | |||
|
138 | 145 | #====================================================================== |
|
139 | 146 | # UPGRADE STEPS |
|
140 | 147 | #====================================================================== |
|
148 | ||
|
141 | 149 | class UpgradeSteps(object): |
|
142 | 150 | """ |
|
143 | 151 | Those steps follow schema versions so for example schema |
@@ -149,32 +157,32 b' class DbManage(object):' | |||
|
149 | 157 | |
|
150 | 158 | def step_0(self): |
|
151 | 159 | # step 0 is the schema upgrade, and than follow proper upgrades |
|
152 |
|
|
|
160 | notify('attempting to do database upgrade to version %s' \ | |
|
153 | 161 | % __dbversion__) |
|
154 | 162 | api.upgrade(db_uri, repository_path, __dbversion__) |
|
155 |
|
|
|
163 | notify('Schema upgrade completed') | |
|
156 | 164 | |
|
157 | 165 | def step_1(self): |
|
158 | 166 | pass |
|
159 | 167 | |
|
160 | 168 | def step_2(self): |
|
161 |
|
|
|
169 | notify('Patching repo paths for newer version of RhodeCode') | |
|
162 | 170 | self.klass.fix_repo_paths() |
|
163 | 171 | |
|
164 |
|
|
|
172 | notify('Patching default user of RhodeCode') | |
|
165 | 173 | self.klass.fix_default_user() |
|
166 | 174 | |
|
167 | 175 | log.info('Changing ui settings') |
|
168 | 176 | self.klass.create_ui_settings() |
|
169 | 177 | |
|
170 | 178 | def step_3(self): |
|
171 |
|
|
|
179 | notify('Adding additional settings into RhodeCode db') | |
|
172 | 180 | self.klass.fix_settings() |
|
173 |
|
|
|
181 | notify('Adding ldap defaults') | |
|
174 | 182 | self.klass.create_ldap_options(skip_existing=True) |
|
175 | 183 | |
|
176 | 184 | def step_4(self): |
|
177 |
|
|
|
185 | notify('create permissions and fix groups') | |
|
178 | 186 | self.klass.create_permissions() |
|
179 | 187 | self.klass.fixup_groups() |
|
180 | 188 | |
@@ -182,23 +190,37 b' class DbManage(object):' | |||
|
182 | 190 | pass |
|
183 | 191 | |
|
184 | 192 | def step_6(self): |
|
185 | print ('re-checking permissions') | |
|
193 | ||
|
194 | notify('re-checking permissions') | |
|
186 | 195 | self.klass.create_permissions() |
|
187 | 196 | |
|
188 |
|
|
|
197 | notify('fixing old PULL hook') | |
|
198 | _pull = RhodeCodeUi.get_by_key('preoutgoing.pull_logger') | |
|
199 | if _pull: | |
|
200 | _pull.ui_key = RhodeCodeUi.HOOK_PULL | |
|
201 | Session().add(_pull) | |
|
202 | ||
|
203 | notify('fixing old PUSH hook') | |
|
204 | _push = RhodeCodeUi.get_by_key('pretxnchangegroup.push_logger') | |
|
205 | if _push: | |
|
206 | _push.ui_key = RhodeCodeUi.HOOK_PUSH | |
|
207 | Session().add(_push) | |
|
208 | ||
|
209 | notify('installing new pre-push hook') | |
|
189 | 210 | hooks4 = RhodeCodeUi() |
|
190 | 211 | hooks4.ui_section = 'hooks' |
|
191 | 212 | hooks4.ui_key = RhodeCodeUi.HOOK_PRE_PUSH |
|
192 | 213 | hooks4.ui_value = 'python:rhodecode.lib.hooks.pre_push' |
|
193 | 214 | Session().add(hooks4) |
|
194 | 215 | |
|
216 | notify('installing new pre-pull hook') | |
|
195 | 217 | hooks6 = RhodeCodeUi() |
|
196 | 218 | hooks6.ui_section = 'hooks' |
|
197 | 219 | hooks6.ui_key = RhodeCodeUi.HOOK_PRE_PULL |
|
198 | 220 | hooks6.ui_value = 'python:rhodecode.lib.hooks.pre_pull' |
|
199 | 221 | Session().add(hooks6) |
|
200 | 222 | |
|
201 |
|
|
|
223 | notify('installing hgsubversion option') | |
|
202 | 224 | # enable hgsubversion disabled by default |
|
203 | 225 | hgsubversion = RhodeCodeUi() |
|
204 | 226 | hgsubversion.ui_section = 'extensions' |
@@ -207,7 +229,7 b' class DbManage(object):' | |||
|
207 | 229 | hgsubversion.ui_active = False |
|
208 | 230 | Session().add(hgsubversion) |
|
209 | 231 | |
|
210 |
|
|
|
232 | notify('installing hg git option') | |
|
211 | 233 | # enable hggit disabled by default |
|
212 | 234 | hggit = RhodeCodeUi() |
|
213 | 235 | hggit.ui_section = 'extensions' |
@@ -216,16 +238,20 b' class DbManage(object):' | |||
|
216 | 238 | hggit.ui_active = False |
|
217 | 239 | Session().add(hggit) |
|
218 | 240 | |
|
219 |
|
|
|
241 | notify('re-check default permissions') | |
|
220 | 242 | self.klass.populate_default_permissions() |
|
221 | 243 | |
|
222 | 244 | upgrade_steps = [0] + range(curr_version + 1, __dbversion__ + 1) |
|
223 | 245 | |
|
224 | 246 | # CALL THE PROPER ORDER OF STEPS TO PERFORM FULL UPGRADE |
|
247 | _step = None | |
|
225 | 248 | for step in upgrade_steps: |
|
226 |
|
|
|
249 | notify('performing upgrade step %s' % step) | |
|
227 | 250 | getattr(UpgradeSteps(self), 'step_%s' % step)() |
|
228 | 251 | self.sa.commit() |
|
252 | _step = step | |
|
253 | ||
|
254 | notify('upgrade to version %s successful' % _step) | |
|
229 | 255 | |
|
230 | 256 | def fix_repo_paths(self): |
|
231 | 257 | """ |
General Comments 0
You need to be logged in to leave comments.
Login now