Merge lp:~pedro.baeza/openupgrade-addons/6.1-fetchmail into lp:openupgrade-addons/6.1

Proposed by Pedro Manuel Baeza
Status: Merged
Merged at revision: 6619
Proposed branch: lp:~pedro.baeza/openupgrade-addons/6.1-fetchmail
Merge into: lp:openupgrade-addons/6.1
Diff against target: 56 lines (+52/-0)
1 file modified
fetchmail/migrations/6.1.1.0/pre-migration.py (+52/-0)
To merge this branch: bzr merge lp:~pedro.baeza/openupgrade-addons/6.1-fetchmail
Reviewer Review Type Date Requested Status
Paulius Sladkevičius @ hbee (community) Approve
Stefan Rijnhart (Opener) Approve
Review via email: mp+133469@code.launchpad.net

Commit message

[ADD] Migration script for module 'fetchmail'.

Description of the change

[ADD] Migration script for module 'fetchmail'.

To post a comment you must log in.
Revision history for this message
Paulius Sladkevičius @ hbee (komsas) wrote :

I found that selection field 'state' on the 6.0 - draft, waiting, done, but 6.1 have 2 only draft, done, I suggest to map 'waiting' to 'draft'.

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

Hi Pedro,

this proposal is set to 'Work in progress', which is why it did not get reviewed earlier on. Does it need any more work as far as you are concerned?

From my part, please use the @migrate decorator to replace the try/catch block, the logging part and the version check. And Paulius' suggestion looks good to me too.

review: Needs Fixing
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Stefan and Paulius,

Thanks for your reviews. I was very newbie when I made this MP, so please excuse me if I did something wrong in the MP status.

I have made the changes you have proposed. Please check them.

Regards.

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

Thank you Pedro! To finish it off, you can remove the now unsed imports of os, logging and osv from the file. l.31 is now unused too, and I would appreciate if you could break up lines 9 and 48 to respect PEP max. line length.

review: Needs Fixing
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi again, Stefan,

Thank you very much for your appreciations. I'm a little unaware of this details, but I will try to take in care for future apports.

Regards.

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

Thanks for the changes!

review: Approve
Revision history for this message
Paulius Sladkevičius @ hbee (komsas) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'fetchmail/migrations/6.1.1.0/pre-migration.py'
2--- fetchmail/migrations/6.1.1.0/pre-migration.py 1970-01-01 00:00:00 +0000
3+++ fetchmail/migrations/6.1.1.0/pre-migration.py 2013-07-18 10:21:25 +0000
4@@ -0,0 +1,52 @@
5+# -*- coding: utf-8 -*-
6+##############################################################################
7+#
8+# OpenERP, Open Source Management Solution
9+# Copyright (c) 2013 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
10+# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
11+#
12+# This program is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU Affero General Public License as
14+# published by the Free Software Foundation, either version 3 of the
15+# License, or (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU Affero General Public License for more details.
21+#
22+# You should have received a copy of the GNU Affero General Public License
23+# along with this program. If not, see <http://www.gnu.org/licenses/>.
24+#
25+##############################################################################
26+
27+from openerp.openupgrade import openupgrade
28+
29+me = __file__
30+
31+column_renames = {
32+ 'mail_message': [
33+ ('server_id', 'fetchmail_server_id'),
34+ ],
35+ }
36+
37+table_renames = [
38+ ('email_server', 'fetchmail_server'),
39+ ]
40+
41+model_renames = [
42+ ('email.server', 'fetchmail.server'),
43+ ]
44+
45+def _change_waiting_state(cr):
46+ openupgrade.logged_query(cr, "UPDATE fetchmail_server \
47+ SET state='draft' \
48+ WHERE state='waiting'")
49+
50+@openupgrade.migrate()
51+def migrate(cr, version):
52+ if openupgrade.table_exists(cr, 'email_server'):
53+ openupgrade.rename_tables(cr, table_renames)
54+ openupgrade.rename_columns(cr, column_renames)
55+ openupgrade.rename_models(cr, model_renames)
56+ _change_waiting_state(cr)

Subscribers

People subscribed via source and target branches