class UserBlasts(db.Model): """ User has many blasts (join table)""" id = db.Column(db.Integer(), primary_key=True) user_id = db.Column(db.Integer(), db.ForeignKey('user.id', ondelete='CASCADE')) blast_id = db.Column(db.Integer(), db.ForeignKey('blast.id', ondelete='CASCADE'))
class UserConversations(db.Model): """ User has many conversations (join table)""" id = db.Column(db.Integer(), primary_key=True) user_id = db.Column(db.Integer(), db.ForeignKey('user.id', ondelete='CASCADE')) conversation_id = db.Column( db.Integer(), db.ForeignKey('conversation.id', ondelete='CASCADE')) pass
class UserRoles(db.Model): id = db.Column(db.Integer(), primary_key=True) user_id = db.Column(db.Integer(), db.ForeignKey('user.id', ondelete='CASCADE')) role_id = db.Column(db.Integer(), db.ForeignKey('role.id', ondelete='CASCADE')) # Relationships user = db.relationship('User', backref='roles') role = db.relationship('Role', backref='users')
class Message(db.Model): """ Message belongs to a conversation has many users """ id = db.Column(db.Integer, primary_key=True) created = db.Column(db.DateTime) content = db.Column(db.String) user_id = db.Column(db.Integer(), db.ForeignKey('user.id', ondelete='CASCADE')) conversation_id = db.Column( db.Integer(), db.ForeignKey('conversation.id', ondelete='CASCADE'))
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) user_profile_id = db.Column(db.Integer(), db.ForeignKey('user_profile.id', ondelete='CASCADE')) # Flask-User fields active = db.Column(db.Boolean(), nullable=False, server_default='0') username = db.Column(db.String(50), nullable=False, unique=True) email = db.Column(db.String(255), nullable=False, unique=True) confirmed_at = db.Column(db.DateTime()) password = db.Column(db.String(255), nullable=False, server_default='') reset_password_token = db.Column(db.String(100), nullable=False, server_default='') # Relationships user_profile = db.relationship('UserProfile', uselist=False, backref="user")
class UserAuth(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer(), db.ForeignKey('user.id', ondelete='CASCADE')) # User authentication information (required for Flask-User) username = db.Column(db.String(50), nullable=False, unique=True) password = db.Column(db.String(255), nullable=False, server_default='') reset_password_token = db.Column(db.String(100), nullable=False, server_default='') active = db.Column(db.Boolean(), nullable=False, server_default='0') # Relationships user = db.relationship('User', uselist=False)
class UserRoles(db.Model): id = db.Column(db.Integer(), primary_key=True) user_id = db.Column(db.Integer(), db.ForeignKey('user.id', ondelete='CASCADE')) role_id = db.Column(db.Integer(), db.ForeignKey('role.id', ondelete='CASCADE'))
class Role(db.Model): id = db.Column(db.Integer(), primary_key=True) name = db.Column(db.String(50), unique=True) description = db.Column(db.String(255))