Sha256: c969b35d0d526fe14b0fd2e997d225207bcb0145534544b8027e2756997e5453

Contents?: true

Size: 523 Bytes

Versions: 27

Compression:

Stored size: 523 Bytes

Contents

class LinkProjectsAndMaintainers < ActiveRecord::Migration
  def up
    create_table :projects_maintainers, :id => false do |t|
      t.references :project, :user
    end

    add_index :projects_maintainers, [:project_id, :user_id], :unique => true

    admins = User.where(role: "Administrator")
    Project.unscoped do
      Project.all.each do |project|
        admins.each do |admin|
          project.maintainers << admin
        end
      end
    end
  end

  def down
    drop_table :projects_maintainers
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
houston-core-0.5.6 db/migrate/20120726231754_link_projects_and_maintainers.rb
houston-core-0.5.5 db/migrate/20120726231754_link_projects_and_maintainers.rb
houston-core-0.5.4 db/migrate/20120726231754_link_projects_and_maintainers.rb
houston-core-0.5.3 db/migrate/20120726231754_link_projects_and_maintainers.rb
houston-core-0.5.2 db/migrate/20120726231754_link_projects_and_maintainers.rb
houston-core-0.5.1 db/migrate/20120726231754_link_projects_and_maintainers.rb
houston-core-0.5.0 db/migrate/20120726231754_link_projects_and_maintainers.rb