Sha256: b4080d8147d49dc3906a4e2f76012577484179a9b27ae86542d9deb6bdfb8a3a

Contents?: true

Size: 879 Bytes

Versions: 62

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

62 entries across 62 versions & 1 rubygems

Version Path
decidim-proposals-0.25.1 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.25.0 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.25.0.rc4 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.25.0.rc3 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.25.0.rc2 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.25.0.rc1 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.24.3 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.23.6 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.24.2 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.23.5 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.24.1 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.24.0 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.24.0.rc2 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.23.4 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.24.0.rc1 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.23.3 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.23.2 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.23.1 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.23.1.rc1 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb
decidim-proposals-0.23.0 db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb