Skip to content
This repository has been archived by the owner on Jun 18, 2020. It is now read-only.

Commit

Permalink
Model change and db migration for #71
Browse files Browse the repository at this point in the history
  • Loading branch information
moschlar committed Jun 30, 2013
1 parent b549027 commit fee0679
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
53 changes: 53 additions & 0 deletions migration/versions/453b256dce6b_test_failsafe_parsing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""test_failsafe_parsing
Revision ID: 453b256dce6b
Revises: 3a8c537e6090
Create Date: 2013-06-30 20:58:50.998667
"""
#
# # SAUCE - System for AUtomated Code Evaluation
# # Copyright (C) 2013 Moritz Schlarb
# #
# # This program is free software: you can redistribute it and/or modify
# # it under the terms of the GNU Affero General Public License as published by
# # the Free Software Foundation, either version 3 of the License, or
# # any later version.
# #
# # This program is distributed in the hope that it will be useful,
# # but WITHOUT ANY WARRANTY; without even the implied warranty of
# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# # GNU Affero General Public License for more details.
# #
# # You should have received a copy of the GNU Affero General Public License
# # along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# revision identifiers, used by Alembic.
revision = '453b256dce6b'
down_revision = '3a8c537e6090'

from alembic import op, context
#from alembic.operations import Operations as op
import sqlalchemy as sa
from sqlalchemy.orm import sessionmaker
#TODO: This must be wrong - I need a reflected model here
from sauce.model import Test


def upgrade():
cntxt = context.get_context()
Session = sessionmaker(bind=cntxt.bind)

op.add_column('tests', sa.Column(u'failsafe_parsing', sa.Boolean(), nullable=True, default=False))

session = Session()
for test in session.query(Test):
test.failsafe_parsing = False
session.commit()

op.alter_column('tests', 'result_public', nullable=False, default=False)


def downgrade():
op.drop_column('tests', u'failsafe_parsing')
3 changes: 3 additions & 0 deletions sauce/model/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ class Test(DeclarativeBase):
float_precision = Column(Integer, nullable=True)
'''The precision (number of decimal digits) to compare for floats'''

failsafe_parsing = Column(Boolean, nullable=False, default=False) # default=False as long as the mode is not implemented
'''Kind of like the builtin encode/decode errors keyword ignore/strict'''

assignment_id = Column(Integer, ForeignKey('assignments.id'), nullable=False, index=True)
assignment = relationship('Assignment',
backref=backref('tests',
Expand Down

0 comments on commit fee0679

Please sign in to comment.