Sha256: cb4d7802f2a68fa8d7cdbe544501e6f5209151a0dddda9d7b56ddfbdca96f918
Contents?: true
Size: 719 Bytes
Versions: 71
Compression:
Stored size: 719 Bytes
Contents
# frozen_string_literal: true class FixNicknameIndex < ActiveRecord::Migration[5.1] class User < ApplicationRecord self.table_name = :decidim_users include Decidim::Nicknamizable end def change User.where(nickname: nil) .where(deleted_at: nil) .where(managed: false) .find_each { |u| u.update(nickname: UserBaseEntity.nicknamize(u.name, decidim_organization_id: u.decidim_organization_id)) } # rubocop:disable Rails/SkipsModelValidations User.where(nickname: nil).update_all("nickname = ''") # rubocop:enable Rails/SkipsModelValidations change_column_default :decidim_users, :nickname, "" change_column_null(:decidim_users, :nickname, false) end end
Version data entries
71 entries across 71 versions & 1 rubygems