Class: ActiveRecord::SchemaMigration

Inherits:
Base
  • Object
show all
Defined in:
lib/active_record/schema_migration.rb

Constant Summary

Constants included from ConnectionHandling

ConnectionHandling::VALID_CONN_PARAMS

Constants included from Transactions

Transactions::ACTIONS

Constants included from Callbacks

Callbacks::CALLBACKS

Instance Attribute Summary

Attributes included from Associations

#association_cache

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Explain

#collecting_queries_for_explain, #exec_explain

Methods included from DynamicMatchers

#respond_to?

Methods included from Translation

#i18n_scope, #lookup_ancestors

Methods included from Querying

#count_by_sql, #find_by_sql

Methods included from QueryCache::ClassMethods

#cache, #uncached

Methods included from ConnectionHandling

#clear_cache!, #connected?, #connection, #connection_config, #connection_id, #connection_id=, #connection_pool, #establish_connection, #mysql2_connection, #mysql_connection, #postgresql_connection, #remove_connection, #retrieve_connection, #sqlite3_connection

Methods included from Core

#<=>, #==, #connection, #connection_handler, #encode_with, #freeze, #frozen?, #has_transactional_callbacks?, #hash, #init_with, #initialize, #initialize_dup, #inspect, #readonly!, #readonly?, #set_transaction_state, #slice, #yaml_initialize

Methods included from Serialization

#serializable_hash, #to_xml

Methods included from Transactions

#add_to_transaction, #committed!, #destroy, #rollback_active_record_state!, #rolledback!, #save, #save!, #touch, #transaction, #with_transaction_returning_status

Methods included from Aggregations

#clear_aggregation_cache

Methods included from NestedAttributes

#_destroy

Methods included from AutosaveAssociation

#changed_for_autosave?, #destroyed_by_association, #destroyed_by_association=, #mark_for_destruction, #marked_for_destruction?, #reload

Methods included from Associations

#association, #clear_association_cache

Methods included from Timestamp

#initialize_dup

Methods included from Callbacks

#destroy, #touch

Methods included from AttributeMethods

#[], #[]=, #attribute_for_inspect, #attribute_missing, #attribute_names, #attribute_present?, #attributes, #attributes_for_coder, #column_for_attribute, #has_attribute?, #method_missing, #respond_to?

Methods included from Locking::Pessimistic

#lock!, #with_lock

Methods included from Locking::Optimistic

#locking_enabled?

Methods included from Validations

#save, #save!, #valid?

Methods included from Integration

#cache_key, #to_param

Methods included from AttributeAssignment

#assign_attributes

Methods included from Sanitization

#quoted_id

Methods included from Scoping

#populate_with_current_scope_attributes

Methods included from ReadonlyAttributes

#_attr_readonly

Methods included from Persistence

#becomes, #becomes!, #decrement, #decrement!, #delete, #destroy, #destroy!, #destroyed?, #increment, #increment!, #new_record?, #persisted?, #reload, #save, #save!, #toggle, #toggle!, #touch, #update, #update!, #update_attribute, #update_column, #update_columns

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveRecord::AttributeMethods

Class Method Details

.create_table(limit = nil) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
# File 'lib/active_record/schema_migration.rb', line 16

def self.create_table(limit=nil)
  unless connection.table_exists?(table_name)
    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

.drop_tableObject


28
29
30
31
32
33
# File 'lib/active_record/schema_migration.rb', line 28

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

.index_nameObject


12
13
14
# File 'lib/active_record/schema_migration.rb', line 12

def self.index_name
  "#{Base.table_name_prefix}unique_schema_migrations#{Base.table_name_suffix}"
end

.table_nameObject


8
9
10
# File 'lib/active_record/schema_migration.rb', line 8

def self.table_name
  "#{Base.table_name_prefix}schema_migrations#{Base.table_name_suffix}"
end

Instance Method Details

#versionObject


35
36
37
# File 'lib/active_record/schema_migration.rb', line 35

def version
  super.to_i
end