I am trying to use Azure SQL with Django by using mssql-django.
I get this error during "makemigrations":
django.db.utils.ProgrammingError: ('42S02', "[42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'customer_group_customergroup'. (208) (SQLExecDirectW); [42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Statement(s) could not be prepared. (8180)")
The connection to Azure SQL is already working. If I start a new app, I could make the migrations and migrate it into Azure SQL without problem.
If I migrate only the "customer_group" App, there is no problem. The problem only occurs when I want to migrate apps, whose model contains a foreign key field named customer_group. I tried renaming the field (suspecting it was some naming conflict) but the error still persists.
Does anyone know how to correct this error? Thank you!
Edit: My customer_group app has this model:
class CustomerGroup(models.Model):
name = models.CharField(max_length=50, unique=True, blank=False, null=False,
verbose_name="Customer group name")
owner_first_name = models.CharField(max_length=20, blank=False, null=False)
owner_last_name = models.CharField(max_length=20, blank=False, null=False)
address = models.CharField(max_length=100, blank=False, null=False)
phone = models.CharField(max_length=15, blank=False, null=False)
billing_info = models.CharField(max_length=200, blank=False, null=False)
uuid = models.UUIDField(unique=True, default=uuid.uuid4,
editable=False, blank=False, null=False)
def __str__(self):
return self.name
apps? It's likely it's missing the dependency on the migration that creates the table for theCustomerGroupmodel.