Sha256: eb8f26c05108b8bc682c0e3500768fd83a824643e60d82b5bbcf5b79adcb73a2

Contents?: true

Size: 1.08 KB

Versions: 16

Compression:

Stored size: 1.08 KB

Contents

module ArJdbc
  module MySQL
    # @private copied from native adapter 4.0/4.1
    class SchemaCreation < ::ActiveRecord::ConnectionAdapters::AbstractAdapter::SchemaCreation

      def visit_AddColumn(o)
        add_column_position!(super, column_options(o))
      end

      private
      def visit_ChangeColumnDefinition(o)
        column = o.column
        options = o.options
        sql_type = type_to_sql(o.type, options[:limit], options[:precision], options[:scale])
        change_column_sql = "CHANGE #{quote_column_name(column.name)} #{quote_column_name(options[:name])} #{sql_type}"
        add_column_options!(change_column_sql, options)
        add_column_position!(change_column_sql, options)
      end

      def add_column_position!(sql, options)
        if options[:first]
          sql << " FIRST"
        elsif options[:after]
          sql << " AFTER #{quote_column_name(options[:after])}"
        end
        sql
      end
    end
  end

  def schema_creation
    SchemaCreation.new self
  end

end if ::ActiveRecord::ConnectionAdapters::AbstractAdapter.const_defined? :SchemaCreation

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
activerecord-jdbc-adapter-1.3.16 lib/arjdbc/mysql/schema_creation.rb
activerecord-jdbc-adapter-1.3.15 lib/arjdbc/mysql/schema_creation.rb
activerecord-jdbc-adapter-1.3.14 lib/arjdbc/mysql/schema_creation.rb
activerecord-jdbc-adapter-1.3.13 lib/arjdbc/mysql/schema_creation.rb
activerecord-jdbc-adapter-1.3.12 lib/arjdbc/mysql/schema_creation.rb
activerecord-jdbc-adapter-1.3.11 lib/arjdbc/mysql/schema_creation.rb
activerecord-jdbc-adapter-1.3.10 lib/arjdbc/mysql/schema_creation.rb
activerecord-jdbc-adapter-1.3.9 lib/arjdbc/mysql/schema_creation.rb
activerecord-jdbc-adapter-1.3.8 lib/arjdbc/mysql/schema_creation.rb
activerecord-jdbc-adapter-1.3.7 lib/arjdbc/mysql/schema_creation.rb
activerecord-jdbc-adapter-1.3.6 lib/arjdbc/mysql/schema_creation.rb
activerecord-jdbc-adapter-1.3.5 lib/arjdbc/mysql/schema_creation.rb
activerecord-jdbc-adapter-1.3.4 lib/arjdbc/mysql/schema_creation.rb
activerecord-jdbc-adapter-1.3.3 lib/arjdbc/mysql/schema_creation.rb
activerecord-jdbc-adapter-1.3.2 lib/arjdbc/mysql/schema_creation.rb
activerecord-jdbc-adapter-1.3.1 lib/arjdbc/mysql/schema_creation.rb