Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When deleting a field with unqiue=True it will raise KeyError #364

Closed
gck123 opened this issue Nov 14, 2024 · 0 comments · Fixed by #365
Closed

When deleting a field with unqiue=True it will raise KeyError #364

gck123 opened this issue Nov 14, 2024 · 0 comments · Fixed by #365

Comments

@gck123
Copy link
Contributor

gck123 commented Nov 14, 2024

Describe the bug
When deleting a field with unqiue=True it will raise KeyError.

To Reproduce

version:
mysql8.0,tortoise-orm branch is develop(version 905daaa53928622b53454f65fd629690a7e5491f),aerich branch is dev(version 15d5612

Steps to Reproduction:

1.This is my model

class Tasks(Model):
    """任务表"""
    id = fields.IntField(pk=True)
    name = fields.CharField(max_length=100, unique=True, description="任务名称")
    status = fields.IntEnumField(enum_type=TaskStatus, description="任务状态")
    class Meta:
        table = "tb_tasks"

2.Init db

aerich init -t utils.config.TORTOISE_CONFIG
aerich init-db

3.Delete the name field of the model from step 2

class Tasks(Model):
    """任务表"""
    id = fields.IntField(pk=True)
    status = fields.IntEnumField(enum_type=TaskStatus, description="任务状态")
    class Meta:
        table = "tb_tasks"

4.Migrate and upgrade

aerich migrate
aerich upgrade

5.It will raise a exception
KeyError: 'name'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant