Sha256: 5d73aed22e4f6767df0fa71efb8e51df8a1eb09a0e1fb0a0895e7b29c801462d

Contents?: true

Size: 531 Bytes

Versions: 1

Compression:

Stored size: 531 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

1 entries across 1 versions & 1 rubygems

Version Path
houston-core-0.5.0.beta1 db/migrate/20120726231754_link_projects_and_maintainers.rb