Commit fce8bd402315bddfe3f6e71ea99fcff684d05d97
1 parent
a9f64c33
Exists in
master
and in
29 other branches
Migration to add ProductCategoriesBlock to all enterprises
ActionItem896
Showing
1 changed file
with
18 additions
and
0 deletions
Show diff stats
db/migrate/20130626152300_add_product_categories_block_to_enterprises.rb
0 → 100644
... | ... | @@ -0,0 +1,18 @@ |
1 | +class AddProductCategoriesBlockToEnterprises < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + Enterprise.find_each do |enterprise| | |
4 | + enterprise.boxes << Box.new while enterprise.boxes.length < 2 | |
5 | + enterprise.boxes[1].blocks << ProductCategoriesBlock.new | |
6 | + end | |
7 | + end | |
8 | + | |
9 | + def self.down | |
10 | + Enterprise.find_each do |enterprise| | |
11 | + enterprise.boxes.each do |box| | |
12 | + box.blocks.each do |block| | |
13 | + block.destroy if block.class == ProductCategoriesBlock | |
14 | + end | |
15 | + end | |
16 | + end | |
17 | + end | |
18 | +end | ... | ... |