Describe the bug
I rebuilt all my migrations recently from aerich to the new built in migrations. My initial migration that's generated (overall or for any new model added) doesn't include any inherited fields from Abstract models. When I run a second makemigrations command it then creates a new migration that adds all the inherited abstract model fields, or in the case of inherited PKs it drops the pk field and adds it again. When both migrations are run all of my PKs that should be autogenerated aren't getting a sequence created and added in the SQL.
To Reproduce
class BaseModel(Model):
id = fields.BigIntField(pk=True, generated=True, source_field="id", index=True)
created = fields.DatetimeField(
auto_now_add=True, source_field="created", index=True
)
modified = fields.DatetimeField(auto_now=True, source_field="modified", index=True)
deleted = fields.BooleanField(
null=True, source_field="deleted", default=False, index=True
)
class Meta:
abstract = True
class NewModel(BaseModel):
name = fields.CharField(max_length=255)
Run makemigrations twice, first run will generate table but miss abstract fields, second run will add missing abstract fields. Check table in postgres and see that the NewModel table and id field are missing a newmodel_id_seq.
Expected behavior
Abstract fields should be picked up on a single run as it worked in aerich. Fields defined as pk=True and generated=True should autogenerate a PK upon insert in SQL.
Describe the bug
I rebuilt all my migrations recently from aerich to the new built in migrations. My initial migration that's generated (overall or for any new model added) doesn't include any inherited fields from Abstract models. When I run a second makemigrations command it then creates a new migration that adds all the inherited abstract model fields, or in the case of inherited PKs it drops the pk field and adds it again. When both migrations are run all of my PKs that should be autogenerated aren't getting a sequence created and added in the SQL.
To Reproduce
class BaseModel(Model):
id = fields.BigIntField(pk=True, generated=True, source_field="id", index=True)
created = fields.DatetimeField(
auto_now_add=True, source_field="created", index=True
)
modified = fields.DatetimeField(auto_now=True, source_field="modified", index=True)
deleted = fields.BooleanField(
null=True, source_field="deleted", default=False, index=True
)
class NewModel(BaseModel):
name = fields.CharField(max_length=255)
Run makemigrations twice, first run will generate table but miss abstract fields, second run will add missing abstract fields. Check table in postgres and see that the NewModel table and id field are missing a newmodel_id_seq.
Expected behavior
Abstract fields should be picked up on a single run as it worked in aerich. Fields defined as pk=True and generated=True should autogenerate a PK upon insert in SQL.