Class: ActiveRecord::ConnectionAdapters::TableDefinition
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::TableDefinition
- Defined in:
- lib/activerecord-mysql-unsigned/active_record/v3/connection_adapters/abstract/schema_definitions.rb,
lib/activerecord-mysql-unsigned/active_record/v4/connection_adapters/abstract/schema_definitions.rb
Instance Method Summary collapse
Instance Method Details
#column(name, type, options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/activerecord-mysql-unsigned/active_record/v3/connection_adapters/abstract/schema_definitions.rb', line 29 def column(name, type, = {}) name = name.to_s type = type.to_sym column = self[name] || new_column_definition(@base, name, type) limit = .fetch(:limit) do native[type][:limit] if native[type].is_a?(Hash) end column.limit = limit column.unsigned = [:unsigned] column.auto_increment = [:auto_increment] column.precision = [:precision] column.scale = [:scale] column.default = [:default] column.null = [:null] self end |
#new_column_definition(name, type, options) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/activerecord-mysql-unsigned/active_record/v4/connection_adapters/abstract/schema_definitions.rb', line 19 def new_column_definition(name, type, ) column = create_column_definition name, type limit = .fetch(:limit) do native[type][:limit] if native[type].is_a?(Hash) end column.limit = limit column.array = [:array] if column.respond_to?(:array) column.precision = [:precision] column.scale = [:scale] column.unsigned = [:unsigned] column.default = [:default] column.null = [:null] column.first = [:first] column.after = [:after] column.primary_key = type == :primary_key || [:primary_key] column end |