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

Version Path
decidim-core-0.29.1 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.28.4 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.27.9 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.29.0 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.28.3 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.27.8 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.29.0.rc4 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.29.0.rc3 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.29.0.rc2 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.29.0.rc1 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.28.2 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.27.7 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.28.1 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.27.6 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.26.10 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.26.9 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.28.0 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.27.5 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.28.0.rc5 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.28.0.rc4 db/migrate/20180221101934_fix_nickname_index.rb