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

(cherry picked from commit acfb86d)
  • Loading branch information
agrare authored and Fryguy committed Sep 12, 2023
1 parent 5c7890c commit 3b9e6b2
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 3b9e6b2

Please sign in to comment.