我试图创建表User
和Task
。在User
中,我使user_id
列唯一,但peewee忽略了它。当我查看时,没有唯一列:
class BaseModel(Model):
class Meta:
database = DBConfig.db
class User(BaseModel):
user_id = IntegerField(unique=True, null=False)
class Meta:
table_name = 'User'
class Task(BaseModel):
task_content = TextField(null=False)
completed = BooleanField(null=False, default=False)
user_id = ForeignKeyField(User, backref='tasks', field='user_id', on_delete='CASCADE', on_update='CASCADE',
null=False)
class Meta:
table_name = 'Task'
1条答案
按热度按时间wgmfuz8q1#
适合我:
生成以下SQL: