class UserProgram(db.Model): __tablename__ = 'user_program' user_id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True) program_id = db.Column(db.Integer, db.ForeignKey('program.id'), primary_key=True) program = db.relationship("Program", backref='program_associations', single_parent=True, cascade='all, delete-orphan') user = db.relationship("User", backref='user_associations')
class UserExercise(db.Model): __tablename__ = 'user_exercise' user_id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True) exercise_id = db.Column(db.Integer, db.ForeignKey('exercise.id'), primary_key=True) exercise = db.relationship("Exercise", backref="exercise_associations", single_parent=True, cascade='all, delete-orphan') user = db.relationship("User", backref="user_exercises_associations")
class Step(db.Model): __tablename__ = 'step' id = db.Column(db.Integer, primary_key=True) program_id = db.Column(db.Integer, db.ForeignKey('program.id'), nullable=False) exercise_id = db.Column(db.Integer, db.ForeignKey('exercise.id'), nullable=False) series = db.Column(db.Integer, default=3, nullable=False) repetitions = db.Column(db.Integer, default=8, nullable=False) weight = db.Column(db.Integer, default=0, nullable=False) rest = db.Column(db.Integer, default=60, nullable=False) rest_end = db.Column(db.Integer, default=60, nullable=False) position = db.Column(db.Integer, nullable=False)
class Exercise(db.Model): __tablename__ = 'exercise' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Text, nullable=False) image = db.Column(db.Text, default="", nullable=False) description = db.Column(db.Text, default="", nullable=False) visibility = db.Column(db.Text, default='PRIVATE', nullable=False) created_at = db.Column(db.DateTime, default=datetime.utcnow(), nullable=False) updated_at = db.Column(db.DateTime, default=datetime.utcnow(), nullable=False) step_relation = db.relationship('Step', backref='exercise', lazy=True, cascade='all, delete-orphan')
class User(db.Model): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(120), unique=True, nullable=False) username = db.Column(db.String(80), unique=True, nullable=False) password = db.Column(db.Text, nullable=False) created_at = db.Column(db.DateTime, default=datetime.utcnow(), nullable=False) updated_at = db.Column(db.DateTime, default=datetime.utcnow(), nullable=False) token_relation = db.relationship('Token', backref='user', cascade='all, delete-orphan') programs = db.relationship('Program', secondary='user_program') exercises = db.relationship('Exercise', secondary='user_exercise')
class Token(db.Model): __tablename__ = 'token' id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) token = db.Column(db.Text, nullable=False)