Sha256: e50b3d8541517bc6c71cc5c5499c550a9d9d7d7db6a2821f70295d980525b05f
Contents?: true
Size: 844 Bytes
Versions: 10
Compression:
Stored size: 844 Bytes
Contents
# frozen_string_literal: true class CreateUniqueNicknames < ActiveRecord::Migration[5.1] class User < ApplicationRecord include Decidim::Nicknamizable self.table_name = :decidim_users end def up add_column :decidim_users, :nickname, :string, limit: 20 User.where.not(name: nil).find_each do |user| user.update!(nickname: User.nicknamize(user.name, decidim_organization_id: user.decidim_organization_id)) end add_index :decidim_users, %w(nickname decidim_organization_id), where: "(deleted_at IS NULL) AND (managed = 'f')", name: "index_decidim_users_on_nickame_and_decidim_organization_id", unique: true end def down remove_index :decidim_users, %w(nickname decidim_organization_id) remove_column :decidim_users, :nickname end end
Version data entries
10 entries across 10 versions & 1 rubygems