From f6ba77e533aeabcaad0cdfb5964bd3f44f47db8c Mon Sep 17 00:00:00 2001 From: furu04 Date: Fri, 13 Jun 2025 23:02:48 +0900 Subject: [PATCH 1/4] =?UTF-8?q?DB=E3=82=92=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/workout.py | 65 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/app/models/workout.py b/app/models/workout.py index e69de29..9dc5403 100644 --- a/app/models/workout.py +++ b/app/models/workout.py @@ -0,0 +1,65 @@ +from . import db +from datetime import datetime, date + +class User(db.Model): + __tablename__ = 'users' + + id = db.Column(db.Integer, primary_key=True) + username = db.Column(db.String(80), unique=True, nullable=False) + email = db.Column(db.String(120), unique=True, nullable=True) + password_hash = db.Column(db.String(128), nullable=False) + profile_image_url = db.Column(db.String(255), nullable=True) + bio = db.Column(db.Text, nullable=True) + created_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) + updated_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow) + + workouts = db.relationship('Workout', backref='user', lazy=True, cascade="all, delete-orphan") + + def __repr__(self): + return f'' + +class Workout(db.Model): + __tablename__ = 'workouts' + + id = db.Column(db.Integer, primary_key=True) + user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False) + title = db.Column(db.String(120), nullable=False) + workout_date = db.Column(db.Date, nullable=False, default=date.today) + memo = db.Column(db.Text, nullable=True) + created_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) + updated_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow) + + logs = db.relationship('WorkoutLog', backref='workout', lazy=True, cascade="all, delete-orphan") + + def __repr__(self): + return f'' + +class Exercise(db.Model): + __tablename__ = 'exercises' + + id = db.Column(db.Integer, primary_key=True) + name = db.Column(db.String(120), unique=True, nullable=False) + target_muscle_group = db.Column(db.String(80), nullable=True) + description = db.Column(db.Text, nullable=True) + image_url = db.Column(db.String(255), nullable=True) + + logs = db.relationship('WorkoutLog', backref='exercise', lazy=True) + + def __repr__(self): + return f'' + +class WorkoutLog(db.Model): + __tablename__ = 'workout_logs' + + id = db.Column(db.Integer, primary_key=True) + workout_id = db.Column(db.Integer, db.ForeignKey('workouts.id'), nullable=False) + exercise_id = db.Column(db.Integer, db.ForeignKey('exercises.id'), nullable=False) + set_number = db.Column(db.Integer, nullable=False) + weight = db.Column(db.Float, nullable=False) + reps = db.Column(db.Integer, nullable=False) + unit = db.Column(db.String(10), nullable=False, default='kg') + created_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) + updated_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow) + + def __repr__(self): + return f'' \ No newline at end of file From c945a2adb6710bf242cb1c7648828423011ba94a Mon Sep 17 00:00:00 2001 From: furu04 Date: Sat, 14 Jun 2025 08:16:07 +0900 Subject: [PATCH 2/4] =?UTF-8?q?.env=E3=82=92=E5=89=8A=E9=99=A4=E3=81=97.gi?= =?UTF-8?q?tignore=E3=81=AB=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8447c59..4d186f6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -develop.md \ No newline at end of file +develop.md +.env \ No newline at end of file From 1b07f36387869fd0f558701a0b3280390c50efba Mon Sep 17 00:00:00 2001 From: furu04 Date: Sat, 14 Jun 2025 08:28:51 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=5F=5Finit=5F=5F.py=E3=82=92=E4=BD=9C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/__init__.py | 2 ++ app/models/workout.py | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/__init__.py b/app/models/__init__.py index e69de29..1f23723 100644 --- a/app/models/__init__.py +++ b/app/models/__init__.py @@ -0,0 +1,2 @@ +from . import db +from datetime import datetime \ No newline at end of file diff --git a/app/models/workout.py b/app/models/workout.py index 9dc5403..8768e87 100644 --- a/app/models/workout.py +++ b/app/models/workout.py @@ -1,6 +1,3 @@ -from . import db -from datetime import datetime, date - class User(db.Model): __tablename__ = 'users' From be8d932db2ba3429798d89929b2c94cbf0f5cac4 Mon Sep 17 00:00:00 2001 From: furu04 Date: Sat, 14 Jun 2025 08:38:37 +0900 Subject: [PATCH 4/4] =?UTF-8?q?repositories/=5F=5Finit=5F=5F.py=E3=82=92?= =?UTF-8?q?=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/repositories/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/repositories/__init__.py b/app/repositories/__init__.py index e69de29..608624f 100644 --- a/app/repositories/__init__.py +++ b/app/repositories/__init__.py @@ -0,0 +1 @@ +from app.models.workout import Workout \ No newline at end of file