共计 570 个字符,预计需要花费 2 分钟才能阅读完成。
class TinyUrl(Model):
id = BigAutoField()
user_id = IntegerField(null=False)
short_uuid = CharField(max_length=255, null=False, help_text='长度为 6 位')
long_url_hash = CharField(max_length=64, null=False)
long_url = CharField(max_length=2048, null=False)
created_at = DateTimeField(
null=False,
constraints=[SQL('DEFAULT CURRENT_TIMESTAMP')],
help_text='应用数据库工夫'
)
updated_at = DateTimeField(
null=False,
constraints=[SQL('DEFAULT CURRENT_TIMESTAMP'),
SQL('ON UPDATE CURRENT_TIMESTAMP'),
]
)
class Meta:
database = db
table_name = 'tiny_url'
indexes = ((('short_uuid',), True),
(('user_id', 'long_url_hash'), True),
)
应用 indexes 就能够了
正文完