Skip to content

Commit 9ea78c5

Browse files
author
Milan Topuzov
committed
models(queue_job): drop index_exists guards around create_index
Align with review: create_index already checks existence; no functional change.
1 parent 231705d commit 9ea78c5

1 file changed

Lines changed: 21 additions & 23 deletions

File tree

queue_job/models/queue_job.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from odoo import api, exceptions, fields, models
99
from odoo.tools import config, html_escape
10-
from odoo.tools.sql import create_index, index_exists
10+
from odoo.tools.sql import create_index
1111

1212
from odoo.addons.base_sparse_field.models.fields import Serialized
1313

@@ -131,28 +131,26 @@ def init(self):
131131
cr = self.env.cr
132132
index_1 = "queue_job_identity_key_state_partial_index"
133133
index_2 = "queue_job_channel_date_done_date_created_index"
134-
if not index_exists(cr, index_1):
135-
# Used by Job.job_record_with_same_identity_key
136-
create_index(
137-
cr,
138-
index_1,
139-
"queue_job",
140-
["identity_key"],
141-
where=(
142-
"state in ('pending','enqueued','wait_dependencies') "
143-
"AND identity_key IS NOT NULL"
144-
),
145-
comment=("Queue Job: partial index for identity_key on active states"),
146-
)
147-
if not index_exists(cr, index_2):
148-
# Used by <queue.job>.autovacuum
149-
create_index(
150-
cr,
151-
index_2,
152-
"queue_job",
153-
["channel", "date_done", "date_created"],
154-
comment="Queue Job: index to accelerate autovacuum",
155-
)
134+
# Used by Job.job_record_with_same_identity_key
135+
create_index(
136+
cr,
137+
index_1,
138+
"queue_job",
139+
["identity_key"],
140+
where=(
141+
"state in ('pending','enqueued','wait_dependencies') "
142+
"AND identity_key IS NOT NULL"
143+
),
144+
comment=("Queue Job: partial index for identity_key on active states"),
145+
)
146+
# Used by <queue.job>.autovacuum
147+
create_index(
148+
cr,
149+
index_2,
150+
"queue_job",
151+
["channel", "date_done", "date_created"],
152+
comment="Queue Job: index to accelerate autovacuum",
153+
)
156154

157155
@api.depends("dependencies")
158156
def _compute_dependency_graph(self):

0 commit comments

Comments
 (0)