Sha256: a974990cdfa00ec3925c49f487ce30e1c24f05b902b37a51ecaa52dea33d9bef

Contents?: true

Size: 1.28 KB

Versions: 30

Compression:

Stored size: 1.28 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
    end

    def version
      super.to_i
    end
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
activerecord-4.1.16 lib/active_record/schema_migration.rb
activerecord-4.1.16.rc1 lib/active_record/schema_migration.rb
activerecord-4.1.15 lib/active_record/schema_migration.rb
activerecord-4.1.15.rc1 lib/active_record/schema_migration.rb
activerecord-4.1.14.2 lib/active_record/schema_migration.rb
activerecord-4.1.14.1 lib/active_record/schema_migration.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/activerecord-4.1.13/lib/active_record/schema_migration.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/activerecord-4.1.13/lib/active_record/schema_migration.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/activerecord-4.1.13/lib/active_record/schema_migration.rb
activerecord-4.1.14 lib/active_record/schema_migration.rb
activerecord-4.1.14.rc2 lib/active_record/schema_migration.rb
activerecord-4.1.14.rc1 lib/active_record/schema_migration.rb
activerecord-4.1.13 lib/active_record/schema_migration.rb
activerecord-4.1.13.rc1 lib/active_record/schema_migration.rb
activerecord-4.1.12 lib/active_record/schema_migration.rb
activerecord-4.1.12.rc1 lib/active_record/schema_migration.rb
activerecord-4.1.11 lib/active_record/schema_migration.rb
activerecord-4.1.10 lib/active_record/schema_migration.rb
activerecord-4.1.10.rc4 lib/active_record/schema_migration.rb
activerecord-4.1.10.rc3 lib/active_record/schema_migration.rb