Skip to content

Commit

Permalink
Remove legacy Proposals endorsements table (#5643)
Browse files Browse the repository at this point in the history
* [DOC] Update changelog upgrade notes.

* Remove legacy ProposalEndorsement related structures from database.

* Fix syntax error

* Fix bad automatic merge in changelog

* Clean changelog entries from bad merge

* Fix mistyped table name
  • Loading branch information
tramuntanal committed Jun 30, 2020
1 parent 745a7da commit 87ba1b2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,10 +2,21 @@

## [Unreleased](https://github.com/decidim/decidim/tree/HEAD)

### Upgrade notes

- **Endorsements**

The latest version of Decidim extracted the Endorsement feature into a generic concern that can now be applied to many resources.
To keep current Decidim::Proposals::Proposal's endorsement information, endorsements were copied into the new `Decidim::Endorsable` tables and counter cache columns via migrations.

After this, `Decidim::Proposals::ProposalEndorsement` and the corresponding counter cache column in `decidim_proposals_proposal.proposal_endorsements_count` should be removed. To do so, Decidim provides now the corresponding migration.

### Added

### Changed

- **decidim-proposals**: Remove legacy proposal endorsements. [\#5643](https://github.com/decidim/decidim/pull/5643)

### Fixed

- **decidim-comments**: Fix comments JS errors and delays [\#6193](https://github.com/decidim/decidim/pull/6193)
Expand Down
2 changes: 1 addition & 1 deletion decidim-proposals/app/models/decidim/proposals/proposal.rb
Expand Up @@ -146,7 +146,7 @@ def self.newsletter_participant_ids(component)

endorsements_participants_ids = Decidim::Endorsement.where(resource: proposals)
.where(decidim_author_type: "Decidim::UserBaseEntity")
.map(&:decidim_author_id).flatten.compact.uniq
.pluck(:decidim_author_id).to_a.compact.uniq

(endorsements_participants_ids + participants_has_voted_ids + coauthors_recipients_ids).flatten.compact.uniq
end
Expand Down
Expand Up @@ -5,9 +5,11 @@ class MoveProposalEndorsementsToCoreEndorsements < ActiveRecord::Migration[5.2]
class ProposalEndorsement < ApplicationRecord
self.table_name = :decidim_proposals_proposal_endorsements
end

class Endorsement < ApplicationRecord
self.table_name = :decidim_endorsements
end

# Move ProposalEndorsements to Endorsements
def up
non_duplicated_group_endorsements = ProposalEndorsement.select(
Expand Down
@@ -0,0 +1,8 @@
# frozen_string_literal: true

class DropProposalEndorsements < ActiveRecord::Migration[5.2]
def change
drop_table :decidim_proposals_proposal_endorsements, if_exists: true, force: :restrict
remove_column :decidim_proposals_proposals, :proposal_endorsements_count
end
end

0 comments on commit 87ba1b2

Please sign in to comment.