You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: namespace.rb
    path of file: ./repos/Portus/app/models
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

# == Schema Information
#
# Table name: namespaces
#
#  id          :integer          not null, primary key
#  name        :string(255)
#  created_at  :datetime         not null
#  updated_at  :datetime         not null
#  team_id     :integer
#  registry_id :integer          not null
#  global      :boolean          default(FALSE)
#  description :text(65535)
#  visibility  :integer
#
# Indexes
#
#  index_namespaces_on_name_and_registry_id  (name,registry_id) UNIQUE
#  index_namespaces_on_registry_id           (registry_id)
#  index_namespaces_on_team_id               (team_id)
#

class Namespace < ApplicationRecord
  include PublicActivity::Common
  include SearchCop
  include ::Activity::Fallback

  search_scope :search do
    attributes :name, :description
  end

  # This regexp is extracted from the reference package of Docker Distribution
  # and it matches a valid namespace name.
  NAME_REGEXP = /\A[a-z0-9]+(?:[._\\-][a-z0-9]+)*\Z/.freeze

  # The maximum length of a namespace name.
  MAX_NAME_LENGTH = 255

  has_many :webhooks, dependent: :destroy
  has_many :repositories, dependent: :destroy
  belongs_to 
    
  def self.make_valid(name)
    # One common case is LDAP and case sensitivity. With this in mind, try to
    # downcase everything and see if now it's fine.
    name = name.downcase

    # Let's strip extra characters from the beginning and end.
    first = name.index(/[a-z0-9]/)
    return nil if first.nil?

    last = name.rindex(/[a-z0-9]/)
    str = name[first..last]

    # Replace weird characters with underscores.
    str = str.gsub(/[^[a-z0-9\\.\\-_]]/, "_")

    # Only one special character is allowed in between of alphanumeric
    # characters. Thus, let's merge multiple appearences into one on each case.
    # After that, the name should be fine, so let's trim it if it's too large.
    final = str.gsub(/[._\\-]{2,}/, "_")
    name = final[0..MAX_NAME_LENGTH]

    return nil if name !~ NAME_REGEXP

    # To avoid any name conflict we append an incremental number to the end
    # of the name returns it as the name that will be used on both Namespace
    # and Team on the User#create_personal_namespace! method
    increment = 0
    original_name = name
    while Namespace.exists?(name: name)
      name = "#{original_name}#{increment}"
      increment += 1
      break if increment > 1000
    end

    name
  end