The serious problem occurs when migrate

This is my models:

class Role(models.Models):  
    name = .....

class User(AbstractUser):
    role = ForeignKey(

I changed name of models UserType to Role . When I developed, i created migrations and migrates several times so it everything was OK. But when I deployed to production, I migrated and the problems began.

Django applied and ran migrations file from app core before user. So the table name was changed to core_role but in user it still using UserType as foreign key. So I can not migrate and do anything in my production.

Any one can help me with this. I’m very nervous because it my company product

You’ve got a couple of options. You can either manually correct your database, or you could create your own migration to straighten things out, or you could reverse the migration and edit the migration files before applying them.

I created and could not migrate my own because pre_migrate_state raise error. I think i must manually correct my database but i dont know what exactly i will do. I don’t have experience to solve this and my company have not Senior :frowning: