0
votes

I write some models in my project, then i deleted an uuid field from my book model and the deleted the 0001_initial.py file and run make migrations and migrate

but when i run py manage.py migrate, show me this message:

  • No migrations to apply.

and when run makemigrations :

Migrations for 'main_app':

main_app\migrations\0001_initial.py

  • Create model Author

  • Create model Book

  • Create model Genre

  • Add field genre to book

this are my models:


class Genre(models.Model):
    genre       = models.CharField(max_length=100)

    def __str__(self):
        return self.genre


class Book(models.Model):
    book_name   = models.CharField(max_length=150)
    summary     = models.TextField(max_length=1000, null=True,blank=True)
    author      = models.ForeignKey('Author', on_delete=models.CASCADE)
    genre       = models.ManyToManyField(Genre)
    status = [
        ('a', 'available'),
        ('b', 'borrowed'),
        ('r', 'reserved'),
    ]
    book_status = models.CharField(max_length=1, choices=status, default='a')
    isbn        = models.CharField(max_length=13,
                            help_text='read '
            '<a href="https://www.isbn-international.org/content/what-isbn">'
                                      'here'
                                      '</a>'
                                      ' to help ')

    def __str__(self):
        return '{0}({1})'.format(self.book_name, self.author)

    def get_absolute_url(self):
        return reverse('main_app:book-detail', args=[self.id])


class Author(models.Model):
    first_name  = models.CharField(max_length=200)
    last_name   = models.CharField(max_length=200)
    rate        = models.IntegerField(default=0)

    def __str__(self):
        return '{0} {1}'.format(self.first_name,self.last_name)
1
I'm not sure if I can help with this - but I'm really not sure why you deleted just the first migration. When you get into db/migration trouble like this, my recommendation would be to delete ALL migrations, then run makemigrations again (followed by migrate of course) - Robin Zigmond
If you delete the migrations, you also need to drop the database. But don't delete the migrations. - Daniel Roseman

1 Answers

0
votes

Delete the entry of the migration you deleted from table django_migrations as well.