sideplace_app/db/migrate/20150730183145_create_annonce_account_newsgroups.rb

21 lines
587 B
Ruby

class CreateAnnonceAccountNewsgroups < ActiveRecord::Migration
def change
create_table :annonce_account_newsgroups do |t|
t.references :annonce_account, index: true
t.references :newsgroup, index: true
t.timestamps null: false
end
add_foreign_key :annonce_account_newsgroups, :annonce_accounts
add_foreign_key :annonce_account_newsgroups, :newsgroups
newsgroups = Newsgroup.where(:default_checked => true).all
AnnonceAccount.all.each do |annonce_account|
annonce_account.newsgroups << newsgroups
end
end
end