Sha256: 5846c436fae52ed99fa17168eaf64de942a6b183757c420c5ba821f0a7939658

Contents?: true

Size: 1.06 KB

Versions: 74

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

class MakeAuthorPolymorhpicForProposalEndorsements < ActiveRecord::Migration[5.2]
  class ProposalEndorsement < ApplicationRecord
    self.table_name = :decidim_proposals_proposal_endorsements
  end

  def change
    remove_index :decidim_proposals_proposal_endorsements, :decidim_author_id

    add_column :decidim_proposals_proposal_endorsements, :decidim_author_type, :string

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

    add_index :decidim_proposals_proposal_endorsements,
              [:decidim_author_id, :decidim_author_type],
              name: "index_decidim_proposals_proposal_endorsements_on_decidim_author"

    change_column_null :decidim_proposals_proposal_endorsements, :decidim_author_id, false
    change_column_null :decidim_proposals_proposal_endorsements, :decidim_author_type, false

    ProposalEndorsement.reset_column_information
  end
end

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
decidim-proposals-0.29.1 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.28.4 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.27.9 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.29.0 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.28.3 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.27.8 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.29.0.rc4 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.29.0.rc3 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.29.0.rc2 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.29.0.rc1 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.28.2 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.27.7 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.28.1 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.27.6 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.26.10 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.26.9 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.28.0 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.27.5 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.28.0.rc5 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb
decidim-proposals-0.28.0.rc4 db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb