Sha256: 38ea69c8f48f7e723d6c93c6609445c9b25725f978c1a5681875caf4ece5ca8c

Contents?: true

Size: 950 Bytes

Versions: 122

Compression:

Stored size: 950 Bytes

Contents

# frozen_string_literal: true

class MakeModerationsPolymorphic < ActiveRecord::Migration[5.1]
  def change
    remove_index :decidim_moderations,
                 name: "decidim_moderations_participatory_process"

    add_column :decidim_moderations, :decidim_participatory_space_type, :string

    reversible do |direction|
      direction.up do
        execute <<~SQL.squish
          UPDATE decidim_moderations
          SET decidim_participatory_space_type = 'Decidim::ParticipatoryProcess'
        SQL
      end
    end

    rename_column :decidim_moderations,
                  :decidim_participatory_process_id,
                  :decidim_participatory_space_id

    add_index :decidim_moderations,
              [:decidim_participatory_space_id, :decidim_participatory_space_type],
              name: "decidim_moderations_participatory_space"

    change_column_null :decidim_moderations, :decidim_participatory_space_type, false
  end
end

Version data entries

122 entries across 122 versions & 2 rubygems

Version Path
decidim-core-0.6.0 db/migrate/20170720120231_make_moderations_polymorphic.rb
decidim-0.6.0 decidim-core/db/migrate/20170720120231_make_moderations_polymorphic.rb