Class: ActiveRecord::SchemaMigration
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/schema_migration.rb
Overview
This class is used to create a table that keeps track of which migrations have been applied to a given database. When a migration is run, its schema number is inserted in to the ‘SchemaMigration.table_name` so it doesn’t need to be executed the next time.
Constant Summary
Constants included from ConnectionHandling
ConnectionHandling::DEFAULT_ENV, ConnectionHandling::RAILS_ENV
Constants included from Querying
Constants included from SecureToken
ActiveRecord::SecureToken::MINIMUM_TOKEN_LENGTH
Constants included from Transactions
Constants included from ActiveModel::SecurePassword
ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED
Constants included from Callbacks
Constants included from AttributeMethods
AttributeMethods::RESTRICTED_CLASS_METHODS
Constants included from ActiveModel::AttributeMethods
ActiveModel::AttributeMethods::CALL_COMPILABLE_REGEXP, ActiveModel::AttributeMethods::FORWARD_PARAMETERS, ActiveModel::AttributeMethods::NAME_COMPILABLE_REGEXP
Instance Attribute Summary
Attributes included from ConnectionHandling
#connection_specification_name
Attributes included from Core
Class Method Summary collapse
- .all_versions ⇒ Object
- .create_table ⇒ Object
- .drop_table ⇒ Object
- .normalize_migration_number(number) ⇒ Object
- .normalized_versions ⇒ Object
- .primary_key ⇒ Object
- .table_exists? ⇒ Boolean
- .table_name ⇒ Object
Instance Method Summary collapse
Methods included from ActiveModel::Naming
extended, #model_name, param_key, plural, route_key, singular, singular_route_key, uncountable?
Methods included from ActiveSupport::Benchmarkable
Methods included from ActiveSupport::DescendantsTracker
clear, #descendants, descendants, direct_descendants, #direct_descendants, disable_clear!, #inherited, native?, store_inherited, #subclasses, subclasses
Methods included from ConnectionHandling
#clear_cache!, #clear_query_caches_for_current_thread, #connected?, #connected_to, #connected_to?, #connected_to_many, #connecting_to, #connection, #connection_db_config, #connection_pool, #connects_to, #establish_connection, #lookup_connection_handler, #mysql2_connection, #postgresql_connection, #primary_class?, #prohibit_shard_swapping, #remove_connection, #retrieve_connection, #shard_swapping_prohibited?, #sqlite3_connection, #while_preventing_writes
Methods included from QueryCache::ClassMethods
Methods included from Querying
#_load_from_sql, #_query_by_sql, #count_by_sql, #find_by_sql
Methods included from Translation
#i18n_scope, #lookup_ancestors
Methods included from ActiveModel::Translation
#human_attribute_name, #i18n_scope, #lookup_ancestors
Methods included from DelegatedType
Methods included from Explain
#collecting_queries_for_explain, #exec_explain
Methods included from Enum
Methods included from Delegation::DelegateCache
#generate_relation_method, #inherited, #initialize_relation_delegate_cache, #relation_delegate_class
Methods included from Aggregations::ClassMethods
Methods included from Encryption::EncryptableRecord
#ciphertext_for, #decrypt, #encrypt, #encrypted_attribute?
Methods included from ActiveSupport::Concern
#append_features, #class_methods, extended, #included, #prepend_features, #prepended
Methods included from Suppressor
Methods included from SignedId
Methods included from Serialization
Methods included from ActiveModel::Serializers::JSON
Methods included from ActiveModel::Serialization
Methods included from Reflection
add_aggregate_reflection, add_reflection, create
Methods included from NoTouching
applied_to?, apply_to, #no_touching?, #touch, #touch_later
Methods included from TouchLater
#before_committed!, #touch, #touch_later
Methods included from Transactions
#before_committed!, #committed!, #destroy, #rolledback!, #save, #save!, #touch, #transaction, #trigger_transactional_callbacks?, #with_transaction_returning_status
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, #association_cached?, eager_load!, #initialize_dup
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
#[], #[]=, #_has_attribute?, #accessed_fields, #attribute_for_inspect, #attribute_names, #attribute_present?, #attributes, dangerous_attribute_methods, #has_attribute?, #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
#increment!, #locking_enabled?
Methods included from Validations
Methods included from ActiveModel::Validations
#errors, #initialize_dup, #invalid?, #valid?, #validate!, #validates_with
Methods included from Integration
#cache_key, #cache_key_with_version, #cache_version, #to_param
Methods included from ActiveModel::Conversion
#to_key, #to_model, #to_param, #to_partial_path
Methods included from ActiveModel::AttributeAssignment
Methods included from Scoping
#initialize_internals_callback, #populate_with_current_scope_attributes
Methods included from Inheritance
Methods included from ModelSchema
Methods included from Persistence
#becomes, #becomes!, #decrement, #decrement!, #delete, #destroy, #destroy!, #destroyed?, #increment, #increment!, #new_record?, #persisted?, #previously_new_record?, #previously_persisted?, #reload, #save, #save!, #toggle, #toggle!, #touch, #update, #update!, #update_attribute, #update_column, #update_columns
Methods included from Core
#<=>, #==, #blank?, #connection_handler, #encode_with, #freeze, #frozen?, #hash, #init_with, #init_with_attributes, #initialize, #initialize_dup, #inspect, #present?, #pretty_print, #readonly!, #readonly?, #slice, #strict_loading!, #strict_loading?, #strict_loading_n_plus_one_only?, #values_at
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ActiveModel::AttributeMethods
Class Method Details
.all_versions ⇒ Object
41 42 43 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/schema_migration.rb', line 41 def all_versions order(:version).pluck(:version) end |
.create_table ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/schema_migration.rb', line 21 def create_table unless connection.table_exists?(table_name) connection.create_table(table_name, id: false) do |t| t.string :version, **connection. end end end |
.drop_table ⇒ Object
29 30 31 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/schema_migration.rb', line 29 def drop_table connection.drop_table table_name, if_exists: true end |
.normalize_migration_number(number) ⇒ Object
33 34 35 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/schema_migration.rb', line 33 def normalize_migration_number(number) "%.3d" % number.to_i end |
.normalized_versions ⇒ Object
37 38 39 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/schema_migration.rb', line 37 def normalized_versions all_versions.map { |v| normalize_migration_number v } end |
.primary_key ⇒ Object
13 14 15 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/schema_migration.rb', line 13 def primary_key "version" end |
.table_exists? ⇒ Boolean
45 46 47 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/schema_migration.rb', line 45 def table_exists? connection.data_source_exists?(table_name) end |
.table_name ⇒ Object
17 18 19 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/schema_migration.rb', line 17 def table_name "#{table_name_prefix}#{schema_migrations_table_name}#{table_name_suffix}" end |
Instance Method Details
#version ⇒ Object
50 51 52 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/schema_migration.rb', line 50 def version super.to_i end |