diff --git a/queue_job/__manifest__.py b/queue_job/__manifest__.py index ddc19b44da..be41d4bff3 100644 --- a/queue_job/__manifest__.py +++ b/queue_job/__manifest__.py @@ -2,7 +2,7 @@ {'name': 'Job Queue', - 'version': '12.0.4.1.1', + 'version': '12.0.4.1.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/12.0.4.1.2/pre-migration.py b/queue_job/migrations/12.0.4.1.2/pre-migration.py new file mode 100644 index 0000000000..704bad1ab9 --- /dev/null +++ b/queue_job/migrations/12.0.4.1.2/pre-migration.py @@ -0,0 +1,19 @@ +# 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 not table_exists(cr, "queue_job"): + return + # Drop index 'queue_job_identity_key_state_partial_index' when it misses + # the 'wait_dependencies' state, it will be recreated during the update. + # An index already built with the new predicate (e.g. created + # concurrently beforehand on a big table) is kept. + cr.execute( + "SELECT indexdef FROM pg_indexes " + "WHERE indexname = 'queue_job_identity_key_state_partial_index'" + ) + row = cr.fetchone() + if row and "wait_dependencies" not in row[0]: + cr.execute("DROP INDEX queue_job_identity_key_state_partial_index;") diff --git a/queue_job/models/queue_job.py b/queue_job/models/queue_job.py index ba3a3acfc4..abb4a9d1e6 100644 --- a/queue_job/models/queue_job.py +++ b/queue_job/models/queue_job.py @@ -148,7 +148,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")