Sha256: 1190d3ab3f9e075b081279d7da6714ecd35e95afcb5b228cbf0626160d84d829

Contents?: true

Size: 871 Bytes

Versions: 19

Compression:

Stored size: 871 Bytes

Contents

module NulogyMessageBusProducer
  # This modules repopulates the replication slot (what debezium uses to populate Kafka)
  # by re-generating the subscription events
  module RepopulateReplicationSlots
    def self.repopulate
      table_name = NulogyMessageBusProducer::SubscriptionEvent.table_name
      temp_table_name = "#{NulogyMessageBusProducer::SubscriptionEvent.table_name}_tmp_event_repopulation"

      ActiveRecord::Base.connection.execute(<<~SQL)
        BEGIN;
        LOCK TABLE #{table_name} IN SHARE MODE;

        DROP TABLE IF EXISTS #{temp_table_name};
        CREATE TEMPORARY TABLE #{temp_table_name} AS
          SELECT * FROM #{table_name} ORDER BY created_at ASC;

        TRUNCATE #{table_name};
        INSERT INTO #{table_name}
          (SELECT * FROM #{temp_table_name} ORDER BY created_at ASC);

        COMMIT;
      SQL
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
nulogy_message_bus_producer-5.0.8 lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-5.0.7 lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-5.0.6 lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-5.0.5 lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-5.0.4 lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-5.0.3 lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-5.0.2 lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-5.0.1 lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-5.0.1.alpha lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-5.0.0 lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-4.0.0 lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-3.7.0 lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-3.6.0 lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-3.5.0 lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-4.0.0.alpha lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-3.4.1 lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-3.4.0 lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-3.3.0 lib/nulogy_message_bus_producer/repopulate_replication_slots.rb
nulogy_message_bus_producer-3.2.1 lib/nulogy_message_bus_producer/repopulate_replication_slots.rb