From 0ff20eb753238a89cd90f07a6d340c5a27b1bfd0 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Fri, 19 Oct 2018 19:16:06 -0500 Subject: [PATCH] Add image fields for Appliance table raw, normalized, thumbnail --- .../a2676d3dfc1e_add_appliance_images.py | 39 +++++++++++++++++++ rattail_tempmon/db/model.py | 16 ++++++++ 2 files changed, 55 insertions(+) create mode 100644 rattail_tempmon/db/alembic/versions/a2676d3dfc1e_add_appliance_images.py diff --git a/rattail_tempmon/db/alembic/versions/a2676d3dfc1e_add_appliance_images.py b/rattail_tempmon/db/alembic/versions/a2676d3dfc1e_add_appliance_images.py new file mode 100644 index 0000000..45fb8ea --- /dev/null +++ b/rattail_tempmon/db/alembic/versions/a2676d3dfc1e_add_appliance_images.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8; -*- +"""add appliance images + +Revision ID: a2676d3dfc1e +Revises: 796084026e5b +Create Date: 2018-10-19 18:27:01.700943 + +""" + +from __future__ import unicode_literals, absolute_import + +# revision identifiers, used by Alembic. +revision = 'a2676d3dfc1e' +down_revision = u'796084026e5b' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa +import rattail.db.types + + + +def upgrade(): + + # appliance + op.add_column('appliance', sa.Column('appliance_type', sa.Integer(), nullable=True)) + op.add_column('appliance', sa.Column('image_normal', sa.LargeBinary(), nullable=True)) + op.add_column('appliance', sa.Column('image_raw', sa.LargeBinary(), nullable=True)) + op.add_column('appliance', sa.Column('image_thumbnail', sa.LargeBinary(), nullable=True)) + + +def downgrade(): + + # appliance + op.drop_column('appliance', 'image_thumbnail') + op.drop_column('appliance', 'image_raw') + op.drop_column('appliance', 'image_normal') + op.drop_column('appliance', 'appliance_type') diff --git a/rattail_tempmon/db/model.py b/rattail_tempmon/db/model.py index 01633ee..4abbd29 100644 --- a/rattail_tempmon/db/model.py +++ b/rattail_tempmon/db/model.py @@ -57,10 +57,26 @@ class Appliance(Base): Human-friendly (and unique) name for the appliance. """) + appliance_type = sa.Column(sa.Integer(), nullable=True, doc=""" + Code indicating which "type" of appliance this is. + """) + location = sa.Column(sa.String(length=255), nullable=True, doc=""" Description of the appliance's physical location. """) + image_raw = sa.Column(sa.LargeBinary(), nullable=True, doc=""" + Byte sequence of the raw image, as uploaded. + """) + + image_normal = sa.Column(sa.LargeBinary(), nullable=True, doc=""" + Byte sequence of the normalized image, i.e. "reasonable" size. + """) + + image_thumbnail = sa.Column(sa.LargeBinary(), nullable=True, doc=""" + Byte sequence of the thumbnail image. + """) + def __str__(self): return self.name