Class: IdempotencyCheck::TableSnapshot
- Inherits:
-
Object
- Object
- IdempotencyCheck::TableSnapshot
- Defined in:
- lib/idempotency_check/table_snapshot.rb
Overview
Snapshots row counts per table, so two snapshots can be compared to see whether running something again changed the resulting state.
tables is the set of tables the checked block actually wrote to — see
SqlTracker. Snapshotting only those keeps a check proportional to what
the job touches instead of to the size of the whole schema.
Class Method Summary collapse
Class Method Details
.take(tables:) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/idempotency_check/table_snapshot.rb', line 12 def take(tables:) connection = ActiveRecord::Base.connection tables.each_with_object({}) do |table, counts| counts[table] = connection.select_value( "SELECT COUNT(*) FROM #{connection.quote_table_name(table)}" ).to_i end end |