Method: Sequel::Schema::AlterTableGenerator#set_column_default

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

#set_column_default(name, default) ⇒ Object

Modify the default value for one of the table’s column.

set_column_default(:artist_name, 'a') # ALTER COLUMN artist_name SET DEFAULT 'a'

To remove an existing default value, use nil as the value:

set_column_default(:artist_name, nil) # ALTER COLUMN artist_name SET DEFAULT NULL

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



655
656
657
658
# File 'lib/sequel/database/schema_generator.rb', line 655

def set_column_default(name, default)
  @operations << {:op => :set_column_default, :name => name, :default => default}
  nil
end