You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 此文件用于定义数据库表的模型
# 使用命令行创建数据库表
# flask db init # 初始化(只要执行一次)
# flask db migrate #检查模型文件,生成迁移文件
# flask db upgrade # 更新数据库
# 后续添加表只要执行 migrate 和 upgrade 命令即可
from exts import db
from datetime import datetime
class UserModel(db.Model):
__tablename__ = 'user'
id = db.Column(db.Integer, primary_key=True, autoincrement=True) #也是视频收藏号与视频收藏表关联得到收藏号去视频收藏表中查找收藏的视频id
username = db.Column(db.String(100), nullable=False)
password = db.Column(db.String(500), nullable=False)
email = db.Column(db.String(100), nullable=False, unique=True)
stu_id = db.Column(db.String(100), nullable=False, unique=True)
user_say = db.Column(db.String(500), nullable=True)
join_time = db.Column(db.DateTime, default=datetime.now)
address = db.Column(db.String(100), nullable=True)
enterprise = db.Column(db.String(100), nullable=True)
user_avatar_url = db.Column(db.String(100), nullable=False, default='/static/imgs/users/root.png')
class VideoUri(db.Model):
__tablename__ = 'videouri'
id = db.Column(db.Integer, primary_key=True, autoincrement=True) #视频id
video_url = db.Column(db.String(100), nullable=False)
video_img_src = db.Column(db.String(100), nullable=False)
video_tite = db.Column(db.String(100), nullable=False)
class FavoriteVideo(db.Model):
__tablename__ = 'favorite'
favorite_id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True)
video_id = db.Column(db.Integer, db.ForeignKey('videouri.id'), primary_key=True)
class EmailCaptchaModel(db.Model):
__tablename__ = 'email_captcha'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
email = db.Column(db.String(100), nullable=False)
captcha = db.Column(db.String(100), nullable=False)