Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce the Number of Migration Files #660

Open
wants to merge 4 commits into
base: rails4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions db/migrate/20110214221555_create_forem_forums.rb

This file was deleted.

11 changes: 0 additions & 11 deletions db/migrate/20110221092741_create_forem_topics.rb

This file was deleted.

11 changes: 0 additions & 11 deletions db/migrate/20110221094502_create_forem_posts.rb

This file was deleted.

5 changes: 0 additions & 5 deletions db/migrate/20110228084940_add_reply_to_to_forem_posts.rb

This file was deleted.

5 changes: 0 additions & 5 deletions db/migrate/20110519210300_add_locked_to_forem_topics.rb

This file was deleted.

5 changes: 0 additions & 5 deletions db/migrate/20110519222000_add_pinned_to_forem_topics.rb

This file was deleted.

9 changes: 0 additions & 9 deletions db/migrate/20110520150056_add_forem_views.rb

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions db/migrate/20110626160056_add_hidden_to_forem_topics.rb

This file was deleted.

12 changes: 0 additions & 12 deletions db/migrate/20111026143136_add_indexes_to_topics_posts_views.rb

This file was deleted.

8 changes: 0 additions & 8 deletions db/migrate/20111103210835_create_forem_categories.rb

This file was deleted.

9 changes: 0 additions & 9 deletions db/migrate/20111103214432_add_category_id_to_forums.rb

This file was deleted.

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions db/migrate/20120222000227_add_forem_topics_last_post_at.rb

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions db/migrate/20120228194653_approve_all_topics_and_posts.rb

This file was deleted.

5 changes: 0 additions & 5 deletions db/migrate/20120228202859_add_notified_to_forem_posts.rb

This file was deleted.

12 changes: 0 additions & 12 deletions db/migrate/20120229165013_make_forem_views_polymorphic.rb

This file was deleted.

23 changes: 0 additions & 23 deletions db/migrate/20120302152918_add_forem_view_fields.rb

This file was deleted.

11 changes: 0 additions & 11 deletions db/migrate/20120616193446_add_forem_admin.rb

This file was deleted.

11 changes: 0 additions & 11 deletions db/migrate/20120616193447_add_forem_state.rb

This file was deleted.

11 changes: 0 additions & 11 deletions db/migrate/20120616193448_add_forem_auto_subscribe.rb

This file was deleted.

18 changes: 0 additions & 18 deletions db/migrate/20120718073130_add_friendly_id_slugs.rb

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions db/migrate/20140917034000_add_position_to_categories.rb

This file was deleted.

5 changes: 0 additions & 5 deletions db/migrate/20140917201619_add_position_to_forums.rb

This file was deleted.

24 changes: 24 additions & 0 deletions db/migrate/20150514185633_create_forem_forums.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class CreateForemForums < ActiveRecord::Migration
def change
create_table :forem_forums do |t|
t.string :name
t.text :description

t.integer :category_id
t.integer :views_count, :default=>0
t.string :slug
t.integer :position, :default => 0

t.index :slug, :unique => true
end

if Forem::Forum.count > 0
Forem::Forum.update_all :category_id => Forem::Category.first.id
end
Forem::Forum.find_each do |forum|
forum.update_column(:views_count, forum.topics.sum(:views_count))
end
Forem::Forum.reset_column_information
Forem::Forum.find_each {|t| t.save! }
end
end
35 changes: 35 additions & 0 deletions db/migrate/20150514185634_create_forem_topics.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
class CreateForemTopics < ActiveRecord::Migration
def change
create_table :forem_topics do |t|
t.integer :forum_id
t.integer :user_id
t.string :subject
t.timestamps :null => false

t.boolean :locked, :null => false, :default => false
t.boolean :pinned, :default => false, :nullable => false
t.boolean :hidden, :default => false
t.string :state, :default => 'pending_review'
t.datetime :last_post_at
t.integer :views_count, :default=>0
t.string :slug

t.index :forum_id
t.index :user_id
t.index :state
t.index :slug, :unique => true
end

Forem::Topic.reset_column_information
Forem::Topic.includes(:posts).find_each do |t|
post = t.posts.last
t.update_attribute(:last_post_at, post.updated_at)
end
Forem::Topic.update_all :state => "approved"
Forem::Topic.find_each do |topic|
topic.update_column(:views_count, topic.views.sum(:count))
end
Forem::Topic.reset_column_information
Forem::Topic.find_each {|t| t.save! }
end
end
21 changes: 21 additions & 0 deletions db/migrate/20150514185635_create_forem_posts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class CreateForemPosts < ActiveRecord::Migration
def change
create_table :forem_posts do |t|
t.integer :topic_id
t.text :text
t.integer :user_id
t.timestamps :null => false

t.integer :reply_to_id
t.string :state, :default => 'pending_review'
t.boolean :notified, :default => false

t.index :topic_id
t.index :user_id
t.index :reply_to_id
t.index :state
end

Forem::Post.update_all :state => "approved"
end
end
Loading