From ba9f49c817e321af0c4b1acbca7b48e8513b389e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Alix?= Date: Wed, 6 Mar 2024 12:03:03 +0100 Subject: [PATCH] queue_job: fix partial index to add 'wait_dependencies' state --- queue_job/__manifest__.py | 2 +- queue_job/migrations/14.0.3.5.2/pre-migration.py | 12 ++++++++++++ queue_job/models/queue_job.py | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 queue_job/migrations/14.0.3.5.2/pre-migration.py diff --git a/queue_job/__manifest__.py b/queue_job/__manifest__.py index 56129042c0..3b3caae4aa 100644 --- a/queue_job/__manifest__.py +++ b/queue_job/__manifest__.py @@ -2,7 +2,7 @@ { "name": "Job Queue", - "version": "14.0.3.5.1", + "version": "14.0.3.5.2", "author": "Camptocamp,ACSONE SA/NV,Odoo Community Association (OCA)", "website": "https://github.com/OCA/queue", "license": "LGPL-3", diff --git a/queue_job/migrations/14.0.3.5.2/pre-migration.py b/queue_job/migrations/14.0.3.5.2/pre-migration.py new file mode 100644 index 0000000000..7a2bca2e07 --- /dev/null +++ b/queue_job/migrations/14.0.3.5.2/pre-migration.py @@ -0,0 +1,12 @@ +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) + +from odoo.tools.sql import table_exists + + +def migrate(cr, version): + if table_exists(cr, "queue_job"): + # Drop index 'queue_job_identity_key_state_partial_index', + # it will be recreated during the update + cr.execute( + "DROP INDEX IF EXISTS queue_job_identity_key_state_partial_index;" + ) diff --git a/queue_job/models/queue_job.py b/queue_job/models/queue_job.py index 791c54db13..03aa60d60d 100644 --- a/queue_job/models/queue_job.py +++ b/queue_job/models/queue_job.py @@ -139,7 +139,7 @@ def init(self): self._cr.execute( "CREATE INDEX queue_job_identity_key_state_partial_index " "ON queue_job (identity_key) WHERE state in ('pending', " - "'enqueued') AND identity_key IS NOT NULL;" + "'enqueued', 'wait_dependencies') AND identity_key IS NOT NULL;" ) @api.depends("records")