nullable chassis

This commit is contained in:
Cayo Puigdefabregas 2020-12-16 11:57:51 +01:00
parent 48d866b2d5
commit 349170aa99
3 changed files with 37 additions and 2 deletions

View File

@ -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

View File

@ -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.

View File

@ -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',