Sha256: fc00cf5a91a344d7e7a556a5b1eb46711b938beadced679e2cd6311161cd15a9

Contents?: true

Size: 874 Bytes

Versions: 49

Compression:

Stored size: 874 Bytes

Contents

# frozen_string_literal: true

class MakeAuthorsPolymorphicForComments < ActiveRecord::Migration[5.2]
  class Comment < ApplicationRecord
    self.table_name = :decidim_comments_comments
  end
  def change
    add_column :decidim_comments_comments, :decidim_author_type, :string

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

    add_index :decidim_comments_comments,
              [:decidim_author_id, :decidim_author_type],
              name: "index_decidim_comments_comments_on_decidim_author"

    change_column_null :decidim_comments_comments, :decidim_author_id, false
    change_column_null :decidim_comments_comments, :decidim_author_type, false
    Comment.reset_column_information
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
decidim-comments-0.26.10 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.26.9 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.26.8 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.26.7 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.26.5 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.26.4 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.26.3 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.26.2 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.26.1 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.26.0 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.26.0.rc2 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.26.0.rc1 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.25.2 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.25.1 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.25.0 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.25.0.rc4 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.25.0.rc3 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.25.0.rc2 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.25.0.rc1 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
decidim-comments-0.24.3 db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb