Sha256: 1b92b711a2528735a4d8b19ce3ce9931badbd18911b0711dff30c59424c040ce

Contents?: true

Size: 731 Bytes

Versions: 4

Compression:

Stored size: 731 Bytes

Contents

# frozen_string_literal: true

class Create<%= model_name.camelize %>Events < ActiveRecord::Migration[7.0]
  def change
    create_table :<%= model_name.underscore %>_events do |t|
      # Change this to string if your aggregates primary key is a string type
      t.bigint :aggregate_id, null: false, index: true
      t.string :idempotency_key, null: true
      t.string :type, null: false
      t.json :data, null: false, default: {}
      t.json :metadata, null: false, default: {}

      t.timestamps

      t.index :idempotency_key, unique: true
      t.index :created_at
    end

    # Enables optimistic locking on the evented table
    add_column :<%= model_name.underscore.pluralize %>, :lock_version, :integer
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eventsimple-1.5.6 lib/eventsimple/generators/templates/create_events.erb
eventsimple-1.5.5 lib/eventsimple/generators/templates/create_events.erb
eventsimple-1.5.4 lib/eventsimple/generators/templates/create_events.erb
eventsimple-1.5.3 lib/eventsimple/generators/templates/create_events.erb