Class: ActiveRecord::SchemaMigration
- Defined in:
- activerecord/lib/active_record/schema_migration.rb
Constant Summary
Constants included from ConnectionHandling
ConnectionHandling::VALID_CONN_PARAMS
Constants included from Transactions
Constants included from Callbacks
Constants included from AttributeMethods
Constants included from ActiveModel::AttributeMethods
ActiveModel::AttributeMethods::CALL_COMPILABLE_REGEXP, ActiveModel::AttributeMethods::NAME_COMPILABLE_REGEXP
Instance Attribute Summary
Attributes included from Associations
Class Method Summary collapse
- .create_table(limit = nil) ⇒ Object
- .drop_table ⇒ Object
- .index_name ⇒ Object
- .table_exists? ⇒ Boolean
- .table_name ⇒ Object
Instance Method Summary collapse
Methods included from Explain
#collecting_queries_for_explain, #exec_explain
Methods included from DynamicMatchers
Methods included from Translation
#i18n_scope, #lookup_ancestors
Methods included from ActiveModel::Translation
#human_attribute_name, #i18n_scope, #lookup_ancestors
Methods included from ActiveModel::Naming
#model_name, param_key, plural, route_key, singular, singular_route_key, uncountable?
Methods included from Querying
Methods included from QueryCache::ClassMethods
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 ActiveSupport::DescendantsTracker
clear, descendants, #descendants, #direct_descendants, direct_descendants, #inherited, store_inherited
Methods included from ActiveSupport::Benchmarkable
Methods included from Core
#<=>, #==, #connection_handler, #encode_with, #freeze, #frozen?, #has_transactional_callbacks?, #hash, #init_with, #initialize, #initialize_dup, #inspect, #readonly!, #readonly?, #set_transaction_state, #slice
Methods included from ActiveSupport::Concern
#append_features, extended, #included
Methods included from Serialization
Methods included from ActiveModel::Serializers::Xml
Methods included from ActiveModel::Serialization
Methods included from ActiveModel::Serializers::JSON
Methods included from Reflection
Methods included from Transactions
#add_to_transaction, #committed!, #destroy, #rollback_active_record_state!, #rolledback!, #save, #save!, #transaction, #with_transaction_returning_status
Methods included from Aggregations
Methods included from NestedAttributes
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 ActiveSupport::Autoload
#autoload, #autoload_at, #autoload_under, #autoloads, #eager_autoload, #eager_load!, extended
Methods included from Timestamp
Methods included from Callbacks
Methods included from AttributeMethods
#[], #[]=, #attribute_for_inspect, #attribute_names, #attribute_present?, #attributes, #column_for_attribute, #has_attribute?, #method_missing, #respond_to?
Methods included from ActiveModel::AttributeMethods
#attribute_missing, #method_missing, #respond_to?, #respond_to_without_attributes?
Methods included from Locking::Pessimistic
Methods included from Locking::Optimistic
Methods included from Validations
Methods included from ActiveModel::Validations
#errors, #initialize_dup, #invalid?, #valid?, #validates_with
Methods included from Integration
Methods included from ActiveModel::Conversion
#to_key, #to_model, #to_param, #to_partial_path
Methods included from AttributeAssignment
Methods included from Sanitization
Methods included from Scoping
#populate_with_current_scope_attributes
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
21 22 23 24 25 26 27 28 29 30 31 |
# File 'activerecord/lib/active_record/schema_migration.rb', line 21 def create_table(limit=nil) unless table_exists? = {null: false} [:limit] = limit if limit connection.create_table(table_name, id: false) do |t| t.column :version, :string, end connection.add_index table_name, :version, unique: true, name: index_name end end |
.drop_table ⇒ Object
33 34 35 36 37 38 |
# File 'activerecord/lib/active_record/schema_migration.rb', line 33 def drop_table if table_exists? connection.remove_index table_name, name: index_name connection.drop_table(table_name) end end |
.index_name ⇒ Object
13 14 15 |
# File 'activerecord/lib/active_record/schema_migration.rb', line 13 def index_name "#{table_name_prefix}unique_schema_migrations#{table_name_suffix}" end |
.table_exists? ⇒ Boolean
17 18 19 |
# File 'activerecord/lib/active_record/schema_migration.rb', line 17 def table_exists? connection.table_exists?(table_name) end |
.table_name ⇒ Object
9 10 11 |
# File 'activerecord/lib/active_record/schema_migration.rb', line 9 def table_name "#{table_name_prefix}schema_migrations#{table_name_suffix}" end |
Instance Method Details
#version ⇒ Object
41 42 43 |
# File 'activerecord/lib/active_record/schema_migration.rb', line 41 def version super.to_i end |