.primary_key
[ GitHub ]# File 'activerecord/lib/active_record/schema_migration.rb', line 8
def primary_key nil end
123456789_123456789_123456789_123456789_123456789_
  CALL_COMPILABLE_REGEXP, NAME_COMPILABLE_REGEXP
AttrNames, BLACKLISTED_CLASS_METHODS
| average, calculate, count, create_with, delete, delete_all, destroy, destroy_all, distinct, eager_load, except, fifth, find, find_by, find_each, find_in_batches, find_or_create_by, find_or_initialize_by, first, first_or_create, first_or_initialize, forty_two, fourth, from, group, having, ids, includes, joins, last, limit, lock, maximum, minimum, none, offset, order, pluck, preload, readonly, references, reorder, rewhere, second, select, sum, take, third, uniq, unscope, update, update_all, where | 
| connected? | Returns  | 
| connection_id, connection_id= | |
| human_attribute_name | Transforms attribute names into a more human format, such as “First name” instead of “first_name”. | 
| i18n_scope | Returns the  | 
| lookup_ancestors | When localizing a string, it goes through the lookup returned by this method, which is used in ActiveModel::Name#human, ActiveModel::Errors#full_messages and ActiveModel::Translation#human_attribute_name. | 
| any?, | |
| count_by_sql | Returns the result of an SQL statement that should only include a COUNT(*) in the SELECT part. | 
| exists?, fifth!, find_by!, | |
| find_by_sql | Executes a custom SQL query against your database and returns all the results. | 
| find_or_create_by!, first!, first_or_create!, forty_two!, fourth!, last!, many?, second!, take!, third! | |
| cache | Enable the query cache within the block if Active Record is configured. | 
| uncached | Disable the query cache within the block if Active Record is configured. | 
| clear_active_connections!, clear_all_connections!, clear_reloadable_connections!, | |
| connection | Returns the connection currently associated with the class. | 
| connection_config | Returns the configuration of the associated connection as a hash: | 
| connection_pool, | |
| establish_connection | Establishes the connection to the database. | 
| remove_connection, retrieve_connection | |
| benchmark | Allows you to measure the execution time of a block in a template and records the result to the log. | 
| model_name | Returns an ::ActiveModel::Name object for module. | 
| #changed_for_autosave? | Returns whether or not this record has been changed in any way (including whether any of its nested autosave associations are likewise changed). | 
| #destroyed_by_association | Returns the association for the parent being destroyed. | 
| #destroyed_by_association= | Records the association that is being destroyed and destroying this record in the process. | 
| #marked_for_destruction? | Returns whether or not this record will be destroyed as part of the parents save transaction. | 
| #attribute_aliases, #attribute_aliases?, #attribute_method_matchers, #attribute_method_matchers?, | |
| #changed? | Returns  | 
| #id | Returns the primary key value. | 
| #id= | Sets the primary key value. | 
| #id? | Queries the primary key value. | 
| #destroyed? | Returns true if this object has been destroyed, otherwise returns false. | 
| #new_record? | Returns true if this object hasn't been saved yet – that is, a record for the object doesn't exist in the database yet; otherwise, returns false. | 
| #persisted? | Returns true if the record is persisted, i.e. | 
| #frozen? | Returns  | 
| #readonly? | Returns  | 
| #serializable_hash, | |
| #to_xml | Builds an XML document to represent the model. | 
| #as_json | Returns a hash representing the model. | 
| #from_json | Sets the model  | 
| #serializable_hash | Returns a serialized hash of your object. | 
| #add_to_transaction | Add the record to the current transaction so that the  | 
| #rollback_active_record_state! | Reset id and @new_record if the transaction rolls back. | 
| #transaction | See Transactions::ClassMethods for detailed documentation. | 
| #with_transaction_returning_status | Executes  | 
| #mark_for_destruction | Marks this record to be destroyed as part of the parents save transaction. | 
| #reload | Reloads the attributes of the object as usual and clears  | 
| #changed | Returns an array with the name of the attributes with unsaved changes. | 
| #changed_attributes | Returns a hash of the attributes with unsaved changes indicating their original values like  | 
| #changes | Returns a hash of changed attributes indicating their original and new values like  | 
| #previous_changes | Returns a hash of attributes that were changed before the model was saved. | 
| #restore_attributes | Restore all previous data of the provided attributes. | 
| #changes_applied | Removes current changes and makes them accessible through  | 
| #clear_attribute_changes | Remove changes information for the provided attributes. | 
| #clear_changes_information | Clear all dirty data: current changes and previous changes. | 
| #id_before_type_cast | Returns the primary key value before type cast. | 
| #id_was | Returns the primary key previous value. | 
| #to_key | Returns this record's primary key value wrapped in an ::Array if one is available. | 
| #attributes_before_type_cast | Returns a hash of attributes before typecasting and deserialization. | 
| #read_attribute_before_type_cast | Returns the value of the attribute identified by  | 
| #raw_write_attribute, | |
| #write_attribute | Updates the attribute identified by  | 
| #read_attribute | Returns the value of the attribute identified by  | 
| #[] | Returns the value of the attribute identified by  | 
| #[]= | Updates the attribute identified by  | 
| #attribute_for_inspect | Returns an  | 
| #attribute_names | Returns an array of names for the attributes available on this object. | 
| #attribute_present? | Returns  | 
| #attributes | Returns a hash of all the attributes with their names as keys and the values of the attributes as values. | 
| #has_attribute? | Returns  | 
| #respond_to? | A Person object with a name attribute can ask  | 
| #attribute_missing | 
 | 
