from django.db import models
import datetime
from utente.models import *

class Documento(models.Model):
  utente = models.ForeignKey(Utente,on_delete=models.CASCADE)
  azienda = models.ForeignKey(Azienda,default=0,on_delete=models.CASCADE)
  documento = models.CharField(max_length=256,null=True,default="")
  storage = models.CharField(max_length=256,null=True,default="")
  dataupload = models.DateField(null=True,default=datetime.date.today)
  crc = models.CharField(max_length=256,null=False,default="")
  descrizione = models.CharField(max_length=128,null=False,default="")
  
  class Meta:
    constraints = [ models.UniqueConstraint(fields=['documento'], name="unique-documento") ]
    indexes = [ models.Index(fields=['documento','utente']) ]

