Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from cantino/prevent_event_replay_on_linking
Prevent event propagation of events created before a link
- Loading branch information
Showing
5 changed files
with
69 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
db/migrate/20140213053001_add_event_id_at_creation_to_links.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class AddEventIdAtCreationToLinks < ActiveRecord::Migration | ||
def up | ||
add_column :links, :event_id_at_creation, :integer, :null => false, :default => 0 | ||
|
||
execute <<-SQL | ||
UPDATE #{ActiveRecord::Base.connection.quote_table_name('links')} | ||
SET event_id_at_creation = ( | ||
SELECT #{ActiveRecord::Base.connection.quote_column_name('id')} | ||
FROM #{ActiveRecord::Base.connection.quote_table_name('events')} | ||
WHERE events.agent_id = links.source_id ORDER BY events.id DESC limit 1 | ||
) | ||
SQL | ||
end | ||
|
||
def down | ||
remove_column :links, :event_id_at_creation | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters