From a6df96213bbc949b23cb16bd010e2d1a383f7c02 Mon Sep 17 00:00:00 2001 From: Ken Tsang Date: Thu, 6 Jul 2017 10:56:03 +0100 Subject: [PATCH] Update model and migration script --- app/models.py | 6 ++--- .../versions/0105_change_logo_not_nullable.py | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 migrations/versions/0105_change_logo_not_nullable.py diff --git a/app/models.py b/app/models.py index 8dd56c96e..43e8b7ebe 100644 --- a/app/models.py +++ b/app/models.py @@ -130,11 +130,11 @@ class BrandingTypes(db.Model): name = db.Column(db.String(255), primary_key=True) -class Organisation(db.Model, Versioned): +class Organisation(db.Model): __tablename__ = 'organisation' id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) colour = db.Column(db.String(7), nullable=True) - logo = db.Column(db.String(255), nullable=True) + logo = db.Column(db.String(255), nullable=False) name = db.Column(db.String(255), nullable=True) @classmethod @@ -142,7 +142,7 @@ class Organisation(db.Model, Versioned): """ Assumption: data has been validated appropriately. - Returns a Organisation object based on the provided data. + Returns a Organisation object based on the provided data. """ # validate json with marshmallow fields = data.copy() diff --git a/migrations/versions/0105_change_logo_not_nullable.py b/migrations/versions/0105_change_logo_not_nullable.py new file mode 100644 index 000000000..09efbcb41 --- /dev/null +++ b/migrations/versions/0105_change_logo_not_nullable.py @@ -0,0 +1,27 @@ +"""empty message + +Revision ID: 0105_change_logo_not_nullable +Revises: 0104_more_letter_orgs +Create Date: 2017-07-06 10:14:35.188404 + +""" + +# revision identifiers, used by Alembic. +revision = '0105_change_logo_not_nullable' +down_revision = '0104_more_letter_orgs' + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + + +def upgrade(): + op.alter_column('organisation', 'logo', + existing_type=sa.VARCHAR(length=255), + nullable=False) + + +def downgrade(): + op.alter_column('organisation', 'logo', + existing_type=sa.VARCHAR(length=255), + nullable=True)