Django Migrations not applying

So i have an app called accounts in which I have two models called Client and Contact. I was trying to apply migrations for the Contact field but something wasn’t working. It was saying that my email field cannot be a non-nullable field or something even though an email shouldn’t have a default. So I thought deleting the tables in PostGres would solve the problem since this is an early project, (not much data work has been done.) But now whenever I apply make the migration file, it says Migrations for 'accounts': accounts\migrations\0001_initial.py - Create model Client - Create model Contact then when I migrate it says Operations to perform: Apply all migrations: accounts Running migrations: No migrations to apply. . Ive tried flushing the database, deleting the migration initial file, but nothing is working still getting the same error and the migration is not applying the tables in my database. This is my Contact model.

class Contact(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
email = models.EmailField(max_length=150)
date = models.DateField(default=timezone.now)
discipline = models.CharField(max_length=2, choices=Disciplines.choices, default=Disciplines.BOXING)

If you want to restart from scratch with an empty database. You should also remove the django_migrations table.

If, by removing the table, you only cancelled what correspond to your 0001_initial migration, just remove the corresponding record in django_migrations table

1 Like

Yes so what I did was in pgAdmin I selected the table django_migrations and I selected the accounts app which I was having problems with. Then I deleted that record from the migrations table as well as from the migration folder, after that when i applied the migrations it applied everything, and the tables were also created.