Skip to content

Commit

Permalink
Merge pull request #704 from jrafanie/delete_nil_timestamp_event_streams
Browse files Browse the repository at this point in the history
Delete invalid nil timestamp event streams
  • Loading branch information
agrare committed Aug 30, 2023
2 parents 62f0ee6 + 2ba5fb1 commit acfb86d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions db/migrate/20230830134742_delete_nil_timestamp_event_streams.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class DeleteNilTimestampEventStreams < ActiveRecord::Migration[6.1]
class EventStream < ActiveRecord::Base
self.inheritance_column = :_type_disabled
end

def up
say_with_time("Deleting event_streams with nil timestamp values") do
EventStream.where(:timestamp => nil).delete_all
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require_migration

describe DeleteNilTimestampEventStreams do
let(:event_stream_stub) { migration_stub(:EventStream) }

migration_context :up do
it "removes nil timestamp events, leaving others" do
good = event_stream_stub.create!(:timestamp => Time.now.utc)
event_stream_stub.create!(:timestamp => nil)

migrate

expect(event_stream_stub.count).to eq(1)
expect(event_stream_stub.first.id).to eq(good.id)
expect(event_stream_stub.first.timestamp).to be_present
end
end
end

0 comments on commit acfb86d

Please sign in to comment.