File tree Expand file tree Collapse file tree 2 files changed +11
-13
lines changed Expand file tree Collapse file tree 2 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -19,12 +19,11 @@ SET depends_on_array = CASE
19
19
WHEN jsonb_typeof(depends_on) = ' array' THEN
20
20
ARRAY(
21
21
SELECT elem::UUID
22
- FROM jsonb_array_elements_text(depends_on) AS elem(value)
23
- WHERE elem . value ~ ' ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$'
22
+ FROM jsonb_array_elements_text(depends_on) AS elem
23
+ WHERE elem:: text ~ ' ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$'
24
24
)
25
25
ELSE ' {}' ::UUID[]
26
- END
27
- WHERE depends_on_array = ' {}' ;
26
+ END;
28
27
29
28
-- Handle dependents column with UUID validation
30
29
UPDATE hammerwork_jobs
@@ -33,12 +32,11 @@ SET dependents_array = CASE
33
32
WHEN jsonb_typeof(dependents) = ' array' THEN
34
33
ARRAY(
35
34
SELECT elem::UUID
36
- FROM jsonb_array_elements_text(dependents) AS elem(value)
37
- WHERE elem . value ~ ' ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$'
35
+ FROM jsonb_array_elements_text(dependents) AS elem
36
+ WHERE elem:: text ~ ' ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$'
38
37
)
39
38
ELSE ' {}' ::UUID[]
40
- END
41
- WHERE dependents_array = ' {}' ;
39
+ END;
42
40
43
41
-- Step 3: Verify data migration integrity
44
42
DO $$
Original file line number Diff line number Diff line change @@ -1779,19 +1779,19 @@ impl DatabaseQueue for crate::queue::JobQueue<Postgres> {
1779
1779
r#"
1780
1780
SELECT id, depends_on
1781
1781
FROM hammerwork_jobs
1782
- WHERE depends_on @> $1::jsonb
1782
+ WHERE $1 = ANY(depends_on)
1783
1783
AND dependency_status = 'waiting'
1784
1784
"# ,
1785
1785
)
1786
- . bind ( serde_json :: json! ( [ completed_job_id] ) )
1786
+ . bind ( completed_job_id)
1787
1787
. fetch_all ( & self . pool )
1788
1788
. await ?;
1789
1789
1790
1790
let mut resolved_jobs = Vec :: new ( ) ;
1791
1791
1792
1792
for job_row in dependent_jobs {
1793
1793
let job_id: uuid:: Uuid = job_row. get ( "id" ) ;
1794
- let depends_on: Vec < uuid:: Uuid > = serde_json :: from_value ( job_row. get ( "depends_on" ) ) ? ;
1794
+ let depends_on: Vec < uuid:: Uuid > = job_row. get ( "depends_on" ) ;
1795
1795
1796
1796
// Check if all dependencies are now satisfied
1797
1797
let satisfied_count = sqlx:: query_scalar :: < _ , i64 > (
@@ -1860,12 +1860,12 @@ impl DatabaseQueue for crate::queue::JobQueue<Postgres> {
1860
1860
r#"
1861
1861
SELECT id
1862
1862
FROM hammerwork_jobs
1863
- WHERE depends_on @> $1::jsonb
1863
+ WHERE $1 = ANY(depends_on)
1864
1864
AND dependency_status IN ('waiting', 'satisfied')
1865
1865
AND status = 'Pending'
1866
1866
"# ,
1867
1867
)
1868
- . bind ( serde_json :: json! ( [ current_job_id] ) )
1868
+ . bind ( current_job_id)
1869
1869
. fetch_all ( & self . pool )
1870
1870
. await ?;
1871
1871
You can’t perform that action at this time.
0 commit comments