From 3c432ec8501e580f415002a1b5b76b756285f487 Mon Sep 17 00:00:00 2001 From: TekuConcept Date: Thu, 14 May 2015 15:48:02 -0600 Subject: [PATCH 1/4] reduced the number of migration files --- db/migrate/20110214221555_create_forem_forums.rb | 13 ------------- db/migrate/20110221092741_create_forem_topics.rb | 11 ----------- db/migrate/20110221094502_create_forem_posts.rb | 11 ----------- .../20110228084940_add_reply_to_to_forem_posts.rb | 5 ----- .../20110519210300_add_locked_to_forem_topics.rb | 5 ----- .../20110519222000_add_pinned_to_forem_topics.rb | 5 ----- 6 files changed, 50 deletions(-) delete mode 100644 db/migrate/20110214221555_create_forem_forums.rb delete mode 100644 db/migrate/20110221092741_create_forem_topics.rb delete mode 100644 db/migrate/20110221094502_create_forem_posts.rb delete mode 100644 db/migrate/20110228084940_add_reply_to_to_forem_posts.rb delete mode 100644 db/migrate/20110519210300_add_locked_to_forem_topics.rb delete mode 100644 db/migrate/20110519222000_add_pinned_to_forem_topics.rb diff --git a/db/migrate/20110214221555_create_forem_forums.rb b/db/migrate/20110214221555_create_forem_forums.rb deleted file mode 100644 index 334879c3e..000000000 --- a/db/migrate/20110214221555_create_forem_forums.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateForemForums < ActiveRecord::Migration - def up - create_table :forem_forums do |t| - t.string :title - t.text :description - end - - end - - def down - drop_table :forem_forums - end -end diff --git a/db/migrate/20110221092741_create_forem_topics.rb b/db/migrate/20110221092741_create_forem_topics.rb deleted file mode 100644 index 12be28b22..000000000 --- a/db/migrate/20110221092741_create_forem_topics.rb +++ /dev/null @@ -1,11 +0,0 @@ -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 - end - end -end diff --git a/db/migrate/20110221094502_create_forem_posts.rb b/db/migrate/20110221094502_create_forem_posts.rb deleted file mode 100644 index 9b10bfe4f..000000000 --- a/db/migrate/20110221094502_create_forem_posts.rb +++ /dev/null @@ -1,11 +0,0 @@ -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 - end - end -end diff --git a/db/migrate/20110228084940_add_reply_to_to_forem_posts.rb b/db/migrate/20110228084940_add_reply_to_to_forem_posts.rb deleted file mode 100644 index 6cc07fba4..000000000 --- a/db/migrate/20110228084940_add_reply_to_to_forem_posts.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddReplyToToForemPosts < ActiveRecord::Migration - def change - add_column :forem_posts, :reply_to_id, :integer - end -end diff --git a/db/migrate/20110519210300_add_locked_to_forem_topics.rb b/db/migrate/20110519210300_add_locked_to_forem_topics.rb deleted file mode 100644 index ecebc3428..000000000 --- a/db/migrate/20110519210300_add_locked_to_forem_topics.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddLockedToForemTopics < ActiveRecord::Migration - def change - add_column :forem_topics, :locked, :boolean, :null => false, :default => false - end -end diff --git a/db/migrate/20110519222000_add_pinned_to_forem_topics.rb b/db/migrate/20110519222000_add_pinned_to_forem_topics.rb deleted file mode 100644 index a0d6b6c96..000000000 --- a/db/migrate/20110519222000_add_pinned_to_forem_topics.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddPinnedToForemTopics < ActiveRecord::Migration - def change - add_column :forem_topics, :pinned, :boolean, :default => false, :nullable => false - end -end From bae53f079afe3ee9e594cc4f29ef9eb0cd5701a3 Mon Sep 17 00:00:00 2001 From: TekuConcept Date: Thu, 14 May 2015 15:55:02 -0600 Subject: [PATCH 2/4] reduce the number of migrations --- db/migrate/20110520150056_add_forem_views.rb | 9 ---- ...add_updated_at_and_count_to_forem_views.rb | 6 --- ...110626160056_add_hidden_to_forem_topics.rb | 5 -- ...43136_add_indexes_to_topics_posts_views.rb | 12 ----- .../20111103210835_create_forem_categories.rb | 8 ---- ...0111103214432_add_category_id_to_forums.rb | 9 ---- ...95806_add_pending_review_to_forem_posts.rb | 8 ---- ...5807_add_pending_review_to_forem_topics.rb | 8 ---- ...222000227_add_forem_topics_last_post_at.rb | 14 ------ ...20120222204450_create_forem_memberships.rb | 10 ---- ...223162058_create_forem_moderator_groups.rb | 10 ---- ...pending_review_add_state_to_forem_posts.rb | 16 ------- ...ding_review_from_forem_topics_add_state.rb | 16 ------- ...0228194653_approve_all_topics_and_posts.rb | 10 ---- ...20228202859_add_notified_to_forem_posts.rb | 5 -- ...0229165013_make_forem_views_polymorphic.rb | 12 ----- .../20120302152918_add_forem_view_fields.rb | 23 --------- db/migrate/20120616193446_add_forem_admin.rb | 11 ----- db/migrate/20120616193447_add_forem_state.rb | 11 ----- ...20120616193448_add_forem_auto_subscribe.rb | 11 ----- .../20120718073130_add_friendly_id_slugs.rb | 18 ------- ...19_rename_title_to_name_on_forem_forums.rb | 9 ---- ...140917034000_add_position_to_categories.rb | 5 -- .../20140917201619_add_position_to_forums.rb | 5 -- .../20150514185633_create_forem_forums.rb | 20 ++++++++ .../20150514185634_create_forem_topics.rb | 27 +++++++++++ .../20150514185635_create_forem_posts.rb | 23 +++++++++ .../20150514185636_create_forem_views.rb | 19 ++++++++ .../20150514185637_create_forem_categories.rb | 13 +++++ ...50514185638_create_forem_subscriptions.rb} | 1 + ... => 20150514185639_create_forem_groups.rb} | 5 +- ...20150514185640_create_forem_memberships.rb | 11 +++++ ...514185641_create_forem_moderator_groups.rb | 11 +++++ db/migrate/20150514185642_add_forem_admin.rb | 22 +++++++++ .../20150514185643_update_forem_tables.rb | 47 +++++++++++++++++++ 35 files changed, 197 insertions(+), 253 deletions(-) delete mode 100644 db/migrate/20110520150056_add_forem_views.rb delete mode 100644 db/migrate/20110626150056_add_updated_at_and_count_to_forem_views.rb delete mode 100644 db/migrate/20110626160056_add_hidden_to_forem_topics.rb delete mode 100644 db/migrate/20111026143136_add_indexes_to_topics_posts_views.rb delete mode 100644 db/migrate/20111103210835_create_forem_categories.rb delete mode 100644 db/migrate/20111103214432_add_category_id_to_forums.rb delete mode 100644 db/migrate/20120221195806_add_pending_review_to_forem_posts.rb delete mode 100644 db/migrate/20120221195807_add_pending_review_to_forem_topics.rb delete mode 100644 db/migrate/20120222000227_add_forem_topics_last_post_at.rb delete mode 100644 db/migrate/20120222204450_create_forem_memberships.rb delete mode 100644 db/migrate/20120223162058_create_forem_moderator_groups.rb delete mode 100644 db/migrate/20120227195911_remove_pending_review_add_state_to_forem_posts.rb delete mode 100644 db/migrate/20120227202639_remove_pending_review_from_forem_topics_add_state.rb delete mode 100644 db/migrate/20120228194653_approve_all_topics_and_posts.rb delete mode 100644 db/migrate/20120228202859_add_notified_to_forem_posts.rb delete mode 100644 db/migrate/20120229165013_make_forem_views_polymorphic.rb delete mode 100644 db/migrate/20120302152918_add_forem_view_fields.rb delete mode 100644 db/migrate/20120616193446_add_forem_admin.rb delete mode 100644 db/migrate/20120616193447_add_forem_state.rb delete mode 100644 db/migrate/20120616193448_add_forem_auto_subscribe.rb delete mode 100644 db/migrate/20120718073130_add_friendly_id_slugs.rb delete mode 100644 db/migrate/20121203093719_rename_title_to_name_on_forem_forums.rb delete mode 100644 db/migrate/20140917034000_add_position_to_categories.rb delete mode 100644 db/migrate/20140917201619_add_position_to_forums.rb create mode 100644 db/migrate/20150514185633_create_forem_forums.rb create mode 100644 db/migrate/20150514185634_create_forem_topics.rb create mode 100644 db/migrate/20150514185635_create_forem_posts.rb create mode 100644 db/migrate/20150514185636_create_forem_views.rb create mode 100644 db/migrate/20150514185637_create_forem_categories.rb rename db/migrate/{20111208014437_create_forem_subscriptions.rb => 20150514185638_create_forem_subscriptions.rb} (75%) rename db/migrate/{20120222155549_create_forem_groups.rb => 20150514185639_create_forem_groups.rb} (61%) create mode 100644 db/migrate/20150514185640_create_forem_memberships.rb create mode 100644 db/migrate/20150514185641_create_forem_moderator_groups.rb create mode 100644 db/migrate/20150514185642_add_forem_admin.rb create mode 100644 db/migrate/20150514185643_update_forem_tables.rb diff --git a/db/migrate/20110520150056_add_forem_views.rb b/db/migrate/20110520150056_add_forem_views.rb deleted file mode 100644 index a6f7b7f8d..000000000 --- a/db/migrate/20110520150056_add_forem_views.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddForemViews < ActiveRecord::Migration - def change - create_table :forem_views do |t| - t.integer :user_id - t.integer :topic_id - t.datetime :created_at - end - end -end diff --git a/db/migrate/20110626150056_add_updated_at_and_count_to_forem_views.rb b/db/migrate/20110626150056_add_updated_at_and_count_to_forem_views.rb deleted file mode 100644 index d1d8c0fba..000000000 --- a/db/migrate/20110626150056_add_updated_at_and_count_to_forem_views.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddUpdatedAtAndCountToForemViews < ActiveRecord::Migration - def change - add_column :forem_views, :updated_at, :datetime - add_column :forem_views, :count, :integer, :default => 0 - end -end diff --git a/db/migrate/20110626160056_add_hidden_to_forem_topics.rb b/db/migrate/20110626160056_add_hidden_to_forem_topics.rb deleted file mode 100644 index 770fb7385..000000000 --- a/db/migrate/20110626160056_add_hidden_to_forem_topics.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddHiddenToForemTopics < ActiveRecord::Migration - def change - add_column :forem_topics, :hidden, :boolean, :default => false - end -end diff --git a/db/migrate/20111026143136_add_indexes_to_topics_posts_views.rb b/db/migrate/20111026143136_add_indexes_to_topics_posts_views.rb deleted file mode 100644 index 62f91beb3..000000000 --- a/db/migrate/20111026143136_add_indexes_to_topics_posts_views.rb +++ /dev/null @@ -1,12 +0,0 @@ -class AddIndexesToTopicsPostsViews < ActiveRecord::Migration - def change - add_index :forem_topics, :forum_id - add_index :forem_topics, :user_id - add_index :forem_posts, :topic_id - add_index :forem_posts, :user_id - add_index :forem_posts, :reply_to_id - add_index :forem_views, :user_id - add_index :forem_views, :topic_id - add_index :forem_views, :updated_at - end -end diff --git a/db/migrate/20111103210835_create_forem_categories.rb b/db/migrate/20111103210835_create_forem_categories.rb deleted file mode 100644 index 2cc5090ee..000000000 --- a/db/migrate/20111103210835_create_forem_categories.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateForemCategories < ActiveRecord::Migration - def change - create_table :forem_categories do |t| - t.string :name, :null => false - t.timestamps - end - end -end diff --git a/db/migrate/20111103214432_add_category_id_to_forums.rb b/db/migrate/20111103214432_add_category_id_to_forums.rb deleted file mode 100644 index a59663b9c..000000000 --- a/db/migrate/20111103214432_add_category_id_to_forums.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddCategoryIdToForums < ActiveRecord::Migration - def change - add_column :forem_forums, :category_id, :integer - - if Forem::Forum.count > 0 - Forem::Forum.update_all :category_id => Forem::Category.first.id - end - end -end diff --git a/db/migrate/20120221195806_add_pending_review_to_forem_posts.rb b/db/migrate/20120221195806_add_pending_review_to_forem_posts.rb deleted file mode 100644 index b3f876693..000000000 --- a/db/migrate/20120221195806_add_pending_review_to_forem_posts.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddPendingReviewToForemPosts < ActiveRecord::Migration - def change - add_column :forem_posts, :pending_review, :boolean, :default => true - - Forem::Post.reset_column_information - Forem::Post.update_all :pending_review => false - end -end diff --git a/db/migrate/20120221195807_add_pending_review_to_forem_topics.rb b/db/migrate/20120221195807_add_pending_review_to_forem_topics.rb deleted file mode 100644 index 6b0bdbd51..000000000 --- a/db/migrate/20120221195807_add_pending_review_to_forem_topics.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddPendingReviewToForemTopics < ActiveRecord::Migration - def change - add_column :forem_topics, :pending_review, :boolean, :default => true - - Forem::Topic.reset_column_information - Forem::Topic.update_all :pending_review => false - end -end diff --git a/db/migrate/20120222000227_add_forem_topics_last_post_at.rb b/db/migrate/20120222000227_add_forem_topics_last_post_at.rb deleted file mode 100644 index 1451b54f7..000000000 --- a/db/migrate/20120222000227_add_forem_topics_last_post_at.rb +++ /dev/null @@ -1,14 +0,0 @@ -class AddForemTopicsLastPostAt < ActiveRecord::Migration - def up - add_column :forem_topics, :last_post_at, :datetime - 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 - end - - def down - remove_column :forem_topics, :last_post_at - end -end diff --git a/db/migrate/20120222204450_create_forem_memberships.rb b/db/migrate/20120222204450_create_forem_memberships.rb deleted file mode 100644 index 840832da7..000000000 --- a/db/migrate/20120222204450_create_forem_memberships.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateForemMemberships < ActiveRecord::Migration - def change - create_table :forem_memberships do |t| - t.integer :group_id - t.integer :member_id - end - - add_index :forem_memberships, :group_id - end -end diff --git a/db/migrate/20120223162058_create_forem_moderator_groups.rb b/db/migrate/20120223162058_create_forem_moderator_groups.rb deleted file mode 100644 index 48502b9ba..000000000 --- a/db/migrate/20120223162058_create_forem_moderator_groups.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateForemModeratorGroups < ActiveRecord::Migration - def change - create_table :forem_moderator_groups do |t| - t.integer :forum_id - t.integer :group_id - end - - add_index :forem_moderator_groups, :forum_id - end -end diff --git a/db/migrate/20120227195911_remove_pending_review_add_state_to_forem_posts.rb b/db/migrate/20120227195911_remove_pending_review_add_state_to_forem_posts.rb deleted file mode 100644 index 4a43307a7..000000000 --- a/db/migrate/20120227195911_remove_pending_review_add_state_to_forem_posts.rb +++ /dev/null @@ -1,16 +0,0 @@ -class RemovePendingReviewAddStateToForemPosts < ActiveRecord::Migration - def up - remove_column :forem_posts, :pending_review - add_column :forem_posts, :state, :string, :default => 'pending_review' - add_index :forem_posts, :state - end - - def down - remove_index :forem_posts, :state - remove_column :forem_posts, :state - add_column :forem_posts, :pending_review, :boolean, :default => true - - Forem::Post.reset_column_information - Forem::Post.update_all :pending_review => false - end -end diff --git a/db/migrate/20120227202639_remove_pending_review_from_forem_topics_add_state.rb b/db/migrate/20120227202639_remove_pending_review_from_forem_topics_add_state.rb deleted file mode 100644 index 567554876..000000000 --- a/db/migrate/20120227202639_remove_pending_review_from_forem_topics_add_state.rb +++ /dev/null @@ -1,16 +0,0 @@ -class RemovePendingReviewFromForemTopicsAddState < ActiveRecord::Migration - def up - remove_column :forem_topics, :pending_review - add_column :forem_topics, :state, :string, :default => 'pending_review' - add_index :forem_topics, :state - end - - def down - remove_index :forem_topics, :state - remove_column :forem_topics, :state - add_column :forem_topics, :pending_review, :boolean, :default => true - - Forem::Topic.reset_column_information - Forem::Topic.update_all :pending_review => false - end -end diff --git a/db/migrate/20120228194653_approve_all_topics_and_posts.rb b/db/migrate/20120228194653_approve_all_topics_and_posts.rb deleted file mode 100644 index 830cf1c90..000000000 --- a/db/migrate/20120228194653_approve_all_topics_and_posts.rb +++ /dev/null @@ -1,10 +0,0 @@ -class ApproveAllTopicsAndPosts < ActiveRecord::Migration - def up - Forem::Topic.update_all :state => "approved" - Forem::Post.update_all :state => "approved" - end - - def down - end -end - diff --git a/db/migrate/20120228202859_add_notified_to_forem_posts.rb b/db/migrate/20120228202859_add_notified_to_forem_posts.rb deleted file mode 100644 index 233ff5fc5..000000000 --- a/db/migrate/20120228202859_add_notified_to_forem_posts.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddNotifiedToForemPosts < ActiveRecord::Migration - def change - add_column :forem_posts, :notified, :boolean, :default => false - end -end diff --git a/db/migrate/20120229165013_make_forem_views_polymorphic.rb b/db/migrate/20120229165013_make_forem_views_polymorphic.rb deleted file mode 100644 index 55f49815a..000000000 --- a/db/migrate/20120229165013_make_forem_views_polymorphic.rb +++ /dev/null @@ -1,12 +0,0 @@ -class MakeForemViewsPolymorphic < ActiveRecord::Migration - def up - rename_column :forem_views, :topic_id, :viewable_id - add_column :forem_views, :viewable_type, :string - Forem::View.update_all("viewable_type='Forem::Topic'") - end - - def down - remove_column :forem_views, :viewable_type - rename_column :forem_views, :viewable_id, :topic_id - end -end diff --git a/db/migrate/20120302152918_add_forem_view_fields.rb b/db/migrate/20120302152918_add_forem_view_fields.rb deleted file mode 100644 index 0f11e630a..000000000 --- a/db/migrate/20120302152918_add_forem_view_fields.rb +++ /dev/null @@ -1,23 +0,0 @@ -class AddForemViewFields < ActiveRecord::Migration - def up - add_column :forem_views, :current_viewed_at, :datetime - add_column :forem_views, :past_viewed_at, :datetime - add_column :forem_topics, :views_count, :integer, :default=>0 - add_column :forem_forums, :views_count, :integer, :default=>0 - - Forem::Topic.find_each do |topic| - topic.update_column(:views_count, topic.views.sum(:count)) - end - - Forem::Forum.find_each do |forum| - forum.update_column(:views_count, forum.topics.sum(:views_count)) - end - end - - def down - remove_column :forem_views, :current_viewed_at - remove_column :forem_views, :past_viewed_at - remove_column :forem_topics, :views_count - remove_column :forem_forums, :views_count - end -end diff --git a/db/migrate/20120616193446_add_forem_admin.rb b/db/migrate/20120616193446_add_forem_admin.rb deleted file mode 100644 index 61958a6d7..000000000 --- a/db/migrate/20120616193446_add_forem_admin.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddForemAdmin < ActiveRecord::Migration - def change - unless column_exists?(user_class, :forem_admin) - add_column user_class, :forem_admin, :boolean, :default => false - end - end - - def user_class - Forem.user_class.table_name.downcase.to_sym - end -end diff --git a/db/migrate/20120616193447_add_forem_state.rb b/db/migrate/20120616193447_add_forem_state.rb deleted file mode 100644 index 19631d5fb..000000000 --- a/db/migrate/20120616193447_add_forem_state.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddForemState < ActiveRecord::Migration - def change - unless column_exists?(user_class, :forem_state) - add_column user_class, :forem_state, :string, :default => 'pending_review' - end - end - - def user_class - Forem.user_class.table_name.downcase.to_sym - end -end diff --git a/db/migrate/20120616193448_add_forem_auto_subscribe.rb b/db/migrate/20120616193448_add_forem_auto_subscribe.rb deleted file mode 100644 index 42227fc4d..000000000 --- a/db/migrate/20120616193448_add_forem_auto_subscribe.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddForemAutoSubscribe < ActiveRecord::Migration - def change - unless column_exists?(user_class, :forem_auto_subscribe) - add_column user_class, :forem_auto_subscribe, :boolean, :default => false - end - end - - def user_class - Forem.user_class.table_name.downcase.to_sym - end -end \ No newline at end of file diff --git a/db/migrate/20120718073130_add_friendly_id_slugs.rb b/db/migrate/20120718073130_add_friendly_id_slugs.rb deleted file mode 100644 index 10fa71ff6..000000000 --- a/db/migrate/20120718073130_add_friendly_id_slugs.rb +++ /dev/null @@ -1,18 +0,0 @@ -class AddFriendlyIdSlugs < ActiveRecord::Migration - def change - add_column :forem_forums, :slug, :string - add_index :forem_forums, :slug, :unique => true - Forem::Forum.reset_column_information - Forem::Forum.find_each {|t| t.save! } - - add_column :forem_categories, :slug, :string - add_index :forem_categories, :slug, :unique => true - Forem::Category.reset_column_information - Forem::Category.find_each {|t| t.save! } - - add_column :forem_topics, :slug, :string - add_index :forem_topics, :slug, :unique => true - Forem::Topic.reset_column_information - Forem::Topic.find_each {|t| t.save! } - end -end diff --git a/db/migrate/20121203093719_rename_title_to_name_on_forem_forums.rb b/db/migrate/20121203093719_rename_title_to_name_on_forem_forums.rb deleted file mode 100644 index 4c83d7d56..000000000 --- a/db/migrate/20121203093719_rename_title_to_name_on_forem_forums.rb +++ /dev/null @@ -1,9 +0,0 @@ -class RenameTitleToNameOnForemForums < ActiveRecord::Migration - def up - rename_column :forem_forums, :title, :name - end - - def down - rename_column :forem_forums, :name, :title - end -end diff --git a/db/migrate/20140917034000_add_position_to_categories.rb b/db/migrate/20140917034000_add_position_to_categories.rb deleted file mode 100644 index 29fdf710f..000000000 --- a/db/migrate/20140917034000_add_position_to_categories.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddPositionToCategories < ActiveRecord::Migration - def change - add_column :forem_categories, :position, :integer, :default => 0 - end -end diff --git a/db/migrate/20140917201619_add_position_to_forums.rb b/db/migrate/20140917201619_add_position_to_forums.rb deleted file mode 100644 index 740f18684..000000000 --- a/db/migrate/20140917201619_add_position_to_forums.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddPositionToForums < ActiveRecord::Migration - def change - add_column :forem_forums, :position, :integer, :default => 0 - end -end diff --git a/db/migrate/20150514185633_create_forem_forums.rb b/db/migrate/20150514185633_create_forem_forums.rb new file mode 100644 index 000000000..078532b0f --- /dev/null +++ b/db/migrate/20150514185633_create_forem_forums.rb @@ -0,0 +1,20 @@ +# This migration comes from forem (originally 20110214221555) +class CreateForemForums < ActiveRecord::Migration + def up + 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 + end + + def down + drop_table :forem_forums + end +end \ No newline at end of file diff --git a/db/migrate/20150514185634_create_forem_topics.rb b/db/migrate/20150514185634_create_forem_topics.rb new file mode 100644 index 000000000..a6c2ee605 --- /dev/null +++ b/db/migrate/20150514185634_create_forem_topics.rb @@ -0,0 +1,27 @@ +# This migration comes from forem (originally 20110221092741) +class CreateForemTopics < ActiveRecord::Migration + def up + create_table :forem_topics do |t| + t.integer :forum_id + t.integer :user_id + t.string :subject + t.timestamps + + t.boolean :locked, :null => false, :default => false # ? + t.boolean :pinned, :default => false, :nullable => false # ? + t.boolean :hidden, :default => false # ? + t.datetime :last_post_at + t.string :state, :default => "pending_review" + 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 + end + + def down + drop_table :forem_topics + end +end \ No newline at end of file diff --git a/db/migrate/20150514185635_create_forem_posts.rb b/db/migrate/20150514185635_create_forem_posts.rb new file mode 100644 index 000000000..9eb75e94e --- /dev/null +++ b/db/migrate/20150514185635_create_forem_posts.rb @@ -0,0 +1,23 @@ +# This migration comes from forem (originally 20110221094502) +class CreateForemPosts < ActiveRecord::Migration + def up + create_table :forem_posts do |t| + t.integer :topic_id + t.text :text + t.integer :user_id + t.integer :reply_to_id + t.timestamps + + 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 + end + + def down + drop_table :forem_posts + end +end diff --git a/db/migrate/20150514185636_create_forem_views.rb b/db/migrate/20150514185636_create_forem_views.rb new file mode 100644 index 000000000..b2925b9a9 --- /dev/null +++ b/db/migrate/20150514185636_create_forem_views.rb @@ -0,0 +1,19 @@ +# This migration comes from forem (originally 20110520150056) +class CreateForemViews < ActiveRecord::Migration + def change + create_table :forem_views do |t| + t.integer :user_id + t.integer :viewable_id + t.string :viewable_type + t.datetime :created_at + + t.datetime :updated_at + t.integer :count, :default => 0 # ? + t.datetime :current_viewed_at + t.datetime :past_viewed_at + t.index :user_id + t.index :viewable_id + t.index :updated_at + end + end +end \ No newline at end of file diff --git a/db/migrate/20150514185637_create_forem_categories.rb b/db/migrate/20150514185637_create_forem_categories.rb new file mode 100644 index 000000000..b84a5797a --- /dev/null +++ b/db/migrate/20150514185637_create_forem_categories.rb @@ -0,0 +1,13 @@ +# This migration comes from forem (originally 20111103210835) +class CreateForemCategories < ActiveRecord::Migration + def change + create_table :forem_categories do |t| + t.string :name, :null => false + t.timestamps + + t.string :slug + t.integer :position, :default => 0 + t.index :slug, :unique => true + end + end +end diff --git a/db/migrate/20111208014437_create_forem_subscriptions.rb b/db/migrate/20150514185638_create_forem_subscriptions.rb similarity index 75% rename from db/migrate/20111208014437_create_forem_subscriptions.rb rename to db/migrate/20150514185638_create_forem_subscriptions.rb index 552caf751..91c25c84d 100644 --- a/db/migrate/20111208014437_create_forem_subscriptions.rb +++ b/db/migrate/20150514185638_create_forem_subscriptions.rb @@ -1,3 +1,4 @@ +# This migration comes from forem (originally 20111208014437) class CreateForemSubscriptions < ActiveRecord::Migration def change create_table :forem_subscriptions do |t| diff --git a/db/migrate/20120222155549_create_forem_groups.rb b/db/migrate/20150514185639_create_forem_groups.rb similarity index 61% rename from db/migrate/20120222155549_create_forem_groups.rb rename to db/migrate/20150514185639_create_forem_groups.rb index b7b259917..c48e2d7fe 100644 --- a/db/migrate/20120222155549_create_forem_groups.rb +++ b/db/migrate/20150514185639_create_forem_groups.rb @@ -1,9 +1,10 @@ +# This migration comes from forem (originally 20120222155549) class CreateForemGroups < ActiveRecord::Migration def change create_table :forem_groups do |t| t.string :name + + t.index :name end - - add_index :forem_groups, :name end end diff --git a/db/migrate/20150514185640_create_forem_memberships.rb b/db/migrate/20150514185640_create_forem_memberships.rb new file mode 100644 index 000000000..f880cad9d --- /dev/null +++ b/db/migrate/20150514185640_create_forem_memberships.rb @@ -0,0 +1,11 @@ +# This migration comes from forem (originally 20120222204450) +class CreateForemMemberships < ActiveRecord::Migration + def change + create_table :forem_memberships do |t| + t.integer :group_id + t.integer :member_id + + t.index :group_id + end + end +end diff --git a/db/migrate/20150514185641_create_forem_moderator_groups.rb b/db/migrate/20150514185641_create_forem_moderator_groups.rb new file mode 100644 index 000000000..abf631941 --- /dev/null +++ b/db/migrate/20150514185641_create_forem_moderator_groups.rb @@ -0,0 +1,11 @@ +# This migration comes from forem (originally 20120223162058) +class CreateForemModeratorGroups < ActiveRecord::Migration + def change + create_table :forem_moderator_groups do |t| + t.integer :forum_id + t.integer :group_id + + t.index :forum_id + end + end +end diff --git a/db/migrate/20150514185642_add_forem_admin.rb b/db/migrate/20150514185642_add_forem_admin.rb new file mode 100644 index 000000000..f88c25cd9 --- /dev/null +++ b/db/migrate/20150514185642_add_forem_admin.rb @@ -0,0 +1,22 @@ +# This migration comes from forem (originally 20120616193446) +class AddForemAdmin < ActiveRecord::Migration + def change + unless column_exists?(user_class, :forem_admin) + add_column user_class, :forem_admin, :boolean, :default => false + end + + unless column_exists?(user_class, :forem_state) + add_column user_class, :forem_state, :string, :default => 'pending_review' + end + + unless column_exists?(user_class, :forem_auto_subscribe) + add_column user_class, :forem_auto_subscribe, :boolean, :default => false + end + end + + def user_class + Forem.user_class.table_name.downcase.to_sym + Forem.user_class.table_name.downcase.to_sym + Forem.user_class.table_name.downcase.to_sym + end +end \ No newline at end of file diff --git a/db/migrate/20150514185643_update_forem_tables.rb b/db/migrate/20150514185643_update_forem_tables.rb new file mode 100644 index 000000000..922726e3e --- /dev/null +++ b/db/migrate/20150514185643_update_forem_tables.rb @@ -0,0 +1,47 @@ +class UpdateForemTables < ActiveRecord::Migration + def up + # forem_forums + Forem::Forum.find_each do |forum| + forum.update_column(:views_count, forum.topics.sum(:views_count)) + end + + # forem_topics + 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_posts + Forem::Post.reset_column_information + Forem::Post.update_all :state => "approved" + end + + def down + + end + + def change + # forem_forums + if Forem::Forum.count > 0 + Forem::Forum.update_all :category_id => Forem::Category.first.id + end + Forem::Forum.reset_column_information + Forem::Forum.find_each {|t| t.save! } + + # forem_topics + Forem::Topic.reset_column_information + Forem::Topic.find_each {|t| t.save! } + + # forem_views + Forem::View.update_all("viewable_type='Forem::Topic'") + + # forem_categories + Forem::Category.reset_column_information + Forem::Category.find_each {|t| t.save! } + end +end \ No newline at end of file From 68f5a2adf83c71868fd4b39705edfef2f63114a4 Mon Sep 17 00:00:00 2001 From: TekuConcept Date: Thu, 14 May 2015 16:22:59 -0600 Subject: [PATCH 3/4] removed unnecessary lines --- db/migrate/20150514185633_create_forem_forums.rb | 1 - db/migrate/20150514185634_create_forem_topics.rb | 1 - db/migrate/20150514185635_create_forem_posts.rb | 1 - db/migrate/20150514185636_create_forem_views.rb | 1 - db/migrate/20150514185637_create_forem_categories.rb | 1 - db/migrate/20150514185638_create_forem_subscriptions.rb | 1 - db/migrate/20150514185639_create_forem_groups.rb | 1 - db/migrate/20150514185640_create_forem_memberships.rb | 1 - db/migrate/20150514185641_create_forem_moderator_groups.rb | 1 - db/migrate/20150514185642_add_forem_admin.rb | 3 --- 10 files changed, 12 deletions(-) diff --git a/db/migrate/20150514185633_create_forem_forums.rb b/db/migrate/20150514185633_create_forem_forums.rb index 078532b0f..d275076de 100644 --- a/db/migrate/20150514185633_create_forem_forums.rb +++ b/db/migrate/20150514185633_create_forem_forums.rb @@ -1,4 +1,3 @@ -# This migration comes from forem (originally 20110214221555) class CreateForemForums < ActiveRecord::Migration def up create_table :forem_forums do |t| diff --git a/db/migrate/20150514185634_create_forem_topics.rb b/db/migrate/20150514185634_create_forem_topics.rb index a6c2ee605..32b916cdd 100644 --- a/db/migrate/20150514185634_create_forem_topics.rb +++ b/db/migrate/20150514185634_create_forem_topics.rb @@ -1,4 +1,3 @@ -# This migration comes from forem (originally 20110221092741) class CreateForemTopics < ActiveRecord::Migration def up create_table :forem_topics do |t| diff --git a/db/migrate/20150514185635_create_forem_posts.rb b/db/migrate/20150514185635_create_forem_posts.rb index 9eb75e94e..4f5679363 100644 --- a/db/migrate/20150514185635_create_forem_posts.rb +++ b/db/migrate/20150514185635_create_forem_posts.rb @@ -1,4 +1,3 @@ -# This migration comes from forem (originally 20110221094502) class CreateForemPosts < ActiveRecord::Migration def up create_table :forem_posts do |t| diff --git a/db/migrate/20150514185636_create_forem_views.rb b/db/migrate/20150514185636_create_forem_views.rb index b2925b9a9..6570c8733 100644 --- a/db/migrate/20150514185636_create_forem_views.rb +++ b/db/migrate/20150514185636_create_forem_views.rb @@ -1,4 +1,3 @@ -# This migration comes from forem (originally 20110520150056) class CreateForemViews < ActiveRecord::Migration def change create_table :forem_views do |t| diff --git a/db/migrate/20150514185637_create_forem_categories.rb b/db/migrate/20150514185637_create_forem_categories.rb index b84a5797a..e71b0b768 100644 --- a/db/migrate/20150514185637_create_forem_categories.rb +++ b/db/migrate/20150514185637_create_forem_categories.rb @@ -1,4 +1,3 @@ -# This migration comes from forem (originally 20111103210835) class CreateForemCategories < ActiveRecord::Migration def change create_table :forem_categories do |t| diff --git a/db/migrate/20150514185638_create_forem_subscriptions.rb b/db/migrate/20150514185638_create_forem_subscriptions.rb index 91c25c84d..552caf751 100644 --- a/db/migrate/20150514185638_create_forem_subscriptions.rb +++ b/db/migrate/20150514185638_create_forem_subscriptions.rb @@ -1,4 +1,3 @@ -# This migration comes from forem (originally 20111208014437) class CreateForemSubscriptions < ActiveRecord::Migration def change create_table :forem_subscriptions do |t| diff --git a/db/migrate/20150514185639_create_forem_groups.rb b/db/migrate/20150514185639_create_forem_groups.rb index c48e2d7fe..b6a236d4d 100644 --- a/db/migrate/20150514185639_create_forem_groups.rb +++ b/db/migrate/20150514185639_create_forem_groups.rb @@ -1,4 +1,3 @@ -# This migration comes from forem (originally 20120222155549) class CreateForemGroups < ActiveRecord::Migration def change create_table :forem_groups do |t| diff --git a/db/migrate/20150514185640_create_forem_memberships.rb b/db/migrate/20150514185640_create_forem_memberships.rb index f880cad9d..ce4010e83 100644 --- a/db/migrate/20150514185640_create_forem_memberships.rb +++ b/db/migrate/20150514185640_create_forem_memberships.rb @@ -1,4 +1,3 @@ -# This migration comes from forem (originally 20120222204450) class CreateForemMemberships < ActiveRecord::Migration def change create_table :forem_memberships do |t| diff --git a/db/migrate/20150514185641_create_forem_moderator_groups.rb b/db/migrate/20150514185641_create_forem_moderator_groups.rb index abf631941..11de0ca92 100644 --- a/db/migrate/20150514185641_create_forem_moderator_groups.rb +++ b/db/migrate/20150514185641_create_forem_moderator_groups.rb @@ -1,4 +1,3 @@ -# This migration comes from forem (originally 20120223162058) class CreateForemModeratorGroups < ActiveRecord::Migration def change create_table :forem_moderator_groups do |t| diff --git a/db/migrate/20150514185642_add_forem_admin.rb b/db/migrate/20150514185642_add_forem_admin.rb index f88c25cd9..22d26a6f5 100644 --- a/db/migrate/20150514185642_add_forem_admin.rb +++ b/db/migrate/20150514185642_add_forem_admin.rb @@ -1,4 +1,3 @@ -# This migration comes from forem (originally 20120616193446) class AddForemAdmin < ActiveRecord::Migration def change unless column_exists?(user_class, :forem_admin) @@ -16,7 +15,5 @@ def change def user_class Forem.user_class.table_name.downcase.to_sym - Forem.user_class.table_name.downcase.to_sym - Forem.user_class.table_name.downcase.to_sym end end \ No newline at end of file From f4c9316b96b244dd0c64fa6b1ab6d43e5f8fabb4 Mon Sep 17 00:00:00 2001 From: TekuConcept Date: Fri, 15 May 2015 14:02:28 -0600 Subject: [PATCH 4/4] fixed rspec error for user_class migration --- .../20150514185633_create_forem_forums.rb | 15 ++++-- .../20150514185634_create_forem_topics.rb | 45 +++++++++++------- .../20150514185635_create_forem_posts.rb | 31 ++++++------ .../20150514185636_create_forem_views.rb | 19 ++++---- .../20150514185637_create_forem_categories.rb | 14 ++++-- .../20150514185639_create_forem_groups.rb | 2 +- ...20150514185640_create_forem_memberships.rb | 8 ++-- ...514185641_create_forem_moderator_groups.rb | 6 +-- db/migrate/20150514185642_add_forem_admin.rb | 2 +- .../20150514185643_update_forem_tables.rb | 47 ------------------- spec/migrations/add_forem_admin_spec.rb | 10 +++- .../add_forem_auto_subscribe_spec.rb | 17 ------- spec/migrations/add_forem_state_spec.rb | 17 ------- 13 files changed, 89 insertions(+), 144 deletions(-) delete mode 100644 db/migrate/20150514185643_update_forem_tables.rb delete mode 100644 spec/migrations/add_forem_auto_subscribe_spec.rb delete mode 100644 spec/migrations/add_forem_state_spec.rb diff --git a/db/migrate/20150514185633_create_forem_forums.rb b/db/migrate/20150514185633_create_forem_forums.rb index d275076de..11628976a 100644 --- a/db/migrate/20150514185633_create_forem_forums.rb +++ b/db/migrate/20150514185633_create_forem_forums.rb @@ -1,5 +1,5 @@ class CreateForemForums < ActiveRecord::Migration - def up + def change create_table :forem_forums do |t| t.string :name t.text :description @@ -11,9 +11,14 @@ def up t.index :slug, :unique => true end - end - def down - drop_table :forem_forums + 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 \ No newline at end of file +end diff --git a/db/migrate/20150514185634_create_forem_topics.rb b/db/migrate/20150514185634_create_forem_topics.rb index 32b916cdd..9cb990978 100644 --- a/db/migrate/20150514185634_create_forem_topics.rb +++ b/db/migrate/20150514185634_create_forem_topics.rb @@ -1,26 +1,35 @@ class CreateForemTopics < ActiveRecord::Migration - def up + def change create_table :forem_topics do |t| - t.integer :forum_id - t.integer :user_id - t.string :subject - t.timestamps + 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.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.string :state, :default => "pending_review" - 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 + 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 - end - def down - drop_table :forem_topics + 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 \ No newline at end of file diff --git a/db/migrate/20150514185635_create_forem_posts.rb b/db/migrate/20150514185635_create_forem_posts.rb index 4f5679363..afe24ad91 100644 --- a/db/migrate/20150514185635_create_forem_posts.rb +++ b/db/migrate/20150514185635_create_forem_posts.rb @@ -1,22 +1,21 @@ class CreateForemPosts < ActiveRecord::Migration - def up + def change create_table :forem_posts do |t| - t.integer :topic_id - t.text :text - t.integer :user_id - t.integer :reply_to_id - t.timestamps + t.integer :topic_id + t.text :text + t.integer :user_id + t.timestamps :null => false - 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 + 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 - end - def down - drop_table :forem_posts + Forem::Post.update_all :state => "approved" end -end +end \ No newline at end of file diff --git a/db/migrate/20150514185636_create_forem_views.rb b/db/migrate/20150514185636_create_forem_views.rb index 6570c8733..cd3c2ce66 100644 --- a/db/migrate/20150514185636_create_forem_views.rb +++ b/db/migrate/20150514185636_create_forem_views.rb @@ -1,18 +1,21 @@ class CreateForemViews < ActiveRecord::Migration def change create_table :forem_views do |t| - t.integer :user_id - t.integer :viewable_id - t.string :viewable_type + t.integer :user_id t.datetime :created_at + t.integer :viewable_id + t.string :viewable_type t.datetime :updated_at - t.integer :count, :default => 0 # ? + t.integer :count, :default => 0 t.datetime :current_viewed_at t.datetime :past_viewed_at - t.index :user_id - t.index :viewable_id - t.index :updated_at + + t.index :user_id + t.index :viewable_id + t.index :updated_at end + + Forem::View.update_all("viewable_type='Forem::Topic'") end -end \ No newline at end of file +end diff --git a/db/migrate/20150514185637_create_forem_categories.rb b/db/migrate/20150514185637_create_forem_categories.rb index e71b0b768..a3ef1beae 100644 --- a/db/migrate/20150514185637_create_forem_categories.rb +++ b/db/migrate/20150514185637_create_forem_categories.rb @@ -1,12 +1,16 @@ class CreateForemCategories < ActiveRecord::Migration def change create_table :forem_categories do |t| - t.string :name, :null => false - t.timestamps + t.string :name, :null => false + t.timestamps :null => false - t.string :slug - t.integer :position, :default => 0 - t.index :slug, :unique => true + t.string :slug + t.integer :position, :default => 0 + + t.index :slug, :unique => true end + + Forem::Category.reset_column_information + Forem::Category.find_each {|t| t.save! } end end diff --git a/db/migrate/20150514185639_create_forem_groups.rb b/db/migrate/20150514185639_create_forem_groups.rb index b6a236d4d..83176018e 100644 --- a/db/migrate/20150514185639_create_forem_groups.rb +++ b/db/migrate/20150514185639_create_forem_groups.rb @@ -2,7 +2,7 @@ class CreateForemGroups < ActiveRecord::Migration def change create_table :forem_groups do |t| t.string :name - + t.index :name end end diff --git a/db/migrate/20150514185640_create_forem_memberships.rb b/db/migrate/20150514185640_create_forem_memberships.rb index ce4010e83..27e4027f9 100644 --- a/db/migrate/20150514185640_create_forem_memberships.rb +++ b/db/migrate/20150514185640_create_forem_memberships.rb @@ -1,10 +1,10 @@ class CreateForemMemberships < ActiveRecord::Migration def change create_table :forem_memberships do |t| - t.integer :group_id - t.integer :member_id - - t.index :group_id + t.integer :group_id + t.integer :member_id + + t.index :group_id end end end diff --git a/db/migrate/20150514185641_create_forem_moderator_groups.rb b/db/migrate/20150514185641_create_forem_moderator_groups.rb index 11de0ca92..fab99ef8a 100644 --- a/db/migrate/20150514185641_create_forem_moderator_groups.rb +++ b/db/migrate/20150514185641_create_forem_moderator_groups.rb @@ -1,10 +1,10 @@ class CreateForemModeratorGroups < ActiveRecord::Migration def change create_table :forem_moderator_groups do |t| - t.integer :forum_id - t.integer :group_id + t.integer :forum_id + t.integer :group_id - t.index :forum_id + t.index :forum_id end end end diff --git a/db/migrate/20150514185642_add_forem_admin.rb b/db/migrate/20150514185642_add_forem_admin.rb index 22d26a6f5..b9ad23b79 100644 --- a/db/migrate/20150514185642_add_forem_admin.rb +++ b/db/migrate/20150514185642_add_forem_admin.rb @@ -16,4 +16,4 @@ def change def user_class Forem.user_class.table_name.downcase.to_sym end -end \ No newline at end of file +end diff --git a/db/migrate/20150514185643_update_forem_tables.rb b/db/migrate/20150514185643_update_forem_tables.rb deleted file mode 100644 index 922726e3e..000000000 --- a/db/migrate/20150514185643_update_forem_tables.rb +++ /dev/null @@ -1,47 +0,0 @@ -class UpdateForemTables < ActiveRecord::Migration - def up - # forem_forums - Forem::Forum.find_each do |forum| - forum.update_column(:views_count, forum.topics.sum(:views_count)) - end - - # forem_topics - 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_posts - Forem::Post.reset_column_information - Forem::Post.update_all :state => "approved" - end - - def down - - end - - def change - # forem_forums - if Forem::Forum.count > 0 - Forem::Forum.update_all :category_id => Forem::Category.first.id - end - Forem::Forum.reset_column_information - Forem::Forum.find_each {|t| t.save! } - - # forem_topics - Forem::Topic.reset_column_information - Forem::Topic.find_each {|t| t.save! } - - # forem_views - Forem::View.update_all("viewable_type='Forem::Topic'") - - # forem_categories - Forem::Category.reset_column_information - Forem::Category.find_each {|t| t.save! } - end -end \ No newline at end of file diff --git a/spec/migrations/add_forem_admin_spec.rb b/spec/migrations/add_forem_admin_spec.rb index c46c3a0e0..58934a9ce 100644 --- a/spec/migrations/add_forem_admin_spec.rb +++ b/spec/migrations/add_forem_admin_spec.rb @@ -9,9 +9,15 @@ describe AddForemAdmin do include_context "user migrations" - it "adds forem_admin to user_class" do - subject.should_receive('column_exists?').and_return(false) + it "adds forem_admin, forem_state, and forem_auto_subscribe to user_class" do + subject.stub("add_column").with(anything()) + subject.stub("column_exists?").with(anything()) + subject.should_receive('column_exists?').with(:users, :forem_admin).and_return(false) subject.should_receive('add_column').with(:users, :forem_admin, :boolean, {:default=>false}) + subject.should_receive('column_exists?').with(:users, :forem_state).and_return(false) + subject.should_receive('add_column').with(:users, :forem_state, :string, {:default=>"pending_review"}) + subject.should_receive('column_exists?').with(:users, :forem_auto_subscribe).and_return(false) + subject.should_receive('add_column').with(:users, :forem_auto_subscribe, :boolean, {:default=>false}) subject.change end end \ No newline at end of file diff --git a/spec/migrations/add_forem_auto_subscribe_spec.rb b/spec/migrations/add_forem_auto_subscribe_spec.rb deleted file mode 100644 index bb7109734..000000000 --- a/spec/migrations/add_forem_auto_subscribe_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'spec_helper.rb' - -Dir.chdir(Rails.root) do - `rake railties:install:migrations` -end - -require Dir.glob("#{Rails.root}/db/migrate/*add_forem_auto_subscribe.forem.rb").first - -describe AddForemAutoSubscribe do - include_context "user migrations" - - it "adds forem_auto_subscribe to user_class" do - subject.should_receive('column_exists?').and_return(false) - subject.should_receive('add_column').with(:users, :forem_auto_subscribe, :boolean, {:default=>false}) - subject.change - end -end \ No newline at end of file diff --git a/spec/migrations/add_forem_state_spec.rb b/spec/migrations/add_forem_state_spec.rb deleted file mode 100644 index ff832ed5e..000000000 --- a/spec/migrations/add_forem_state_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'spec_helper.rb' - -Dir.chdir(Rails.root) do - `rake railties:install:migrations` -end - -require Dir.glob("#{Rails.root}/db/migrate/*add_forem_state.forem.rb").first - -describe AddForemState do - include_context "user migrations" - - it "adds forem_state to user_class" do - subject.should_receive('column_exists?').and_return(false) - subject.should_receive('add_column').with(:users, :forem_state, :string, {:default=>"pending_review"}) - subject.change - end -end \ No newline at end of file