Mercurial > kallithea
comparison rhodecode/lib/db_manage.py @ 1203:6832ef664673 beta
source code cleanup: remove trailing white space, normalize file endings
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 03 Apr 2011 18:23:15 +0200 |
parents | 9c45e11493fb |
children | a671db5bdd58 |
comparison
equal
deleted
inserted
replaced
1202:eef9e273347a | 1203:6832ef664673 |
---|---|
3 rhodecode.lib.db_manage | 3 rhodecode.lib.db_manage |
4 ~~~~~~~~~~~~~~~~~~~~~~~ | 4 ~~~~~~~~~~~~~~~~~~~~~~~ |
5 | 5 |
6 Database creation, and setup module for RhodeCode. Used for creation | 6 Database creation, and setup module for RhodeCode. Used for creation |
7 of database as well as for migration operations | 7 of database as well as for migration operations |
8 | 8 |
9 :created_on: Apr 10, 2010 | 9 :created_on: Apr 10, 2010 |
10 :author: marcink | 10 :author: marcink |
11 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> | 11 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> |
12 :license: GPLv3, see COPYING for more details. | 12 :license: GPLv3, see COPYING for more details. |
13 """ | 13 """ |
14 # This program is free software; you can redistribute it and/or | 14 # This program is free software; you can redistribute it and/or |
15 # modify it under the terms of the GNU General Public License | 15 # modify it under the terms of the GNU General Public License |
16 # as published by the Free Software Foundation; version 2 | 16 # as published by the Free Software Foundation; version 2 |
17 # of the License or (at your opinion) any later version of the license. | 17 # of the License or (at your opinion) any later version of the license. |
18 # | 18 # |
19 # This program is distributed in the hope that it will be useful, | 19 # This program is distributed in the hope that it will be useful, |
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 20 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 # GNU General Public License for more details. | 22 # GNU General Public License for more details. |
23 # | 23 # |
24 # You should have received a copy of the GNU General Public License | 24 # You should have received a copy of the GNU General Public License |
25 # along with this program; if not, write to the Free Software | 25 # along with this program; if not, write to the Free Software |
26 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | 26 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
27 # MA 02110-1301, USA. | 27 # MA 02110-1301, USA. |
28 | 28 |
93 raise | 93 raise |
94 log.info('db version set to: %s', __dbversion__) | 94 log.info('db version set to: %s', __dbversion__) |
95 | 95 |
96 | 96 |
97 def upgrade(self): | 97 def upgrade(self): |
98 """Upgrades given database schema to given revision following | 98 """Upgrades given database schema to given revision following |
99 all needed steps, to perform the upgrade | 99 all needed steps, to perform the upgrade |
100 | 100 |
101 """ | 101 """ |
102 | 102 |
103 from rhodecode.lib.dbmigrate.migrate.versioning import api | 103 from rhodecode.lib.dbmigrate.migrate.versioning import api |
104 from rhodecode.lib.dbmigrate.migrate.exceptions import \ | 104 from rhodecode.lib.dbmigrate.migrate.exceptions import \ |
105 DatabaseNotControlledError | 105 DatabaseNotControlledError |
132 | 132 |
133 #====================================================================== | 133 #====================================================================== |
134 # UPGRADE STEPS | 134 # UPGRADE STEPS |
135 #====================================================================== | 135 #====================================================================== |
136 class UpgradeSteps(object): | 136 class UpgradeSteps(object): |
137 """Those steps follow schema versions so for example schema | 137 """Those steps follow schema versions so for example schema |
138 for example schema with seq 002 == step_2 and so on. | 138 for example schema with seq 002 == step_2 and so on. |
139 """ | 139 """ |
140 | 140 |
141 def __init__(self, klass): | 141 def __init__(self, klass): |
142 self.klass = klass | 142 self.klass = klass |
259 self.create_user('test_regular2', 'test12', 'test_regular2@mail.com', False) | 259 self.create_user('test_regular2', 'test12', 'test_regular2@mail.com', False) |
260 | 260 |
261 def create_ui_settings(self): | 261 def create_ui_settings(self): |
262 """Creates ui settings, fills out hooks | 262 """Creates ui settings, fills out hooks |
263 and disables dotencode | 263 and disables dotencode |
264 | 264 |
265 """ | 265 """ |
266 #HOOKS | 266 #HOOKS |
267 hooks1_key = 'changegroup.update' | 267 hooks1_key = 'changegroup.update' |
268 hooks1_ = self.sa.query(RhodeCodeUi)\ | 268 hooks1_ = self.sa.query(RhodeCodeUi)\ |
269 .filter(RhodeCodeUi.ui_key == hooks1_key).scalar() | 269 .filter(RhodeCodeUi.ui_key == hooks1_key).scalar() |
514 self.sa.add(default_repo_perm) | 514 self.sa.add(default_repo_perm) |
515 self.sa.commit() | 515 self.sa.commit() |
516 except: | 516 except: |
517 self.sa.rollback() | 517 self.sa.rollback() |
518 raise | 518 raise |
519 |