annotate rhodecode/lib/dbmigrate/__init__.py @ 4116:ffd45b185016 rhodecode-2.2.5-gpl

Imported some of the GPLv3'd changes from RhodeCode v2.2.5. This imports changes between changesets 21af6c4eab3d and 6177597791c2 in RhodeCode's original repository, including only changes to Python files and HTML. RhodeCode clearly licensed its changes to these files under GPLv3 in their /LICENSE file, which states the following: The Python code and integrated HTML are licensed under the GPLv3 license. (See: https://code.rhodecode.com/rhodecode/files/v2.2.5/LICENSE or http://web.archive.org/web/20140512193334/https://code.rhodecode.com/rhodecode/files/f3b123159901f15426d18e3dc395e8369f70ebe0/LICENSE for an online copy of that LICENSE file) Conservancy reviewed these changes and confirmed that they can be licensed as a whole to the Kallithea project under GPLv3-only. While some of the contents committed herein are clearly licensed GPLv3-or-later, on the whole we must assume the are GPLv3-only, since the statement above from RhodeCode indicates that they intend GPLv3-only as their license, per GPLv3ยง14 and other relevant sections of GPLv3.
author Bradley M. Kuhn <bkuhn@sfconservancy.org>
date Wed, 02 Jul 2014 19:03:13 -0400
parents 3563bb7b4b82
children 7e5f8c12a3fc
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 -*-
1206
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
2 # This program is free software: you can redistribute it and/or modify
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
3 # it under the terms of the GNU General Public License as published by
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
4 # the Free Software Foundation, either version 3 of the License, or
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
5 # (at your option) any later version.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 902
diff changeset
6 #
833
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 # 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
8 # 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
9 # 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
10 # GNU General Public License for more details.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 902
diff changeset
11 #
833
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 # You should have received a copy of the GNU General Public License
1206
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
14 """
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
15 rhodecode.lib.dbmigrate.__init__
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
16 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
17
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
18 Database migration modules
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
19
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
20 :created_on: Dec 11, 2010
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
21 :author: marcink
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
22 :copyright: (c) 2013 RhodeCode GmbH.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
23 :license: GPLv3, see LICENSE for more details.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
24 """
833
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
25
835
08d2dcd71666 fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents: 833
diff changeset
26 import logging
08d2dcd71666 fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents: 833
diff changeset
27 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
28
839
ad66bd0e5601 moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents: 838
diff changeset
29
833
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 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
31 from rhodecode.lib.db_manage import DbManage
833
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32
835
08d2dcd71666 fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents: 833
diff changeset
33 log = logging.getLogger(__name__)
833
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34
1210
3bd2e94cbfc8 pep8ify
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
35
833
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
36 class UpgradeDb(BasePasterCommand):
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
37 """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
38 """
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 max_args = 1
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
41 min_args = 1
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43 usage = "CONFIG_FILE"
3339
b76a595b7a5e pasters RhodeCode commands help text improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
44 summary = "Upgrades current db to newer version"
833
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45 group_name = "RhodeCode"
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47 parser = Command.standard_parser(verbose=True)
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 def command(self):
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 from pylons import config
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 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
52
836
28a4bb11bb6f dbmigrations:
Marcin Kuzminski <marcin@python-works.com>
parents: 835
diff changeset
53 db_uri = config['sqlalchemy.db1.url']
837
60cbde084047 fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 836
diff changeset
54 dbmanage = DbManage(log_sql=True, dbconf=db_uri,
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
55 root=config['here'], tests=False,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
56 cli_args=self.options.__dict__)
839
ad66bd0e5601 moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents: 838
diff changeset
57 dbmanage.upgrade()
837
60cbde084047 fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents: 836
diff changeset
58
833
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
59 def update_parser(self):
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
60 self.parser.add_option('--sql',
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61 action='store_true',
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
62 dest='just_sql',
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
63 help="Prints upgrade sql for further investigation",
9753e0907827 added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64 default=False)
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
65
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
66 self.parser.add_option('--force-yes',
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
67 action='store_true',
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
68 dest='force_ask',
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
69 default=None,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
70 help='Force yes to every question')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
71 self.parser.add_option('--force-no',
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
72 action='store_false',
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
73 dest='force_ask',
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
74 default=None,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3700
diff changeset
75 help='Force no to every question')