Closed forverkg closed 1 year ago
My aerich version is 0.6.3, but it was 0.7.1 at the beginning. This problem also exists
Show your models
default
from tortoise import models
from tortoise import fields
from tortoise.fields.base import CASCADE, RESTRICT, SET_NULL, Field
class Oss2DataInfo(models.Model):
key = fields.TextField(null=True, blank=True, description='文件名')
last_modified = fields.DatetimeField(null=True, blank=True, description='最后修改时间')
etag = fields.TextField(null=True, blank=True, description='ETAG')
type = fields.TextField(null=True, blank=True, description='类型')
size = fields.TextField(null=True, blank=True, description='大小')
storage_class = fields.TextField(null=True, blank=True, description='存储类')
prefix = fields.TextField(null=True, blank=True, description='前缀')
bucket = fields.ForeignKeyField('models.Bucket', on_delete=SET_NULL, null=True, blank=True)
status = fields.ForeignKeyField('models.Oss2Status', on_delete=SET_NULL, null=True, blank=True)
create_time = fields.DatetimeField(auto_now_add=True, null=True, blank=True)
done_time = fields.DatetimeField(null=True, blank=True)
download_path = fields.ForeignKeyField('models.DownloadPath', null=True, blank=True, description='总目录',
on_delete=SET_NULL)
class Meta:
app = "default"
class DownloadPath(models.Model):
name = fields.TextField(null=True, blank=True)
class Meta:
app = "default"
class Oss2Status(models.Model):
name = fields.CharField(null=True, blank=True, max_length=255)
class Meta:
app = "default"
class EnterPoint(models.Model):
name = fields.CharField(max_length=255, null=True, blank=True, description='EnterPoint')
class Meta:
app = "default"
class Bucket(models.Model):
enter_point = fields.ForeignKeyField('models.EnterPoint', on_delete=SET_NULL, null=True, blank=True)
name = fields.CharField(max_length=255, null=True, blank=True, description='EnterPoint')
class Meta:
app = "default"
aorui_test
from tortoise import models
from tortoise import fields
from tortoise.fields.base import CASCADE, RESTRICT, SET_NULL, Field
class AoruiauthUser(models.Model):
password = fields.CharField(max_length=128)
last_login = fields.DatetimeField(blank=True, null=True)
is_superuser = fields.BooleanField(default=False)
uid = fields.CharField(max_length=22)
username = fields.CharField(max_length=20)
telephone = fields.CharField(unique=True, max_length=11)
email = fields.CharField(max_length=254)
is_active = fields.BooleanField(default=True)
is_staff = fields.BooleanField()
data_joined = fields.DatetimeField(auto_now_add=True)
sign_pic = fields.TextField(blank=True, null=True)
class Meta:
# managed = False
db_table = 'aoruiAuth_user'
app = 'aorui_test'
This is the directory structure
models.DownloadPath
the models
mean app, in your config is default
and aorui_test
So, I should write like this, right? The test passed just now
No, replace download_path = fields.ForeignKeyField('models.DownloadPath', null=True, blank=True, description='总目录', on_delete=SET_NULL)
to download_path = fields.ForeignKeyField('default.DownloadPath', null=True, blank=True, description='总目录', on_delete=SET_NULL)
, others is same
Ooooooooh,I see
When I try to use aerich --app=default init db , this command causes the error shown in the first figure; When I try to locate the error, I find that replacing related_app_name with app_name can solve the problem. I expect you to fix this bug in the next version