credativ team mailing list archive
-
credativ team
-
Mailing list archive
-
Message #04921
[Merge] lp:~zaber/openupgrade-addons/directory-parent into lp:openupgrade-addons/6.0
Don Kirkby has proposed merging lp:~zaber/openupgrade-addons/directory-parent into lp:openupgrade-addons/6.0.
Requested reviews:
OpenUpgrade Committers (openupgrade-committers)
Related bugs:
Bug #1025896 in OpenUpgrade Addons: "New parent constraint is violated on document directories"
https://bugs.launchpad.net/openupgrade-addons/+bug/1025896
For more details, see:
https://code.launchpad.net/~zaber/openupgrade-addons/directory-parent/+merge/115443
Fixes bug 1025896 by manually adding the storage_id column to document_directory.
--
https://code.launchpad.net/~zaber/openupgrade-addons/directory-parent/+merge/115443
Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~zaber/openupgrade-addons/directory-parent into lp:openupgrade-addons/6.0.
=== 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:36:20 +0000
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openupgrade import openupgrade
+
+@openupgrade.migrate()
+def migrate(cr, version):
+ storage_id = openupgrade.find_valid_id(cr, 'document_storage')
+ cr.execute("""\
+UPDATE document_directory
+SET storage_id = %d,
+ parent_id = NULL
+WHERE storage_id = -1
+""" % storage_id)
+ cr.execute("""\
+ALTER TABLE document_directory
+ADD CONSTRAINT document_directory_storage_id_fkey
+FOREIGN KEY (storage_id) REFERENCES document_storage (id) ON DELETE SET NULL
+""")
=== 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:36:20 +0000
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openupgrade import openupgrade
+
+@openupgrade.migrate()
+def migrate(cr, version):
+ #It's impossible to add the storage_id and the new constraints at the
+ #same time, so we have to add the column first with some dummy value and
+ #no foreign key. It will be properly configured in the post-migration.
+
+ cr.execute("""\
+ALTER TABLE document_directory
+ADD COLUMN storage_id integer
+""")
+ cr.execute("""\
+UPDATE document_directory
+SET storage_id = -1
+WHERE parent_id IS NULL
+""")