Sha256: b4080d8147d49dc3906a4e2f76012577484179a9b27ae86542d9deb6bdfb8a3a

Contents?: true

Size: 879 Bytes

Versions: 60

Compression:

Stored size: 879 Bytes

Contents

# frozen_string_literal: true

class SyncProposalsStateWithAmendmentsState < ActiveRecord::Migration[5.2]
  def up
    execute <<-SQL.squish
      UPDATE decidim_proposals_proposals AS proposals
      SET state = amendments.state
      FROM decidim_amendments AS amendments
      WHERE
        proposals.state IS NULL AND
        amendments.decidim_emendation_type = 'Decidim::Proposals::Proposal' AND
        amendments.decidim_emendation_id = proposals.id AND
        amendments.state IS NOT NULL
    SQL
  end

  def down
    execute <<-SQL.squish
      UPDATE decidim_proposals_proposals AS proposals
      SET state = NULL
      FROM decidim_amendments AS amendments
      WHERE
        amendments.decidim_emendation_type = 'Decidim::Proposals::Proposal' AND
        amendments.decidim_emendation_id = proposals.id AND
        amendments.state IS NOT NULL
    SQL
  end
end

Version data entries

60 entries across 60 versions & 1 rubygems

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