Skip to content

Instantly share code, notes, and snippets.

@timkellogg
Last active August 29, 2015 14:28
Show Gist options
  • Save timkellogg/e6e320c8a620831a0d13 to your computer and use it in GitHub Desktop.
Save timkellogg/e6e320c8a620831a0d13 to your computer and use it in GitHub Desktop.
Rake Tasks,
http://jacopretorius.net/2014/02/all-rails-db-rake-tasks-and-what-they-do.html
http://guides.rubyonrails.org/active_record_basics.html
# many to many
class CreateEmployeesProjects < ActiveRecord::Migration
def change
create_table(:employees_projects) , id: false do |t|
t.column(:employee_id, :integer)
t.column(:project_id, :integer)
end
end
end
# add index
class AddIndexToEmployeesName < ActiveRecord::Migration
def change
add_index :employees, :lastname
end
end
# adding column
class AddBudgetToProjects < ActiveRecord::Migration
def change
add_column(:projects, :budget, :money)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment