Merge lp:~zaber/openupgrade-addons/directory-parent into lp:openupgrade-addons/6.0

Proposed by Don Kirkby
Status: Rejected
Rejected by: Stefan Rijnhart (Opener)
Proposed branch: lp:~zaber/openupgrade-addons/directory-parent
Merge into: lp:openupgrade-addons/6.0
Diff against target: 84 lines (+75/-0)
2 files modified
document/migrations/6.0.2.1/post-migration.py (+37/-0)
document/migrations/6.0.2.1/pre-migration.py (+38/-0)
To merge this branch: bzr merge lp:~zaber/openupgrade-addons/directory-parent
Reviewer Review Type Date Requested Status
Stefan Rijnhart (Opener) Disapprove
Review via email: mp+115443@code.launchpad.net

Description of the change

Fixes bug 1025896 by manually adding the storage_id column to document_directory.

To post a comment you must log in.
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Don,

thanks for suggesting a solution to the issue. As I have explained in the issue report, we prefer to assist the database administrator in filling in these required values over filling in a random value.

Best regards,
Stefan.

review: Disapprove

Unmerged revisions

4784. By Don Kirkby

[FIX] Work around new parent constraint on document directories.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'document/migrations/6.0.2.1/post-migration.py'
--- document/migrations/6.0.2.1/post-migration.py 1970-01-01 00:00:00 +0000
+++ document/migrations/6.0.2.1/post-migration.py 2012-07-17 21:38:33 +0000
@@ -0,0 +1,37 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openupgrade import openupgrade
23
24@openupgrade.migrate()
25def migrate(cr, version):
26 storage_id = openupgrade.find_valid_id(cr, 'document_storage')
27 cr.execute("""\
28UPDATE document_directory
29SET storage_id = %d,
30 parent_id = NULL
31WHERE storage_id = -1
32""" % storage_id)
33 cr.execute("""\
34ALTER TABLE document_directory
35ADD CONSTRAINT document_directory_storage_id_fkey
36FOREIGN KEY (storage_id) REFERENCES document_storage (id) ON DELETE SET NULL
37""")
038
=== added file 'document/migrations/6.0.2.1/pre-migration.py'
--- document/migrations/6.0.2.1/pre-migration.py 1970-01-01 00:00:00 +0000
+++ document/migrations/6.0.2.1/pre-migration.py 2012-07-17 21:38:33 +0000
@@ -0,0 +1,38 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openupgrade import openupgrade
23
24@openupgrade.migrate()
25def migrate(cr, version):
26 #It's impossible to add the storage_id and the new constraints at the
27 #same time, so we have to add the column first with some dummy value and
28 #no foreign key. It will be properly configured in the post-migration.
29
30 cr.execute("""\
31ALTER TABLE document_directory
32ADD COLUMN storage_id integer
33""")
34 cr.execute("""\
35UPDATE document_directory
36SET storage_id = -1
37WHERE parent_id IS NULL
38""")

Subscribers

People subscribed via source and target branches