| #method_missing | Allows access to the object attributes, which are held in the hash returned by  | 
| #respond_to?, | |
| #respond_to_without_attributes? | A  | 
| #lock! | Obtain a row lock on this record. | 
| #with_lock | Wraps the passed block in a transaction, locking the object before yielding. | 
| #save | The validation process on save can be skipped by passing  | 
| #save! | Attempts to save the record just like  | 
| #valid? | Runs all the validations within the specified context. | 
| #validate | Alias for Validations#valid?. | 
| #validate! | Runs all the validations within the specified context. | 
| #validates_absence_of | Validates that the specified attributes are blank (as defined by Object#blank?). | 
| #validates_acceptance_of | Encapsulates the pattern of wanting to validate the acceptance of a terms of service check box (or similar agreement). | 
| #validates_confirmation_of | Encapsulates the pattern of wanting to validate a password or email address field with a confirmation. | 
| #validates_exclusion_of | Validates that the value of the specified attribute is not in a particular enumerable object. | 
| #validates_format_of | Validates whether the value of the specified attribute is of the correct form, going by the regular expression provided. | 
| #validates_inclusion_of | Validates whether the value of the specified attribute is available in a particular enumerable object. | 
| #validates_length_of | Validates that the specified attribute matches the length restrictions supplied. | 
| #validates_numericality_of | Validates whether the value of the specified attribute is numeric by trying to convert it to a float with  | 
| #validates_presence_of | Validates that the specified attributes are not blank (as defined by Object#blank?). | 
| #validates_size_of | 
| #errors | Returns the  | 
| #invalid? | Performs the opposite of  | 
| #read_attribute_for_validation | Hook method defining how an attribute value should be retrieved. | 
| #valid? | Runs all the specified validations and returns  | 
| #validate | Alias for ActiveModel::Validations#valid?. | 
| #validates_with | Passes the record off to the class or classes specified and allows them to add errors based on more complex conditions. | 
| #cache_key | Returns a cache key that can be used to identify this record. | 
| #to_param | Returns a ::String, which Action Pack uses for constructing an URL to this object. | 
| #to_key | Returns an ::Array of all key attributes if any is set, regardless if the object is persisted or not. | 
| #to_model | If your object is already designed to implement all of the Active Model you can use the default  | 
| #to_param | Returns a  | 
| #to_partial_path | Returns a  | 
| #assign_attributes | Allows you to set all the attributes by passing in a hash of attributes with keys matching the attribute names (which again matches the column names). | 
| #quoted_id | TODO: Deprecate this. | 
| #becomes | Returns an instance of the specified  | 
| #becomes! | Wrapper around  | 
| #decrement | Initializes  | 
| #decrement! | Wrapper around  | 
| #delete | Deletes the record in the database and freezes this instance to reflect that no changes should be made (since they can't be persisted). | 
| #destroy | Deletes the record in the database and freezes this instance to reflect that no changes should be made (since they can't be persisted). | 
| #destroy! | Deletes the record in the database and freezes this instance to reflect that no changes should be made (since they can't be persisted). | 
| #increment | Initializes  | 
| #increment! | Wrapper around  | 
| #reload | Reloads the record from the database. | 
| #save | Saves the model. | 
| #save! | Saves the model. | 
| #toggle | Assigns to  | 
| #toggle! | Wrapper around  | 
| #touch | Saves the record with the updated_at/on attributes set to the current time. | 
| #update | Updates the attributes of the model from the passed-in hash and saves the record, all wrapped in a transaction. | 
| #update! | Updates its receiver just like  | 
| #update_attribute | Updates a single attribute and saves the record. | 
| #update_attributes | Alias for Persistence#update. | 
| #update_attributes! | Alias for Persistence#update!. | 
| #update_column | Equivalent to  | 
| #update_columns | Updates the attributes directly in the database issuing an UPDATE SQL statement and sets them in the receiver: | 
| #<=> | Allows sort on objects. | 
| #== | Returns true if  | 
| #clone | Identical to Ruby's clone method. | 
| #connection_handler, | |
| #dup | Duped objects have no id assigned and are treated as new records. | 
| #encode_with | Populate  | 
| #eql? | Alias for Core#==. | 
| #freeze | Clone and freeze the attributes hash such that associations are still accessible, even on destroyed records, but cloned models will not be frozen. | 
| #hash | Delegates to id in order to allow two records of the same type and id to work with something like: | 
| #init_with | Initialize an empty model object from  | 
| #initialize | New objects can be instantiated as either empty (pass no construction parameter) or pre-set with attributes but not yet saved (pass a hash with key names matching the associated table column names). | 
| #inspect | Returns the contents of the record as a nicely formatted string. | 
| #pretty_print | Takes a PP and prettily prints this record to it, allowing you to get a nice result from  | 
| #readonly! | Marks this record as read only. | 
| #slice | Returns a hash of the given methods with their names as keys and returned values as values. | 
This class handles dynamic methods through the method_missing method in the class ActiveModel::AttributeMethods
Boolean  (readonly)
  # File 'activerecord/lib/active_record/schema_migration.rb', line 20
def table_exists? connection.table_exists?(table_name) end
# File 'activerecord/lib/active_record/schema_migration.rb', line 24
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
# File 'activerecord/lib/active_record/schema_migration.rb', line 36
def drop_table connection.drop_table table_name if table_exists? end
# File 'activerecord/lib/active_record/schema_migration.rb', line 16
def index_name "#{table_name_prefix}unique_#{ActiveRecord::Base.schema_migrations_table_name}#{table_name_suffix}" end
# File 'activerecord/lib/active_record/schema_migration.rb', line 40
def normalize_migration_number(number) "%.3d" % number.to_i end
# File 'activerecord/lib/active_record/schema_migration.rb', line 44
def normalized_versions pluck(:version).map { |v| normalize_migration_number v } end
# File 'activerecord/lib/active_record/schema_migration.rb', line 8
def primary_key nil end
# File 'activerecord/lib/active_record/schema_migration.rb', line 12
def table_name "#{table_name_prefix}#{ActiveRecord::Base.schema_migrations_table_name}#{table_name_suffix}" end
# File 'activerecord/lib/active_record/schema_migration.rb', line 49
def version super.to_i end