class CaptureMigrationSql::SqlSubscriber
Constants
- EXPLAIN_STATEMENT
- IGNORE_PAYLOAD_NAMES
- IGNORE_STATEMENTS
- SELECT_INFORMATION_SCHEMA
- SELECT_SCHEMA_MIGRATIONS
- SHOW_STATEMENT
- SQLLITE_VERSION
Public Class Methods
attach_if_necessary()
click to toggle source
# File lib/capture_migration_sql/sql_subscriber.rb, line 19 def attach_if_necessary unless defined?(@attached) && @attached attach_to(:active_record) @attached = true end end
Public Instance Methods
sql(event)
click to toggle source
# File lib/capture_migration_sql/sql_subscriber.rb, line 27 def sql(event) stream = CaptureMigrationSql.capture_stream return unless stream && CaptureMigrationSql.capture_enabled? payload = event.payload return if IGNORE_PAYLOAD_NAMES.include?(payload[:name]) sql = payload[:sql] return if sql.nil? || IGNORE_STATEMENTS.match(sql) sql = sql.strip sql = "#{sql};" unless sql.end_with?(";") stream.write("#{sql}\n\n") end