diff --git a/ereuse_devicehub/migrations/versions/378b6b147b46_nullable.py b/ereuse_devicehub/migrations/versions/378b6b147b46_nullable.py new file mode 100644 index 00000000..5e7472dc --- /dev/null +++ b/ereuse_devicehub/migrations/versions/378b6b147b46_nullable.py @@ -0,0 +1,35 @@ +"""empty message + +Revision ID: 378b6b147b46 +Revises: bf600ca861a4 +Create Date: 2020-12-16 11:45:13.339624 + +""" +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 = '378b6b147b46' +down_revision = 'bf600ca861a4' +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.alter_column('{get_inv()}.computer', 'chassis', nullable=True) + # pass + + +def downgrade(): + pass diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index af566eb9..526dd6cd 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -410,7 +410,7 @@ class Computer(Device): ``Server``. The property ``chassis`` defines it more granularly. """ id = Column(BigInteger, ForeignKey(Device.id), primary_key=True) - chassis = Column(DBEnum(ComputerChassis), nullable=False) + chassis = Column(DBEnum(ComputerChassis), nullable=True) chassis.comment = """The physical form of the computer. It is a subset of the Linux definition of DMI / DMI decode. diff --git a/ereuse_devicehub/resources/device/schemas.py b/ereuse_devicehub/resources/device/schemas.py index d3671c1b..db0f3c43 100644 --- a/ereuse_devicehub/resources/device/schemas.py +++ b/ereuse_devicehub/resources/device/schemas.py @@ -101,7 +101,7 @@ class Computer(Device): collection_class=OrderedSet, description='The components that are inside this computer.') chassis = EnumField(enums.ComputerChassis, - required=True, + required=False, description=m.Computer.chassis.comment) ram_size = Integer(dump_only=True, data_key='ramSize',