Sha256: a94cbf844c9f439afde705a2baf8faad879d406019885036f618ba3556493714

Contents?: true

Size: 885 Bytes

Versions: 60

Compression:

Stored size: 885 Bytes

Contents

# frozen_string_literal: true

class AddAcceptedTosVersionFieldToUsers < ActiveRecord::Migration[5.1]
  class Organization < ApplicationRecord
    self.table_name = :decidim_organizations
    has_many :users, foreign_key: "decidim_organization_id", class_name: "Decidim::User", dependent: :destroy
  end
  class User < ApplicationRecord
    self.table_name = :decidim_users
    belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Decidim::Organization"
  end

  def up
    add_column :decidim_users, :accepted_tos_version, :datetime
    Organization.find_each do |organization|
      # rubocop:disable Rails/SkipsModelValidations
      organization.users.update_all(accepted_tos_version: organization.tos_version)
      # rubocop:enable Rails/SkipsModelValidations
    end
  end

  def down
    remove_columns :decidim_users, :accepted_tos_version
  end
end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
decidim-core-0.26.10 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.26.9 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.26.8 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.26.7 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.26.5 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.26.4 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.26.3 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.26.2 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.26.1 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.26.0 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.26.0.rc2 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.26.0.rc1 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.25.2 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.25.1 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.25.0 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.25.0.rc4 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.25.0.rc3 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.25.0.rc2 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.25.0.rc1 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb
decidim-core-0.24.3 db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb