envato / event_sourcery

A library for building event sourced applications in Ruby
MIT License
84 stars 10 forks source link

Cascade when dropping tables in TableOwner#reset #88

Closed grassdog closed 7 years ago

grassdog commented 7 years ago

TableOwner#reset can't reliably drop tables if we have dependent tables defined in a TableOwner.

e.g.

Class.new do
  prepend EventSourcery::EventProcessing::TableOwner

  def initialize(db_connection)
    @db_connection = db_connection
  end

  table :authors do
    primary_key :id, type: :Integer
    column :uuid, 'UUID'
  end

  table :items do
    foreign_key :authors_id, :authors
    column :created_at, 'timestamp without time zone'
  end
end

Adding the cascade option fixes this.