Use duration instead of separate start/end times.

This commit is contained in:
Sam Black 2017-01-16 00:08:13 +00:00
parent 4f349aa5a2
commit 272e24e9ec
Signed by: samwwwblack
GPG Key ID: 0FF0223994EA47D8
2 changed files with 35 additions and 2 deletions

View File

@ -0,0 +1,33 @@
"""
Use an ArrowRangeType instead of separate start/end datetimes.
Revision ID: 02c2b594dde0
Revises: 7948fd659ddc
Create Date: 2017-01-16 00:03:44.820777
"""
# revision identifiers, used by Alembic.
revision = '02c2b594dde0'
down_revision = '7948fd659ddc'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
from vowel.models.utils import ArrowRangeType
def upgrade():
op.add_column('assessmenttiming',
sa.Column('duration', ArrowRangeType(), nullable=False))
op.drop_column('assessmenttiming', 'end_time')
op.drop_column('assessmenttiming', 'start_time')
def downgrade():
op.add_column('assessmenttiming',
sa.Column('start_time', postgresql.TIMESTAMP(),
autoincrement=False, nullable=False))
op.add_column('assessmenttiming',
sa.Column('end_time', postgresql.TIMESTAMP(),
autoincrement=False, nullable=False))
op.drop_column('assessmenttiming', 'duration')

View File

@ -21,6 +21,7 @@ import arrow
from sqlalchemy_utils.types.arrow import ArrowType
from sqlalchemy_utils.types.choice import ChoiceType
from vowel.models import db
from vowel.models.utils import ArrowRangeType
assessment_criteria_link = db.Table(
"assessment_criteria_link",
@ -142,8 +143,7 @@ class Assessmenttiming(db.Model):
nullable=False)
enrolment = db.relationship("Enrolment", foreign_keys=[enrolment_id])
start_time = db.Column(ArrowType(), nullable=False)
end_time = db.Column(ArrowType(), nullable=False)
duration = db.Column(ArrowRangeType(), nullable=False)
class Assessmentsubmission(db.Model):