Sha256: 1930f86aa8dbd392a075d323f362eb989ab638f1d91f7dd9ea73643c6d83e27d

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

module SchemaMonkey
  module ActiveRecord
    module ConnectionAdapters
      module AbstractAdapter
        def self.included(base) #:nodoc:
          base.alias_method_chain :initialize, :schema_monkey
        end

        def initialize_with_schema_monkey(*args) #:nodoc:
          initialize_without_schema_monkey(*args)

          dbm = case adapter_name
                when /^MySQL/i                 then :Mysql
                when 'PostgreSQL', 'PostGIS'   then :PostgreSQL
                when 'SQLite'                  then :SQLite3
                end

          SchemaMonkey.insert(dbm: dbm)
        end

        module SchemaCreation
          def self.included(base)
            base.class_eval do
              alias_method_chain :add_column_options!, :schema_monkey
              public :options_include_default?
            end
          end

          def add_column_options_with_schema_monkey!(sql, options)
            Middleware::Migration::ColumnOptionsSql.start caller: self, connection: self.instance_variable_get('@conn'), sql: sql, options: options do |env|
              add_column_options_without_schema_monkey! env.sql, env.options
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
schema_monkey-0.4.1 lib/schema_monkey/active_record/connection_adapters/abstract_adapter.rb
schema_monkey-0.4.0 lib/schema_monkey/active_record/connection_adapters/abstract_adapter.rb