codesnips
Browse Tags Share a snippet
Sign in
Join us today
Share your craft projects Make new craft buddies Ask craft questions Blog your craft journey
All Latest Trending
ruby
class AddUniqueIndexToInventorySnapshots < ActiveRecord::Migration[7.1]
  disable_ddl_transaction!

  def change
    add_index :inventory_snapshots,
              [:warehouse_id, :sku],

Bulk Upsert with insert_all + Unique Index

rails activerecord postgres
by codesnips 3 tabs
ruby
class CreateProcessedEvents < ActiveRecord::Migration[7.1]
  def change
    create_table :processed_events do |t|
      t.string :event_key, null: false
      t.string :job_class, null: false
      t.jsonb :metadata, null: false, default: {}

Idempotent Job with Advisory Lock

rails postgres reliability
by codesnips 3 tabs
ruby
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

Transactional Outbox for Reliable Event Publishing

rails background-jobs reliability
by codesnips 4 tabs
Previous
1 ... 90 91 92
Next
CodeSnips

CodeSnips is crafted with passion and great attention to detail.

Privacy Terms
Facebook Instagram Pinterest
Tags

© 2024 CodeSnips. All Rights Reserved. Running on Ruby on Rails.

Disclaimer: Any posts on CodeSnips.io are posted by individuals acting in their own right and do not necessarily reflect the views of CodeSnips.
CodeSnips will not be held liable for the actions of any user.