I am trying to run python manage.py makemigrations
after running python manage.py inspectdb > models.py
without any errors, but I am getting a lot of errors with makemigrations
and I have no idea how to solve these. Some of these errors are:
ERRORS:
whale.GeometryColumnsAuth.f_geometry_column: (fields.E311) 'GeometryColumns.f_geometry_column' must be unique because it is referenced by a foreign key.
HINT: Add unique=True to this field or add a UniqueConstraint (without condition) in the model Meta.constraints.
whale.GeometryColumnsFieldInfos.f_geometry_column: (fields.E311) 'GeometryColumns.f_geometry_column' must be unique because it is referenced by a foreign key.
HINT: Add unique=True to this field or add a UniqueConstraint (without condition) in the model Meta.constraints.
whale.GeometryColumnsStatistics.f_geometry_column: (fields.E311) 'GeometryColumns.f_geometry_column' must be unique because it is referenced by a foreign key.
HINT: Add unique=True to this field or add a UniqueConstraint (without condition) in the model Meta.constraints.
I have tried to solve this by:
class Meta:
#managed = False
db_table = 'geometry_columns_auth'
constraints = [
UniqueConstraint(fields=['f_geometry_column'], name='unique_f_geometry_column')
]
But, this has not resolved my errors. My GeometryColumnsAuth looks like:
class GeometryColumnsAuth(models.Model):
f_table_name = models.OneToOneField(GeometryColumns, models.DO_NOTHING, db_column='f_table_name', primary_key=True) # The composite primary key (f_table_name, f_geometry_column) found, that is not supported. The first column is selected.
f_geometry_column = models.ForeignKey(GeometryColumns, models.DO_NOTHING, db_column='f_geometry_column', to_field='f_geometry_column', related_name='geometrycolumnsauth_f_geometry_column_set')
read_only = models.IntegerField()
hidden = models.IntegerField()
class Meta:
#managed = False
db_table = 'geometry_columns_auth'
constraints = [
UniqueConstraint(fields=['f_geometry_column'], name='unique_f_geometry_column')
]
How can I resolve these errors?