Sha256: 9b467c55f3328bd7576843b2850087bbc3ade7bdfb66a3af20f0b387b8ed735d

Contents?: true

Size: 921 Bytes

Versions: 25

Compression:

Stored size: 921 Bytes

Contents

# frozen_string_literal: true

class MakeAuthorPolymorphicForCommentVotes < ActiveRecord::Migration[5.2]
  class CommentVote < ApplicationRecord
    self.table_name = :decidim_comments_comment_votes
  end

  def change
    add_column :decidim_comments_comment_votes, :decidim_author_type, :string

    reversible do |direction|
      direction.up do
        execute <<~SQL.squish
          UPDATE decidim_comments_comment_votes
          SET decidim_author_type = 'Decidim::UserBaseEntity'
        SQL
      end
    end

    add_index :decidim_comments_comment_votes,
              [:decidim_author_id, :decidim_author_type],
              name: "index_decidim_comments_comment_votes_on_decidim_author"

    change_column_null :decidim_comments_comment_votes, :decidim_author_id, false
    change_column_null :decidim_comments_comment_votes, :decidim_author_type, false
    CommentVote.reset_column_information
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-comments-0.29.1 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.28.4 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.27.9 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.29.0 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.28.3 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.27.8 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.29.0.rc4 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.29.0.rc3 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.29.0.rc2 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.29.0.rc1 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.28.2 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.27.7 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.28.1 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.27.6 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.28.0 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.27.5 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.28.0.rc5 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.28.0.rc4 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.27.4 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
decidim-comments-0.27.3 db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb