Skip to content

Instantly share code, notes, and snippets.

@marshallmick007
Last active August 10, 2017 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marshallmick007/58c48341f6598c2303ed6cc1b14c29ba to your computer and use it in GitHub Desktop.
Save marshallmick007/58c48341f6598c2303ed6cc1b14c29ba to your computer and use it in GitHub Desktop.

Quick Links

Traditional Column Change

Sequel.migration do
  change do
    alter_table(:table_name) do
      add_column :name, String, :null => true
    do
  do
end

Up / Down Column Change

Sequel.migration do
  up do
    alter_table(:table_name) do
      add_column :name, String, :null => true
    do
  do
  down do
    alter_table(:table_name) do
      drop_column :name
    end
  end
end

Insert / Delete Records

Sequel.migration do                                                                            
  up do
    bs_id = self[:my_table].insert(:name => 'food', :title => 'bar', :type => '1103')
  end

  down do
    from(:my_table).where(:name => 'foo').delete
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment