diff --git a/ref-test/app/models/dataset.py b/ref-test/app/models/dataset.py index dc870f5..6a22da3 100644 --- a/ref-test/app/models/dataset.py +++ b/ref-test/app/models/dataset.py @@ -14,8 +14,7 @@ from pathlib import Path from uuid import uuid4 class Dataset(db.Model): - - id = db.Column(db.String(36), primary_key=True) + id = db.Column(db.String(36), index=True, primary_key=True) name = db.Column(db.String(128), nullable=False) tests = db.relationship('Test', backref='dataset') creator_id = db.Column(db.String(36), db.ForeignKey('user.id')) diff --git a/ref-test/app/models/entry.py b/ref-test/app/models/entry.py index b9d07da..217f0b6 100644 --- a/ref-test/app/models/entry.py +++ b/ref-test/app/models/entry.py @@ -11,16 +11,15 @@ from datetime import datetime, timedelta from uuid import uuid4 class Entry(db.Model): - - id = db.Column(db.String(36), primary_key=True) + id = db.Column(db.String(36), index=True, primary_key=True) first_name = db.Column(db.String(128), nullable=False) surname = db.Column(db.String(128), nullable=False) email = db.Column(db.String(128), nullable=False) club = db.Column(db.String(128), nullable=True) test_id = db.Column(db.String(36), db.ForeignKey('test.id')) user_code = db.Column(db.String(6), nullable=True) - start_time = db.Column(db.DateTime, nullable=True) - end_time = db.Column(db.DateTime, nullable=True) + start_time = db.Column(db.DateTime, index=True, nullable=True) + end_time = db.Column(db.DateTime, index=True, nullable=True) status = db.Column(db.String(16), nullable=True) valid = db.Column(db.Boolean, default=True, nullable=True) answers = db.Column(MutableJson, nullable=True) diff --git a/ref-test/app/models/test.py b/ref-test/app/models/test.py index 1bdc160..7bf5e5c 100644 --- a/ref-test/app/models/test.py +++ b/ref-test/app/models/test.py @@ -9,10 +9,9 @@ import secrets from uuid import uuid4 class Test(db.Model): - - id = db.Column(db.String(36), primary_key=True) - code = db.Column(db.String(36), nullable=False) - start_date = db.Column(db.DateTime, nullable=True) + id = db.Column(db.String(36), index=True, primary_key=True) + code = db.Column(db.String(36), index=True, nullable=False) + start_date = db.Column(db.DateTime, index=True, nullable=True) end_date = db.Column(db.DateTime, nullable=True) time_limit = db.Column(db.Integer, nullable=True) creator_id = db.Column(db.String(36), db.ForeignKey('user.id')) diff --git a/ref-test/app/models/user.py b/ref-test/app/models/user.py index 8101e97..d8d55e5 100644 --- a/ref-test/app/models/user.py +++ b/ref-test/app/models/user.py @@ -11,11 +11,11 @@ from werkzeug.security import check_password_hash, generate_password_hash import secrets from uuid import uuid4 class User(UserMixin, db.Model): - id = db.Column(db.String(36), primary_key=True) + id = db.Column(db.String(36), index=True, primary_key=True) username = db.Column(db.String(128), nullable=False) password = db.Column(db.String(128), nullable=False) email = db.Column(db.String(128), nullable=False) - reset_token = db.Column(db.String(20), nullable=True) + reset_token = db.Column(db.String(20), index=True, nullable=True) verification_token = db.Column(db.String(20), nullable=True) tests = db.relationship('Test', backref='creator') datasets = db.relationship('Dataset', backref='creator')