Sha256: 536e2f4fbbf9a4bb1fa0be87c5d1dcad8945a2f69787768ab9123487116ef5b7

Contents?: true

Size: 1.38 KB

Versions: 40

Compression:

Stored size: 1.38 KB

Contents

require 'active_record/scoping/default'
require 'active_record/scoping/named'
require 'active_record/base'

module ActiveRecord
  class SchemaMigration < ActiveRecord::Base
    class << self
      def primary_key
        nil
      end

      def table_name
        "#{table_name_prefix}#{ActiveRecord::Base.schema_migrations_table_name}#{table_name_suffix}"
      end

      def index_name
        "#{table_name_prefix}unique_#{ActiveRecord::Base.schema_migrations_table_name}#{table_name_suffix}"
      end

      def table_exists?
        connection.table_exists?(table_name)
      end

      def create_table(limit=nil)
        unless table_exists?
          version_options = {null: false}
          version_options[:limit] = limit if limit

          connection.create_table(table_name, id: false) do |t|
            t.column :version, :string, version_options
          end
          connection.add_index table_name, :version, unique: true, name: index_name
        end
      end

      def drop_table
        if table_exists?
          connection.remove_index table_name, name: index_name
          connection.drop_table(table_name)
        end
      end

      def normalize_migration_number(number)
        "%.3d" % number.to_i
      end

      def normalized_versions
        pluck(:version).map { |v| normalize_migration_number v }
      end
    end

    def version
      super.to_i
    end
  end
end

Version data entries

40 entries across 39 versions & 7 rubygems

Version Path
activerecord-4.2.7.1 lib/active_record/schema_migration.rb
activerecord-4.2.7 lib/active_record/schema_migration.rb
activerecord-4.2.7.rc1 lib/active_record/schema_migration.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.6/lib/active_record/schema_migration.rb
activerecord-4.2.6 lib/active_record/schema_migration.rb
activerecord-4.2.6.rc1 lib/active_record/schema_migration.rb
activerecord-4.2.5.2 lib/active_record/schema_migration.rb
activejob-lock-0.0.2 rails/activerecord/lib/active_record/schema_migration.rb
activerecord-4.2.5.1 lib/active_record/schema_migration.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/activerecord-4.2.4/lib/active_record/schema_migration.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/activerecord-4.2.4/lib/active_record/schema_migration.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/activerecord-4.2.4/lib/active_record/schema_migration.rb
activerecord-4.2.5 lib/active_record/schema_migration.rb
activerecord-4.2.5.rc2 lib/active_record/schema_migration.rb
activerecord-4.2.5.rc1 lib/active_record/schema_migration.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/schema_migration.rb
activerecord-4.2.4 lib/active_record/schema_migration.rb
activerecord-4.2.4.rc1 lib/active_record/schema_migration.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/activerecord-4.2.3/lib/active_record/schema_migration.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/activerecord-4.2.3/lib/active_record/schema_migration.rb