Skip to content

Instantly share code, notes, and snippets.

@carlcrott
Created November 14, 2012 18:04
Show Gist options
  • Save carlcrott/4073714 to your computer and use it in GitHub Desktop.
Save carlcrott/4073714 to your computer and use it in GitHub Desktop.
class AddModelTypeToModels < ActiveRecord::Migration
class Models < ActiveRecord::Base; end
def self.up
add_column :models, :model_type, :string
Model.update_all("model_type = 'ED2'", "model_name like 'ed%'")
Model.update_all("model_type = 'SIPNET'", "model_name like 'sipnet%'")
Models.update_all("model_type = 'ED2'", "model_name like 'ed%'")
Models.update_all("model_type = 'SIPNET'", "model_name like 'sipnet%'")
Models.update_all("model_type = 'BIOCRO'", "model_name like 'biocro%'")
end
def self.down
remove_column :models, :model_type
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment