Skip to content

Commit

Permalink
SolidQueue migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
elektronaut committed Oct 16, 2024
1 parent e907f1a commit 42d043b
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 6 deletions.
6 changes: 6 additions & 0 deletions bin/jobs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby

require_relative "../config/environment"
require "solid_queue/cli"

SolidQueue::Cli.start(ARGV)
10 changes: 5 additions & 5 deletions config/solid_queue.yml → config/queue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ default: &default
batch_size: 500
workers:
- queues: "*"
threads: 5
processes: 1
threads: 3
processes: <%= ENV.fetch("JOB_CONCURRENCY", 1) %>
polling_interval: 0.1

development:
<<: *default
<<: *default

test:
<<: *default
<<: *default

production:
<<: *default
<<: *default
10 changes: 10 additions & 0 deletions config/recurring.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# production:
# periodic_cleanup:
# class: CleanSoftDeletedRecordsJob
# queue: background
# args: [ 1000, { batch_size: 500 } ]
# schedule: every hour
# periodic_command:
# command: "SoftDeletedRecord.due.delete_all"
# priority: 2
# schedule: at 5am every day
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This migration comes from solid_queue (originally 20240218110712)
class CreateRecurringExecutions < ActiveRecord::Migration[7.1]
def change
create_table :solid_queue_recurring_executions do |t|
t.references :job, index: { unique: true }, null: false
t.string :task_key, null: false
t.datetime :run_at, null: false
t.datetime :created_at, null: false

t.index [ :task_key, :run_at ], unique: true
end

add_foreign_key :solid_queue_recurring_executions, :solid_queue_jobs, column: :job_id, on_delete: :cascade
end
end
21 changes: 21 additions & 0 deletions db/migrate/20241016075105_create_recurring_tasks.solid_queue.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This migration comes from solid_queue (originally 20240719134516)
class CreateRecurringTasks < ActiveRecord::Migration[7.1]
def change
create_table :solid_queue_recurring_tasks do |t|
t.string :key, null: false, index: { unique: true }
t.string :schedule, null: false
t.string :command, limit: 2048
t.string :class_name
t.text :arguments

t.string :queue_name
t.integer :priority, default: 0

t.boolean :static, default: true, index: true

t.text :description

t.timestamps
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This migration comes from solid_queue (originally 20240811173327)
class AddNameToProcesses < ActiveRecord::Migration[7.1]
def change
add_column :solid_queue_processes, :name, :string
end
end
17 changes: 17 additions & 0 deletions db/migrate/20241016075107_make_name_not_null.solid_queue.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This migration comes from solid_queue (originally 20240813160053)
class MakeNameNotNull < ActiveRecord::Migration[7.1]
def up
SolidQueue::Process.where(name: nil).find_each do |process|
process.name ||= [ process.kind.downcase, SecureRandom.hex(10) ].join("-")
process.save!
end

change_column :solid_queue_processes, :name, :string, null: false
add_index :solid_queue_processes, [ :name, :supervisor_id ], unique: true
end

def down
remove_index :solid_queue_processes, [ :name, :supervisor_id ]
change_column :solid_queue_processes, :name, :string, null: false
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This migration comes from solid_queue (originally 20240819165045)
class ChangeSolidQueueRecurringTasksStaticToNotNull < ActiveRecord::Migration[7.1]
def change
change_column_null :solid_queue_recurring_tasks, :static, false, true
end
end
34 changes: 33 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2024_02_04_213226) do
ActiveRecord::Schema[7.1].define(version: 2024_10_16_075108) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
enable_extension "pg_trgm"
Expand Down Expand Up @@ -161,12 +161,14 @@
t.datetime "updated_at", precision: nil, null: false
t.datetime "last_post_at", precision: nil
t.string "type", limit: 100
t.tsvector "tsv"
t.index ["created_at"], name: "index_exchanges_on_created_at"
t.index ["last_post_at"], name: "index_exchanges_on_last_post_at"
t.index ["poster_id"], name: "index_exchanges_on_poster_id"
t.index ["sticky", "last_post_at"], name: "index_exchanges_on_sticky_and_last_post_at"
t.index ["sticky"], name: "index_exchanges_on_sticky"
t.index ["trusted"], name: "index_exchanges_on_trusted"
t.index ["tsv"], name: "index_exchanges_on_tsv", using: :gin
t.index ["type"], name: "index_exchanges_on_type"
end

Expand Down Expand Up @@ -214,12 +216,14 @@
t.datetime "created_at", precision: nil, null: false
t.datetime "updated_at", precision: nil, null: false
t.boolean "deleted", default: false, null: false
t.tsvector "tsv"
t.index ["conversation"], name: "index_posts_on_conversation"
t.index ["created_at"], name: "index_posts_on_created_at"
t.index ["deleted"], name: "index_posts_on_deleted"
t.index ["exchange_id", "created_at"], name: "index_posts_on_exchange_id_and_created_at"
t.index ["exchange_id"], name: "index_posts_on_exchange_id"
t.index ["trusted"], name: "index_posts_on_trusted"
t.index ["tsv"], name: "index_posts_on_tsv", using: :gin
t.index ["user_id", "conversation"], name: "index_posts_on_user_id_and_conversation"
t.index ["user_id", "created_at"], name: "index_posts_on_user_id_and_created_at"
t.index ["user_id"], name: "index_posts_on_user_id"
Expand Down Expand Up @@ -292,7 +296,9 @@
t.string "hostname"
t.text "metadata"
t.datetime "created_at", null: false
t.string "name", null: false
t.index ["last_heartbeat_at"], name: "index_solid_queue_processes_on_last_heartbeat_at"
t.index ["name", "supervisor_id"], name: "index_solid_queue_processes_on_name_and_supervisor_id", unique: true
t.index ["supervisor_id"], name: "index_solid_queue_processes_on_supervisor_id"
end

Expand All @@ -306,6 +312,31 @@
t.index ["queue_name", "priority", "job_id"], name: "index_solid_queue_poll_by_queue"
end

create_table "solid_queue_recurring_executions", force: :cascade do |t|
t.bigint "job_id", null: false
t.string "task_key", null: false
t.datetime "run_at", null: false
t.datetime "created_at", null: false
t.index ["job_id"], name: "index_solid_queue_recurring_executions_on_job_id", unique: true
t.index ["task_key", "run_at"], name: "index_solid_queue_recurring_executions_on_task_key_and_run_at", unique: true
end

create_table "solid_queue_recurring_tasks", force: :cascade do |t|
t.string "key", null: false
t.string "schedule", null: false
t.string "command", limit: 2048
t.string "class_name"
t.text "arguments"
t.string "queue_name"
t.integer "priority", default: 0
t.boolean "static", default: true, null: false
t.text "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["key"], name: "index_solid_queue_recurring_tasks_on_key", unique: true
t.index ["static"], name: "index_solid_queue_recurring_tasks_on_static"
end

create_table "solid_queue_scheduled_executions", force: :cascade do |t|
t.bigint "job_id", null: false
t.string "queue_name", null: false
Expand Down Expand Up @@ -400,5 +431,6 @@
add_foreign_key "solid_queue_claimed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
add_foreign_key "solid_queue_failed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
add_foreign_key "solid_queue_ready_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
add_foreign_key "solid_queue_recurring_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
add_foreign_key "solid_queue_scheduled_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
end

0 comments on commit 42d043b

Please sign in to comment.