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