class CreateWebhookEvents < ActiveRecord::Migration[7.1]
def change
create_table :webhook_events do |t|
t.string :event_id, null: false
t.string :source, null: false, default: "stripe"
t.string :event_type, null: false
class CreateOutboxEvents < ActiveRecord::Migration[7.1]
def change
create_table :outbox_events do |t|
t.string :event_type, null: false
t.string :aggregate_type, null: false
t.string :aggregate_id, null: false
class SyncContactJob < ApplicationJob
queue_as :external
BACKOFF = ->(executions) do
(2**executions) + rand(0.0..1.0) # exponential + jitter, in seconds
end
class ProcessPaymentWorker
include Sidekiq::Worker
sidekiq_options queue: :critical, retry: 10
sidekiq_retry_in do |count, exception|
class ShippedEmailJob
include Sidekiq::Job
sidekiq_options queue: :mailers, retry: 5
def perform(order_id)
order = Order.find_by(id: order_id)
class Reminder < ApplicationRecord
belongs_to :user
validates :time_zone, inclusion: { in: ActiveSupport::TimeZone::MAPPING.values }
validates :local_time, presence: true
class DebouncedReindexJob
include Sidekiq::Job
sidekiq_options queue: :indexing, retry: 5
DEBOUNCE_DELAY = 5 # seconds
class InventoryLevel < ApplicationRecord
belongs_to :warehouse
UPSERT_COLUMNS = %w[warehouse_id sku on_hand reserved updated_at].freeze
def self.upsert_counts(rows)