You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: theme_settings_migration.rb
    path of file: ./repos/discourse/app/models
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

class ThemeSettingsMigration < ActiveRecord::Base
  belongs_to :theme
  belongs_to :theme_field

  validates :theme_id, presence: true
  validates :theme_field_id, presence: true

  validates :version, presence: true
  validates :name, presence: true
  validates :diff, presence: true

  def calculate_diff(settings_before, settings_after)
    diff = { additions: [], deletions: [] }

    before_keys = settings_before.keys
    after_keys = settings_after.keys

    removed_keys = before_keys - after_keys
    removed_keys.each { |key| diff
    
  def calculate_diff(settings_before, settings_after)
    diff = { additions: [], deletions: [] }

    before_keys = settings_before.keys
    after_keys = settings_after.keys

    removed_keys = before_keys - after_keys
    removed_keys.each { |key| diff[:deletions] << { key: key, val: settings_before[key] } }

    added_keys = after_keys - before_keys
    added_keys.each { |key| diff[:additions] << { key: key, val: settings_after[key] } }

    common_keys = before_keys & after_keys
    common_keys.each do |key|
      if settings_before[key] != settings_after[key]
        diff[:deletions] << { key: key, val: settings_before[key] }
        diff[:additions] << { key: key, val: settings_after[key] }
      end
    end