|
7 | 7 |
|
8 | 8 | from odoo import api, exceptions, fields, models |
9 | 9 | 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 |
11 | 11 |
|
12 | 12 | from odoo.addons.base_sparse_field.models.fields import Serialized |
13 | 13 |
|
@@ -131,28 +131,26 @@ def init(self): |
131 | 131 | cr = self.env.cr |
132 | 132 | index_1 = "queue_job_identity_key_state_partial_index" |
133 | 133 | 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 | + ) |
156 | 154 |
|
157 | 155 | @api.depends("dependencies") |
158 | 156 | def _compute_dependency_graph(self): |
|
0 commit comments