drop ethereum_address of deliverynote

This commit is contained in:
Cayo Puigdefabregas 2021-02-03 22:28:04 +01:00
parent 7a88d9d730
commit b9f3d5976b
4 changed files with 35 additions and 4 deletions

View File

@ -0,0 +1,34 @@
"""change deliverynote
Revision ID: eca457d8b2a4
Revises: 0cbd839b09ef
Create Date: 2021-02-03 22:12:41.033661
"""
from alembic import context
from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils
import citext
import teal
# revision identifiers, used by Alembic.
revision = 'eca457d8b2a4'
down_revision = '0cbd839b09ef'
branch_labels = None
depends_on = None
def get_inv():
INV = context.get_x_argument(as_dictionary=True).get('inventory')
if not INV:
raise ValueError("Inventory value is not specified")
return INV
def upgrade():
op.drop_column('deliverynote', 'ethereum_address', schema=f'{get_inv()}')
def downgrade():
op.add_column('deliverynote', sa.Column('ethereum_address', citext.CIText(), nullable=True), schema=f'{get_inv()}')

View File

@ -46,7 +46,6 @@ class Deliverynote(Thing):
transferred_devices = db.Column(db.ARRAY(db.Integer, dimensions=1), nullable=True) transferred_devices = db.Column(db.ARRAY(db.Integer, dimensions=1), nullable=True)
transfer_state = db.Column(IntEnum(TransferState), default=TransferState.Initial, nullable=False) transfer_state = db.Column(IntEnum(TransferState), default=TransferState.Initial, nullable=False)
transfer_state.comment = TransferState.__doc__ transfer_state.comment = TransferState.__doc__
ethereum_address = db.Column(CIText(), unique=True, default=None)
lot_id = db.Column(UUID(as_uuid=True), lot_id = db.Column(UUID(as_uuid=True),
db.ForeignKey(Lot.id), db.ForeignKey(Lot.id),
nullable=False) nullable=False)

View File

@ -21,7 +21,6 @@ class Deliverynote(Thing):
date = f.DateTime('iso', required=True) date = f.DateTime('iso', required=True)
deposit = f.Integer(validate=f.validate.Range(min=0, max=100), deposit = f.Integer(validate=f.validate.Range(min=0, max=100),
description=m.Deliverynote.deposit.__doc__) description=m.Deliverynote.deposit.__doc__)
ethereum_address = f.String(description='User identifier address inside the Blockchain')
expected_devices = f.List(f.Dict, required=True, data_key='expectedDevices') expected_devices = f.List(f.Dict, required=True, data_key='expectedDevices')
transferred_devices = f.List(f.Integer(), required=False, data_key='transferredDevices') transferred_devices = f.List(f.Integer(), required=False, data_key='transferredDevices')
transfer_state = EnumField(TransferState, description=m.Lot.transfer_state.comment) transfer_state = EnumField(TransferState, description=m.Lot.transfer_state.comment)

View File

@ -28,8 +28,7 @@ class DeliverynoteView(View):
return ret return ret
def patch(self, id): def patch(self, id):
patch_schema = self.resource_def.SCHEMA(only=('transfer_state', patch_schema = self.resource_def.SCHEMA(only=('transfer_state'), partial=True)
'ethereum_address'), partial=True)
d = request.get_json(schema=patch_schema) d = request.get_json(schema=patch_schema)
dlvnote = Deliverynote.query.filter_by(id=id).one() dlvnote = Deliverynote.query.filter_by(id=id).one()
# device_fields = ['transfer_state', 'deliverynote_address'] # device_fields = ['transfer_state', 'deliverynote_address']