Sha256: f095207ba5f77882b1e272c8cb0fb787265830c9f47b774a4e427e8165d846fd

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

class CreateMunsterTables < ActiveRecord::Migration[7.0]
  def change
    create_table :received_webhooks do |t|
      t.string :handler_event_id, null: false
      t.string :handler_module_name, null: false
      t.string :status, default: "received", null: false

      # We don't assume, that we can always parse received body as JSON. Body could be invalid or partly missing,
      # we can argue how we can handle that for different integrations, but we still should be able to save this data
      # if it's required. Hence, we don't use :jsonb, but :binary type column here.
      t.binary :body, null: false

      t.timestamps
    end

    # For deduplication at ingress. UNIQUE indices in Postgres are case-sensitive
    # which is what we want, as these are externally-generated IDs
    add_index :received_webhooks, [:handler_module_name, :handler_event_id], unique: true, name: "webhook_dedup_idx"
    # For backfill processing (to know how many skipped etc. payloads we have)
    add_index :received_webhooks, [:status]
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
munster-0.4.2 example/db/migrate/20240523125859_create_munster_tables.rb
munster-0.4.1 example/db/migrate/20240523125859_create_munster_tables.rb
munster-0.4.0 example/db/migrate/20240523125859_create_munster_tables.rb
munster-0.3.1 example/db/migrate/20240523125859_create_munster_tables.rb
munster-0.3.0 example/db/migrate/20240523125859_create_munster_tables.rb
munster-0.2.0 example/db/migrate/20240523125859_create_munster_tables.rb
munster-0.1.0 example/db/migrate/20240523125859_create_munster_tables.rb