class ActiveRecord::SchemaMigration
:nodoc:
to be executed the next time.
number is inserted in to the ‘SchemaMigration.table_name` so it doesn’t need
have been applied to a given database. When a migration is run, its schema
This class is used to create a table that keeps track of which migrations
def all_versions
def all_versions order(:version).pluck(:version) end
def create_table
def create_table unless connection.table_exists?(table_name) connection.create_table(table_name, id: false) do |t| t.string :version, **connection.internal_string_options_for_primary_key end end end
def drop_table
def drop_table connection.drop_table table_name, if_exists: true end
def normalize_migration_number(number)
def normalize_migration_number(number) "%.3d" % number.to_i end
def normalized_versions
def normalized_versions all_versions.map { |v| normalize_migration_number v } end
def primary_key
def primary_key "version" end
def table_exists?
def table_exists? connection.data_source_exists?(table_name) end
def table_name
def table_name "#{table_name_prefix}#{schema_migrations_table_name}#{table_name_suffix}" end
def version
def version super.to_i end