Sha256: 7f1ddf182f13c6b71b3822669d1f074ac2d340d07d6e07b764992386dc7bd317
Contents?: true
Size: 1.14 KB
Versions: 13
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true class UpgradeV05ToV06 < ActiveRecord::Migration def up add_column :thredded_messageboards, :last_topic_id, :integer Thredded::Messageboard.reset_column_information Thredded::Messageboard.all.each do |messageboard| messageboard.update!(last_topic_id: messageboard.topics.order(updated_at: :desc, id: :desc).first.try(:id)) end change_column_null :thredded_posts, :postable_id, false # Allow null on user_id and last_user_id because users can get deleted. change_column_null :thredded_topics, :user_id, true change_column_null :thredded_topics, :last_user_id, true change_column_null :thredded_private_topics, :user_id, true change_column_null :thredded_private_topics, :last_user_id, true end def down change_column_null :thredded_private_topics, :last_user_id, false change_column_null :thredded_private_topics, :user_id, false change_column_null :thredded_topics, :last_user_id, false change_column_null :thredded_topics, :user_id, false change_column_null :thredded_posts, :postable_id, true remove_column :thredded_messageboards, :last_topic_id end end
Version data entries
13 entries across 13 versions & 1 rubygems