B
B
beginer02020-05-06 18:34:09
Django
beginer0, 2020-05-06 18:34:09

Django.db.utils.ProgrammingError: ERROR: Relationship 'AssignedToEmployee_equipment_27' already exists?

removed a couple of fields from the model, deleted the database, and created a new one in which I want to migrate and the
model gives such an error

class  Type(models.Model):
    name = models.CharField(max_length=100,db_index=True)
    class Meta:
        db_table = "Тип"
    def __str__(self):
        return '{}'.format(self.name)


class Room(models.Model):
    name = models.CharField(max_length=100, blank=True, db_index=True, null=True)
    number = models.CharField(max_length=100,db_index=True)
    def __str__(self):
        return '{}'.format(self.number)
    class Meta:
            db_table = "Кабинет"

class Cause(models.Model):
    name = models.CharField(max_length=100,db_index=True)
    def __str__(self):
        return '{}'.format(self.name)
    class Meta:
        db_table = "ПричиныПеремещения"

class Workers(models.Model):
    name = models.CharField(max_length=30)
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
    room = models.CharField(max_length=100)
    full_name = models.CharField(max_length=100,db_index=True)
    def __str__(self):
        return '{}'.format(self.full_name)
    class Meta:
        db_table = "Сотрудники"

class Admission(models.Model):
    name = models.CharField(max_length=100,db_index=True)
    date = models.DateField()
    in_stock = models.IntegerField(null=True, blank=True)
    out_of_stock = models.IntegerField(null=True, blank=True)
    admission = models.IntegerField()
    id_type= models.ForeignKey(
    'Type',
    null=True,
    on_delete=models.SET_NULL,
    related_name='type'
    )

    def __str__(self):
        return '{}'.format(self.name)


    class Meta:
        db_table = "Приход"

class Relocation(models.Model):
    count = models.IntegerField()
    relocation_date = models.DateField()
    previous_room = models.CharField(max_length=50,db_index=True)
    equipment = models.CharField(max_length=50,db_index=True)
    type= models.CharField(max_length=50,db_index=True)
    previous_user = models.CharField(max_length=50,db_index=True)
    id_workers= models.ForeignKey(
    'Workers',
    blank = True,
    null=True,
    on_delete=models.SET_NULL,
    related_name='workers_r'
    )
    id_movereason= models.ForeignKey(
    'Cause',
    blank = True,
    null=True,
    on_delete=models.SET_NULL,
    related_name='cause_r'
    )
    id_room= models.ForeignKey(
    'Room',
    blank = True,
    null=True,
    on_delete=models.SET_NULL,
    related_name='room_r'
    )
    class Meta:
        db_table = "ИсторияПеремещений"

class EquipmentWorkers(models.Model):
    date = models.DateField()
    count = models.IntegerField()
    equipment = models.CharField(max_length=50, db_index=True)
    type= models.CharField(max_length=50, db_index=True)
    id_workers= models.ForeignKey(
    'Workers',
    blank = True,
    null=True,
    on_delete=models.SET_NULL,
    related_name='workers_e'
    )
    id_room= models.ForeignKey(
    'Room',
    blank = True,
    null=True,
    on_delete=models.SET_NULL,
    related_name='room_e'
    )
    class Meta:
        db_table = "ЗакрепленноеЗаСотрудником"

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question