Sha256: b221acc4fcfe00540ccab1efee85f3b1f6d9daa93b8f515e4926fbb958778073

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

class AddDecidimAwesomeProposalPrivateFields < ActiveRecord::Migration[6.0]
  class ProposalExtraField < ApplicationRecord
    self.table_name = :decidim_awesome_proposal_extra_fields
  end

  def change
    add_column :decidim_awesome_proposal_extra_fields, :private_body, :string
    add_column :decidim_awesome_proposal_extra_fields, :decidim_proposal_type, :string
    reversible do |direction|
      direction.up do
        execute <<~SQL.squish
          UPDATE decidim_awesome_proposal_extra_fields
          SET decidim_proposal_type = 'Decidim::Proposals::Proposal'
        SQL
      end
    end

    remove_index :decidim_awesome_proposal_extra_fields, name: "decidim_awesome_extra_fields_on_proposal"
    add_index :decidim_awesome_proposal_extra_fields,
              [:decidim_proposal_id, :decidim_proposal_type],
              name: "index_decidim_awesome_proposal_extra_fields_on_decidim_proposal"

    change_column_null :decidim_awesome_proposal_extra_fields, :decidim_proposal_id, false
    change_column_null :decidim_awesome_proposal_extra_fields, :decidim_proposal_type, false
    ProposalExtraField.reset_column_information
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-decidim_awesome-0.10.3 db/migrate/20240531224204_add_decidim_awesome_proposal_private_fields.rb
decidim-decidim_awesome-0.11.2 db/migrate/20240531224204_add_decidim_awesome_proposal_private_fields.rb
decidim-decidim_awesome-0.11.1 db/migrate/20240531224204_add_decidim_awesome_proposal_private_fields.rb