Sha256: 92910d870277bed7e777bd31615f713343d7b23c52bdd24c629e2df0ef6ae6fb

Contents?: true

Size: 701 Bytes

Versions: 6

Compression:

Stored size: 701 Bytes

Contents

# frozen_string_literal: true

class AddWithdrawnFieldsOnMeetings < ActiveRecord::Migration[6.1]
  class CustomMeeting < Decidim::Meetings::ApplicationRecord
    self.table_name = "decidim_meetings_meetings"
  end

  def up
    add_column :decidim_meetings_meetings, :withdrawn_at, :datetime

    CustomMeeting.where(state: "withdrawn").find_each do |meeting|
      meeting.withdrawn_at = meeting.updated_at
      meeting.save!
    end
  end

  def down
    # rubocop:disable Rails/SkipsModelValidations
    CustomMeeting.where.not(withdrawn_at: null).update_all(state: :withdrawn)
    # rubocop:enable Rails/SkipsModelValidations
    remove_column :decidim_meetings_meetings, :withdrawn_at
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-meetings-0.29.1 db/migrate/20240130135858_add_withdrawn_fields_on_meetings.rb
decidim-meetings-0.29.0 db/migrate/20240130135858_add_withdrawn_fields_on_meetings.rb
decidim-meetings-0.29.0.rc4 db/migrate/20240130135858_add_withdrawn_fields_on_meetings.rb
decidim-meetings-0.29.0.rc3 db/migrate/20240130135858_add_withdrawn_fields_on_meetings.rb
decidim-meetings-0.29.0.rc2 db/migrate/20240130135858_add_withdrawn_fields_on_meetings.rb
decidim-meetings-0.29.0.rc1 db/migrate/20240130135858_add_withdrawn_fields_on_meetings.rb