You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

081_create_projects_trackers.rb 620B

12345678910111213141516171819
  1. class CreateProjectsTrackers < ActiveRecord::Migration[4.2]
  2. def self.up
  3. create_table :projects_trackers, :id => false do |t|
  4. t.column :project_id, :integer, :default => 0, :null => false
  5. t.column :tracker_id, :integer, :default => 0, :null => false
  6. end
  7. add_index :projects_trackers, :project_id, :name => :projects_trackers_project_id
  8. # Associates all trackers to all projects (as it was before)
  9. tracker_ids = Tracker.all.collect(&:id)
  10. Project.all.each do |project|
  11. project.tracker_ids = tracker_ids
  12. end
  13. end
  14. def self.down
  15. drop_table :projects_trackers
  16. end
  17. end