Commit f1579c7833c67e70e59ed3000cb4b1513947ea00
1 parent
8cf671ec
Exists in
master
and in
6 other branches
Showing
1 changed file
with
25 additions
and
0 deletions
Show diff stats
src/noosfero-spb/spb_migrations/db/migrate/20160308181957_move_contents_from_sistemadeatendimento_to_fila.rb
0 → 100644
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +class MoveContentsFromSistemadeatendimentoToFila < ActiveRecord::Migration | ||
2 | + def change | ||
3 | + environment = Environment.default | ||
4 | + sistemadeatendimento = environment.communities.where(:identifier => 'sistemadeatendimento').first | ||
5 | + fila = environment.communities.where(:identifier => 'fila').first | ||
6 | + | ||
7 | + # Migrate foruns | ||
8 | + | ||
9 | + source = sistemadeatendimento.folders.where(:slug => 'historico-de-foruns').first | ||
10 | + target = fila.folders.where(:slug => 'historico-de-foruns').first | ||
11 | + children = source.all_children | ||
12 | + | ||
13 | + execute("UPDATE articles SET parent_id = #{target.id} WHERE parent_id = #{source.id}") | ||
14 | + execute("UPDATE articles SET profile_id = #{fila.id} WHERE id in (#{children.map(&:id).join(',')})") | ||
15 | + | ||
16 | + # Migrate blog posts | ||
17 | + | ||
18 | + source = sistemadeatendimento.folders.where(:slug => 'blog').first | ||
19 | + target = fila.folders.where(:slug => 'blog').first | ||
20 | + children = source.all_children | ||
21 | + | ||
22 | + execute("UPDATE articles SET parent_id = #{target.id} WHERE parent_id = #{source.id}") | ||
23 | + execute("UPDATE articles SET profile_id = #{fila.id} WHERE id in (#{children.map(&:id).join(',')})") | ||
24 | + end | ||
25 | +end |