Add dataset and entry relation to database models

This commit is contained in:
Vivek Santayana 2023-03-04 18:55:30 +00:00
parent 1ea93994ab
commit 07fb170656
2 changed files with 3 additions and 0 deletions

View File

@ -17,6 +17,7 @@ class Dataset(db.Model):
id = db.Column(db.String(36), index=True, primary_key=True) id = db.Column(db.String(36), index=True, primary_key=True)
name = db.Column(db.String(128), nullable=False) name = db.Column(db.String(128), nullable=False)
tests = db.relationship('Test', backref='dataset') tests = db.relationship('Test', backref='dataset')
entries = db.relationship('Entry', backref='dataset')
creator_id = db.Column(db.String(36), db.ForeignKey('user.id')) creator_id = db.Column(db.String(36), db.ForeignKey('user.id'))
date = db.Column(db.DateTime, nullable=False) date = db.Column(db.DateTime, nullable=False)
default = db.Column(db.Boolean, default=False, nullable=True) default = db.Column(db.Boolean, default=False, nullable=True)

View File

@ -2,6 +2,7 @@ from ..extensions import db, mail
from ..tools.encryption import decrypt, encrypt from ..tools.encryption import decrypt, encrypt
from ..tools.logs import write from ..tools.logs import write
from .test import Test from .test import Test
from .dataset import Dataset
from flask_login import current_user from flask_login import current_user
from flask_mail import Message from flask_mail import Message
@ -17,6 +18,7 @@ class Entry(db.Model):
email = db.Column(db.String(128), nullable=False) email = db.Column(db.String(128), nullable=False)
club = db.Column(db.String(128), nullable=True) club = db.Column(db.String(128), nullable=True)
test_id = db.Column(db.String(36), db.ForeignKey('test.id')) test_id = db.Column(db.String(36), db.ForeignKey('test.id'))
dataset_id = db.Column(db.String(36), db.ForeignKey('dataset.id'))
user_code = db.Column(db.String(6), nullable=True) user_code = db.Column(db.String(6), nullable=True)
start_time = db.Column(db.DateTime, index=True, nullable=True) start_time = db.Column(db.DateTime, index=True, nullable=True)
end_time = db.Column(db.DateTime, index=True, nullable=True) end_time = db.Column(db.DateTime, index=True, nullable=True)