aerich
aerich copied to clipboard
The type of the id field hasn't changed
Hi,
The aerich automatically create id field as an IntField when I didn't define the id field.
But I defined id as a BigIntField specifically but the aerich doesn't upgrade field to BigIntField if the field isn't ForeignKeyField
Before.
from tortoise import fields
class AbstractBaseModel(AbstractTimestampModel, AbstractActivatorModel):
class Meta:
abstract = True
class AuthServer(AbstractBaseModel):
name = fields.CharField(max_length=64, unique=True)
users: fields.ReverseRelation[User]
class User(orm.AbstractBaseModel):
name = fields.CharField(max_length=10)
identifier = fields.CharField(max_length=100)
auth_server = fields.ForeignKeyField(
model_name="models.AuthServer",
related_name="users",
on_delete=fields.RESTRICT,
)
After.
from tortoise import fields
class AbstractBaseModel(AbstractTimestampModel, AbstractActivatorModel):
id = fields.BigIntField(pk=True)
class Meta:
abstract = True
class AuthServer(AbstractBaseModel):
name = fields.CharField(max_length=64, unique=True)
users: fields.ReverseRelation[User]
class User(AbstractBaseModel):
name = fields.CharField(max_length=10)
identifier = fields.CharField(max_length=100)
auth_server = fields.ForeignKeyField(
model_name="models.AuthServer",
related_name="users",
on_delete=fields.RESTRICT,
)
But the aerich create DDL only for the auth_server_id column
-- upgrade --
ALTER TABLE `user` MODIFY COLUMN `auth_server_id` BIGINT NOT NULL;
-- downgrade --
ALTER TABLE `user` MODIFY COLUMN `auth_server_id` INT NOT NULL;
I also have this problem, but I'm going from a bigint to a normal int.
I also have this problem, change IntField to BigIntField has no effect. aerich says 'No changes detected'.
Also get "No changes detected" when trying to change id field type from IntField to UUIDField
Before:
class User(models.Model):
"""
The User model
"""
id = fields.IntField(pk=True)
After:
class User(models.Model):
"""
The User model
"""
id = fields.UUIDField(pk=True)