content: package com.activecourses.upwork.model;
  
  import com.fasterxml.jackson.annotation.JsonIgnore;
  import jakarta.persistence.*;
  import jakarta.validation.constraints.Size;
  import lombok.AllArgsConstructor;
  import lombok.Builder;
  import lombok.Getter;
  import lombok.NoArgsConstructor;
  import lombok.Setter;
  import org.springframework.data.annotation.CreatedDate;
  import org.springframework.data.annotation.LastModifiedDate;
  import org.springframework.data.jpa.domain.support.AuditingEntityListener;
  
  import java.time.LocalDateTime;
  import java.util.List;
  
  @Getter
  @Setter
  @NoArgsConstructor
  @AllArgsConstructor
  @Builder
  @Entity
  @Table(name = "roles", indexes = {
          @Index(name = "idx_roles_name", columnList = "name")
  })
  @EntityListeners(AuditingEntityListener.class)
  public class Role {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Integer id;
  
      // "ROLE_ADMIN", "ROLE_FREELANCER", and "ROLE_CLIENT".
      @Column(unique = true, nullable = false)
      private String name;
  
      @ManyToMany(mappedBy = "roles")
      @JsonIgnore
      private List<User> users;
  
      @CreatedDate
      @Column(nullable = false, updatable = false)
      private LocalDateTime createdAt;
  
      @LastModifiedDate
      private LocalDateTime lastModifiedAt;
  }
  