Sha256: 26a7df9d815c71a6e8d7999ced48cb118b76888753fd8c74c4882db914ec31f5

Contents?: true

Size: 1.84 KB

Versions: 40

Compression:

Stored size: 1.84 KB

Contents

# frozen_string_literal: true

require 'thredded/base_migration'

class UpgradeV07ToV08 < Thredded::BaseMigration
  def up
    closed_messageboards = Thredded::Messageboard.unscoped.where(closed: true).to_a
    if closed_messageboards.present?
      fail ActiveRecord::MigrationError, <<-TEXT
There are #{closed_messageboards.length} closed Messageboards:
#{closed_messageboards.map { |m| "#{m.name} (id=#{m.id})" }.join("\n")}
Support for closed messageboards has been removed in thredded v0.8.0.
Delete or un-close these messageboards and consider using the "paranoia" gem to support soft deletion instead.
      TEXT
    end
    remove_index :thredded_messageboards, name: :index_thredded_messageboards_on_closed
    remove_column :thredded_messageboards, :closed
    add_column :thredded_user_preferences, :followed_topic_emails, :boolean, default: true, null: false
    add_column :thredded_user_messageboard_preferences, :followed_topic_emails, :boolean, default: true, null: false
    rename_column :thredded_user_preferences, :notify_on_mention, :follow_topics_on_mention
    rename_column :thredded_user_messageboard_preferences, :notify_on_mention, :follow_topics_on_mention
    change_column :thredded_messageboards, :name, :string, limit: 191
  end

  def down
    change_column :thredded_messageboards, :name, :string, limit: 255
    rename_column :thredded_user_messageboard_preferences, :follow_topics_on_mention, :notify_on_mention
    rename_column :thredded_user_preferences, :follow_topics_on_mention, :notify_on_mention
    remove_column :thredded_user_messageboard_preferences, :followed_topic_emails
    remove_column :thredded_user_preferences, :followed_topic_emails
    add_column :thredded_messageboards, :closed, :boolean, default: false, null: false
    add_index :thredded_messageboards, :closed, name: :index_thredded_messageboards_on_closed
  end
end

Version data entries

40 entries across 40 versions & 2 rubygems

Version Path
thredded-1.0.0 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.16.16 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.16.15 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.16.14 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.16.13 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.16.12 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.16.11 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.16.10 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.16.9 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.16.8 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.16.7 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.16.6 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.16.5 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.16.4 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.16.3 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.16.1 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.16.0 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.15.5 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.15.4 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
thredded-0.15.3 db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb