import json
from django.db import models

class Role(models.Model):
    id = models.BigAutoField(primary_key=True)
    name = models.CharField(max_length=255)
    type = models.CharField(max_length=100, default="admin")
    color = models.CharField(max_length=100, null=True)
    created_by = models.BigIntegerField(null=True)
    created_at = models.DateTimeField(auto_now_add=True,null=True)
    updated_by = models.BigIntegerField(null=True)
    updated_at = models.DateTimeField(auto_now=True,null=True)

    class Meta:
        db_table = "role"
        constraints = [
            models.UniqueConstraint(fields=["name", "type"], name="unique_name_type")
        ]

    def __str__(self):
        return self.name