Sha256: b0757901f638801a6f35e1e7e71267bfe3b19452b716bfe9a552b8e558bdcd6e

Contents?: true

Size: 635 Bytes

Versions: 64

Compression:

Stored size: 635 Bytes

Contents

# frozen_string_literal: true

class AddVersionToActionLogs < ActiveRecord::Migration[5.1]
  class ActionLog < ApplicationRecord
    self.table_name = :decidim_action_logs
  end

  def up
    add_column :decidim_action_logs, :version_id, :integer, index: true

    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

64 entries across 64 versions & 1 rubygems

Version Path
decidim-core-0.20.1 db/migrate/20180226140756_add_version_to_action_logs.rb
decidim-core-0.20.0 db/migrate/20180226140756_add_version_to_action_logs.rb
decidim-core-0.19.1 db/migrate/20180226140756_add_version_to_action_logs.rb
decidim-core-0.19.0 db/migrate/20180226140756_add_version_to_action_logs.rb