from django.db import models
from django.db.models.constraints import UniqueConstraint
import ulid


class ULIDField(models.CharField):
    def __init__(self, *args, **kwargs):
        kwargs["max_length"] = 26
        super(ULIDField, self).__init__(*args, **kwargs)

    def db_type(self, connection):
        return "char(26)"


class ImgItemDefModel(models.Model):
    iid_item_no = models.CharField(max_length=16, primary_key=True)
    iid_type = models.CharField(max_length=1)
    iid_del = models.CharField(max_length=1)
    iid_order = models.IntegerField()
    iid_label = models.CharField(max_length=256)
    iid_cls = models.CharField(max_length=1)
    iid_nn = models.CharField(max_length=1)
    iid_ext = models.CharField(max_length=8)
    iid_use_appl = models.CharField(max_length=16)

    class Meta:
        managed = False
        db_table = "img_item_def_t"
        unique_together = ["iid_item_no", "iid_type"]
