Method: Sequel::Schema::AlterTableGenerator#set_column_type

Defined in:
lib/sequel/database/schema_generator.rb

#set_column_type(name, type, opts = OPTS) ⇒ Object

Modify the type of one of the table’s column. The given options are considered when determining the new type.

set_column_type(:artist_name, 'char(10)') # ALTER COLUMN artist_name TYPE char(10)
set_column_type(:artist_name, String, size: 10) # ALTER COLUMN artist_name TYPE varchar(10)

PostgreSQL specific options:

:using

Add a USING clause that specifies how to convert existing values to new values.

On MySQL, make sure to use a symbol for the name of the column, as otherwise you can lose the default and NULL/NOT NULL setting for the column.



672
673
674
675
# File 'lib/sequel/database/schema_generator.rb', line 672

def set_column_type(name, type, opts=OPTS)
  @operations << {:op => :set_column_type, :name => name, :type => type}.merge!(opts)
  nil
end