Sha256: b73d4b77b53ee0a3703f16e70fe6664f0ab6cc8c1a243db5a280436bf2d74c9c

Contents?: true

Size: 555 Bytes

Versions: 2

Compression:

Stored size: 555 Bytes

Contents

# frozen_string_literal: true

class AddVersionToActionLogs < ActiveRecord::Migration[5.1]
  def up
    add_column :decidim_action_logs, :version_id, :integer, index: true

    Decidim::ActionLog.find_each do |action_log|
      version_id = action_log.extra.dig("version", "id")
      next unless version_id
      # rubocop:disable Rails/SkipsModelValidations
      action_log.update_column(:version_id, version_id)
      # rubocop:enable Rails/SkipsModelValidations
    end
  end

  def down
    remove_column :decidim_action_logs, :version_id
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
decidim-core-0.10.1 db/migrate/20180226140756_add_version_to_action_logs.rb
decidim-core-0.10.0 db/migrate/20180226140756_add_version_to_action_logs.rb