Sha256: a1ada1854ea62461e583ecf0566488677f85b8ed305889014f4ed9f8310e5ab4
Contents?: true
Size: 1023 Bytes
Versions: 19
Compression:
Stored size: 1023 Bytes
Contents
# frozen_string_literal: true class AddOrganizationAsAuthorToDebates < ActiveRecord::Migration[5.2] class Debate < ApplicationRecord self.table_name = :decidim_debates_debates include Decidim::HasComponent end class User < ApplicationRecord self.table_name = :decidim_users end def change add_column :decidim_debates_debates, :decidim_author_type, :string Debate.find_each do |debate| if debate.decidim_author_id.present? debate.decidim_author_type = "Decidim::UserBaseEntity" else debate.decidim_author_id = debate.organization.id debate.decidim_author_type = "Decidim::Organization" end debate.save! end add_index :decidim_debates_debates, [:decidim_author_id, :decidim_author_type], name: "index_decidim_debates_debates_on_decidim_author" change_column_null :decidim_debates_debates, :decidim_author_id, false change_column_null :decidim_debates_debates, :decidim_author_type, false end end
Version data entries
19 entries across 19 versions & 1 rubygems