Sha256: 8baeffde78b32896c6fb70904e56761e4f791ed3654dbdfa6b4b3f0adc9fa1ed
Contents?: true
Size: 974 Bytes
Versions: 74
Compression:
Stored size: 974 Bytes
Contents
# frozen_string_literal: true class MakeBlogpostsAuthorsPolymorphics < ActiveRecord::Migration[5.2] class Post < ApplicationRecord self.table_name = :decidim_blogs_posts include Decidim::HasComponent end def change add_column :decidim_blogs_posts, :decidim_author_type, :string Post.reset_column_information Post.find_each do |post| if post.decidim_author_id.present? post.decidim_author_type = "Decidim::UserBaseEntity" else post.decidim_author_id = post.organization.id post.decidim_author_type = "Decidim::Organization" end post.save! end add_index :decidim_blogs_posts, [:decidim_author_id, :decidim_author_type], name: "index_decidim_blogs_posts_on_decidim_author" change_column_null :decidim_blogs_posts, :decidim_author_id, false change_column_null :decidim_blogs_posts, :decidim_author_type, false Post.reset_column_information end end
Version data entries
74 entries across 74 versions & 1 rubygems