Class: DbSchema::Operations::AlterColumnType

Inherits:
Object
  • Object
show all
Defined in:
lib/db_schema/operations.rb

Constant Summary collapse

SERIAL_TYPES =
[:smallserial, :serial, :bigserial].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, old_type:, new_type:, using: nil, **new_attributes) ⇒ AlterColumnType

Returns a new instance of AlterColumnType.



88
89
90
91
92
93
94
# File 'lib/db_schema/operations.rb', line 88

def initialize(name, old_type:, new_type:, using: nil, **new_attributes)
  @name           = name
  @old_type       = old_type
  @new_type       = new_type
  @using          = using
  @new_attributes = new_attributes
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



86
87
88
# File 'lib/db_schema/operations.rb', line 86

def name
  @name
end

#new_attributesObject (readonly)

Returns the value of attribute new_attributes.



86
87
88
# File 'lib/db_schema/operations.rb', line 86

def new_attributes
  @new_attributes
end

#new_typeObject (readonly)

Returns the value of attribute new_type.



86
87
88
# File 'lib/db_schema/operations.rb', line 86

def new_type
  @new_type
end

#old_typeObject (readonly)

Returns the value of attribute old_type.



86
87
88
# File 'lib/db_schema/operations.rb', line 86

def old_type
  @old_type
end

#usingObject (readonly)

Returns the value of attribute using.



86
87
88
# File 'lib/db_schema/operations.rb', line 86

def using
  @using
end

Instance Method Details

#from_serial?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/db_schema/operations.rb', line 96

def from_serial?
  SERIAL_TYPES.include?(old_type)
end

#to_serial?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/db_schema/operations.rb', line 100

def to_serial?
  SERIAL_TYPES.include?(new_type)
end