Skip to content

Commit

Permalink
change schedule "name" to "task_queue_name" (#58)
Browse files Browse the repository at this point in the history
This is a relatively minor change that ensures schedule rows follow the
same convention as task and task attempt rows by referencing the
associated queue as "task_queue_name".
  • Loading branch information
maxcountryman authored Nov 11, 2024
1 parent 7c7792f commit 44a0e05
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 34 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions migrations/20241111174958_4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Force anything running this migration to use the right search path.
set local search_path to underway;

-- Rename the 'name' column in 'task_schedule' to 'task_queue_name' for consistency.
alter table underway.task_schedule
rename column name to task_queue_name;

-- Update the primary key constraint to use the new column name.
alter table underway.task_schedule
drop constraint task_schedule_pkey,
add primary key (task_queue_name);
16 changes: 9 additions & 7 deletions src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,12 +798,12 @@ impl<T: Task> Queue<T> {
sqlx::query!(
r#"
insert into underway.task_schedule (
name,
task_queue_name,
schedule,
timezone,
input
) values ($1, $2, $3, $4)
on conflict (name) do update
on conflict (task_queue_name) do update
set
schedule = excluded.schedule,
timezone = excluded.timezone,
Expand Down Expand Up @@ -883,7 +883,7 @@ impl<T: Task> Queue<T> {
sqlx::query!(
r#"
delete from underway.task_schedule
where name = $1
where task_queue_name = $1
"#,
self.name,
)
Expand All @@ -903,7 +903,7 @@ impl<T: Task> Queue<T> {
{
let Some(schedule_row) = sqlx::query!(
r#"
select schedule, timezone, input from underway.task_schedule where name = $1
select schedule, timezone, input from underway.task_schedule where task_queue_name = $1
limit 1
"#,
self.name,
Expand Down Expand Up @@ -2214,7 +2214,7 @@ mod tests {
// Check the schedule was actually set
let schedule_row = sqlx::query!(
r#"
select schedule, timezone, input from underway.task_schedule where name = $1
select schedule, timezone, input from underway.task_schedule where task_queue_name = $1
"#,
"schedule"
)
Expand Down Expand Up @@ -2256,7 +2256,7 @@ mod tests {
r#"
select schedule, timezone, input
from underway.task_schedule
where name = $1
where task_queue_name = $1
"#,
queue.name
)
Expand Down Expand Up @@ -2330,7 +2330,9 @@ mod tests {
// Check the schedule was actually set
let schedule_row = sqlx::query!(
r#"
select schedule from underway.task_schedule where name = $1
select schedule
from underway.task_schedule
where task_queue_name = $1
"#,
"schedule"
)
Expand Down

0 comments on commit 44a0e05

Please sign in to comment.