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.26.8 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.27.4 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.27.3 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.26.7 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.26.5 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.27.2 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.27.1 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.26.4 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.27.0 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.26.3 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.27.0.rc2 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.27.0.rc1 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.26.2 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.26.1 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.26.0 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.26.0.rc2 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.26.0.rc1 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.25.2 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.25.1 db/migrate/20180221101934_fix_nickname_index.rb
decidim-core-0.25.0 db/migrate/20180221101934_fix_nickname_index.rb