Merge lp:~therp-nl/openupgrade-addons/6.1_membership into lp:openupgrade-addons/6.1

Proposed by Holger Brunn (Therp)
Status: Merged
Merged at revision: 6615
Proposed branch: lp:~therp-nl/openupgrade-addons/6.1_membership
Merge into: lp:openupgrade-addons/6.1
Diff against target: 37 lines (+33/-0)
1 file modified
membership/migrations/6.1.0.1/pre-migration.py (+33/-0)
To merge this branch: bzr merge lp:~therp-nl/openupgrade-addons/6.1_membership
Reviewer Review Type Date Requested Status
Stefan Rijnhart (Opener) Approve
Review via email: mp+138886@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks! I see this column type change is a generic change in function fields of type 'selection'. Can't we conjure up a generic solution to always cast from type text to type varchar(0) in BaseModel.__auto_init()?

review: Needs Information
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

I had the same idea in the beginning, but you can't change the type of a column on which other objects (views in openerp's case mostly) depend. And I couldn't find a reliable way to first determine which views depend on a column and second if it's save to just drop them.

So I think it's safer to deal with that on a by-column base.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

I thought you would have given it some thought already ;-)

In that case, a remark about this in the documentation of OpenUpgrade 6.1 would be much appreciated.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'membership/migrations/6.1.0.1/pre-migration.py'
2--- membership/migrations/6.1.0.1/pre-migration.py 1970-01-01 00:00:00 +0000
3+++ membership/migrations/6.1.0.1/pre-migration.py 2012-12-09 16:47:26 +0000
4@@ -0,0 +1,33 @@
5+# -*- coding: utf-8 -*-
6+##############################################################################
7+#
8+# OpenERP, Open Source Management Solution
9+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
10+#
11+# This program is free software: you can redistribute it and/or modify
12+# it under the terms of the GNU Affero General Public License as
13+# published by the Free Software Foundation, either version 3 of the
14+# License, or (at your option) any later version.
15+#
16+# This program is distributed in the hope that it will be useful,
17+# but WITHOUT ANY WARRANTY; without even the implied warranty of
18+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+# GNU Affero General Public License for more details.
20+#
21+# You should have received a copy of the GNU Affero General Public License
22+# along with this program. If not, see <http://www.gnu.org/licenses/>.
23+#
24+##############################################################################
25+
26+from openupgrade import openupgrade
27+
28+@openupgrade.migrate()
29+def migrate(cr, version):
30+ #we need to drop this view because it depends on state
31+ #it will be recreated anyway
32+ cr.execute('''drop view report_membership''')
33+ #type of functional selection fields changed from text to varchar
34+ cr.execute('''
35+ alter table membership_membership_line alter state type varchar''')
36+ cr.execute('''
37+ alter table res_partner alter membership_state type varchar''')

Subscribers

People subscribed via source and target branches