Class: ActiveRecord::ConnectionAdapters::SchemaDumper
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
ActiveRecord::SchemaDumper
|
Defined in: | activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb |
Constant Summary
-
DEFAULT_DATETIME_PRECISION =
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb', line 66
Class Attribute Summary
::ActiveRecord::SchemaDumper
- Inherited
.chk_ignore_pattern | Specify a custom regular expression matching check constraints which name should not be dumped to db/schema.rb. |
.excl_ignore_pattern | Specify a custom regular expression matching exclusion constraints which name should not be dumped to db/schema.rb. |
.fk_ignore_pattern | Specify a custom regular expression matching foreign keys which name should not be dumped to db/schema.rb. |
.ignore_tables | A list of tables which should not be dumped to the schema. |
.unique_ignore_pattern | Specify a custom regular expression matching unique constraints which name should not be dumped to db/schema.rb. |
Class Method Summary
::ActiveRecord::SchemaDumper
- Inherited
Instance Attribute Summary
::ActiveRecord::SchemaDumper
- Inherited
Instance Method Summary
- #column_spec(column) private
- #column_spec_for_primary_key(column) private
- #default_primary_key?(column) ⇒ Boolean private
- #explicit_primary_key_default?(column) ⇒ Boolean private
- #prepare_column_options(column) private
- #schema_collation(column) private
- #schema_default(column) private
- #schema_expression(column) private
- #schema_limit(column) private
- #schema_precision(column) private
- #schema_scale(column) private
- #schema_type(column) private
- #schema_type_with_virtual(column) private
::ActiveRecord::SchemaDumper
- Inherited
#dump, #check_constraints_in_create, #define_params, | |
#extensions | extensions are only supported by |
#foreign_keys, #format_colspec, #format_index_parts, #format_options, | |
#formatted_version | turns 20170404131909 into “2017_04_04_131909”. |
#header, #ignored?, #index_parts, | |
#indexes | Keep it for indexing materialized views. |
#indexes_in_create, #remove_prefix_and_suffix, | |
#schemas | schemas are only supported by |
#table, #tables, #trailer, | |
#types | (enum) types are only supported by |
#virtual_tables | virtual tables are only supported by SQLite. |
Constructor Details
This class inherits a constructor from ActiveRecord::SchemaDumper
Class Method Details
.create(connection, options)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb', line 8
def self.create(connection, ) new(connection, ) end
Instance Method Details
#column_spec(column) (private)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb', line 13
def column_spec(column) [schema_type_with_virtual(column), (column)] end
#column_spec_for_primary_key(column) (private)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb', line 17
def column_spec_for_primary_key(column) spec = {} spec[:id] = schema_type(column).inspect unless default_primary_key?(column) spec.merge!( (column).except!(:null)) spec[:default] ||= "nil" if explicit_primary_key_default?(column) spec end
#default_primary_key?(column) ⇒ Boolean
(private)
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb', line 38
def default_primary_key?(column) schema_type(column) == :bigint end
#explicit_primary_key_default?(column) ⇒ Boolean
(private)
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb', line 42
def explicit_primary_key_default?(column) false end
#prepare_column_options(column) (private)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb', line 25
def (column) spec = {} spec[:limit] = schema_limit(column) spec[:precision] = schema_precision(column) spec[:scale] = schema_scale(column) spec[:default] = schema_default(column) spec[:null] = "false" unless column.null spec[:collation] = schema_collation(column) spec[:comment] = column.comment.inspect if column.comment.present? spec.compact! spec end
#schema_collation(column) (private)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb', line 101
def schema_collation(column) column.collation.inspect if column.collation end
#schema_default(column) (private)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb', line 86
def schema_default(column) return unless column.has_default? type = @connection.lookup_cast_type_from_column(column) default = type.deserialize(column.default) if default.nil? schema_expression(column) else type.type_cast_for_schema(default) end end
#schema_expression(column) (private)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb', line 97
def schema_expression(column) "-> { #{column.default_function.inspect} }" if column.default_function end
#schema_limit(column) (private)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb', line 62
def schema_limit(column) limit = column.limit unless column.bigint? limit.inspect if limit && limit != @connection.native_database_types[column.type][:limit] end
#schema_precision(column) (private)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb', line 67
def schema_precision(column) if column.type == :datetime case column.precision when nil "nil" when DEFAULT_DATETIME_PRECISION nil else column.precision.inspect end elsif column.precision column.precision.inspect end end
#schema_scale(column) (private)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb', line 82
def schema_scale(column) column.scale.inspect if column.scale end
#schema_type(column) (private)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb', line 54
def schema_type(column) if column.bigint? :bigint else column.type end end
#schema_type_with_virtual(column) (private)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb', line 46
def schema_type_with_virtual(column) if @connection.supports_virtual_columns? && column.virtual? :virtual else schema_type(column) end end