annotate rhodecode/lib/dbmigrate/__init__.py @ 902:07a6e8c65526 beta

fixed copyright year to 2011
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 31 Dec 2010 19:46:56 +0100
parents ad66bd0e5601
children 6832ef664673
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
833
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 """
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 rhodecode.lib.dbmigrate.__init__
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 Database migration modules
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 :created_on: Dec 11, 2010
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 :author: marcink
902
07a6e8c65526 fixed copyright year to 2011
Marcin Kuzminski <marcin@python-works.com>
parents: 839
diff changeset
10 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
833
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 :license: GPLv3, see COPYING for more details.
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 """
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13 # This program is free software; you can redistribute it and/or
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 # modify it under the terms of the GNU General Public License
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 # as published by the Free Software Foundation; version 2
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16 # of the License or (at your opinion) any later version of the license.
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 #
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18 # This program is distributed in the hope that it will be useful,
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
21 # GNU General Public License for more details.
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
22 #
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
23 # You should have received a copy of the GNU General Public License
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
24 # along with this program; if not, write to the Free Software
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26 # MA 02110-1301, USA.
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27
835
08d2dcd71666 fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents: 833
diff changeset
28 import logging
08d2dcd71666 fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents: 833
diff changeset
29 from sqlalchemy import engine_from_config
08d2dcd71666 fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents: 833
diff changeset
30
839
ad66bd0e5601 moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents: 838
diff changeset
31
833
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32 from rhodecode.lib.utils import BasePasterCommand, Command, add_cache
837
60cbde084047 fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 836
diff changeset
33 from rhodecode.lib.db_manage import DbManage
833
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34
835
08d2dcd71666 fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents: 833
diff changeset
35 log = logging.getLogger(__name__)
833
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
36
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
37 class UpgradeDb(BasePasterCommand):
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38 """Command used for paster to upgrade our database to newer version
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 """
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
41 max_args = 1
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42 min_args = 1
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44 usage = "CONFIG_FILE"
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45 summary = "Upgrades current db to newer version given configuration file"
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46 group_name = "RhodeCode"
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48 parser = Command.standard_parser(verbose=True)
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 def command(self):
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 from pylons import config
836
28a4bb11bb6f dbmigrations:
Marcin Kuzminski <marcin@python-works.com>
parents: 835
diff changeset
52
833
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53 add_cache(config)
835
08d2dcd71666 fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents: 833
diff changeset
54
836
28a4bb11bb6f dbmigrations:
Marcin Kuzminski <marcin@python-works.com>
parents: 835
diff changeset
55 db_uri = config['sqlalchemy.db1.url']
833
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56
837
60cbde084047 fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 836
diff changeset
57 dbmanage = DbManage(log_sql=True, dbconf=db_uri,
60cbde084047 fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 836
diff changeset
58 root=config['here'], tests=False)
60cbde084047 fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 836
diff changeset
59
839
ad66bd0e5601 moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents: 838
diff changeset
60 dbmanage.upgrade()
837
60cbde084047 fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 836
diff changeset
61
60cbde084047 fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 836
diff changeset
62
833
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
63
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64 def update_parser(self):
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
65 self.parser.add_option('--sql',
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
66 action='store_true',
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
67 dest='just_sql',
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68 help="Prints upgrade sql for further investigation",
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
69 default=False)