Index: lnt/server/db/migrations/upgrade_12_to_13.py =================================================================== --- /dev/null +++ lnt/server/db/migrations/upgrade_12_to_13.py @@ -0,0 +1,18 @@ +# Version 12 drops the info_key column as it is unused now. +import sqlalchemy + +def upgrade(engine): + # Create a session. + session = sqlalchemy.orm.sessionmaker(engine)() + + # We do not convert names anymore when importing/exporting. + # So the info_keys only live in lnt.testing.upgrade_1_to_2() when upgrading + # older reports. + if engine.dialect.name != 'sqlite': # sqlite cannot DROP COLUMNs :-( + session.connection().execute(""" +ALTER TABLE TestSuiteMachineFields DROP COLUMN info_key; +ALTER TABLE TestSuiteOrderFields DROP COLUMN info_key; +ALTER TABLE TestSuiteRunFields DROP COLUMN info_key; +ALTER TABLE TestSuiteSampleFields DROP COLUMN info_key; + """) + session.commit() Index: lnt/server/db/testsuite.py =================================================================== --- lnt/server/db/testsuite.py +++ lnt/server/db/testsuite.py @@ -98,21 +98,15 @@ index=True) name = Column("Name", String(256)) - # The info key describes the key to expect this field to be present as in - # the reported machine information. Missing keys result in NULL values in - # the database. - info_key = Column("InfoKey", String(256)) - - def __init__(self, name, info_key): + def __init__(self, name): self.name = name - self.info_key = info_key # Column instance for fields which have been bound (non-DB # parameter). This is provided for convenience in querying. self.column = None def __repr__(self): - return '%s%r' % (self.__class__.__name__, (self.name, self.info_key)) + return '%s%r' % (self.__class__.__name__, self.name) class OrderField(FieldMixin, Base): __tablename__ = 'TestSuiteOrderFields' @@ -122,20 +116,14 @@ index=True) name = Column("Name", String(256)) - # The info key describes the key to expect this field to be present as in - # the reported machine information. Missing keys result in NULL values in - # the database. - info_key = Column("InfoKey", String(256)) - # The ordinal index this field should be used at for creating a # lexicographic ordering amongst runs. ordinal = Column("Ordinal", Integer) - def __init__(self, name, info_key, ordinal): + def __init__(self, name, ordinal): assert isinstance(ordinal, int) and ordinal >= 0 self.name = name - self.info_key = info_key self.ordinal = ordinal # Column instance for fields which have been bound (non-DB @@ -143,8 +131,7 @@ self.column = None def __repr__(self): - return '%s%r' % (self.__class__.__name__, (self.name, self.info_key, - self.ordinal)) + return '%s%r' % (self.__class__.__name__, (self.name, self.ordinal)) class RunField(FieldMixin, Base): __tablename__ = 'TestSuiteRunFields' @@ -154,21 +141,15 @@ index=True) name = Column("Name", String(256)) - # The info key describes the key to expect this field to be present as in - # the reported machine information. Missing keys result in NULL values in - # the database. - info_key = Column("InfoKey", String(256)) - - def __init__(self, name, info_key): + def __init__(self, name): self.name = name - self.info_key = info_key # Column instance for fields which have been bound (non-DB # parameter). This is provided for convenience in querying. self.column = None def __repr__(self): - return '%s%r' % (self.__class__.__name__, (self.name, self.info_key)) + return '%s%r' % (self.__class__.__name__, self.name) class SampleField(FieldMixin, Base): __tablename__ = 'TestSuiteSampleFields' @@ -182,11 +163,6 @@ type_id = Column("Type", Integer, ForeignKey('SampleType.ID')) type = relation(SampleType) - # The info key describes the key to expect this field to be present as in - # the reported machine information. Missing keys result in NULL values in - # the database. - info_key = Column("InfoKey", String(256)) - # The status field is used to create a relation to the sample field that # reports the status (pass/fail/etc.) code related to this value. This # association is used by UI code to present the two status fields together. @@ -198,11 +174,10 @@ # This assumption can be inverted by setting this column to nonzero. bigger_is_better = Column("bigger_is_better", Integer) - def __init__(self, name, type, info_key, status_field = None, + def __init__(self, name, type, status_field = None, bigger_is_better = 0): self.name = name self.type = type - self.info_key = info_key self.status_field = status_field self.bigger_is_better = bigger_is_better @@ -214,5 +189,4 @@ self.column = None def __repr__(self): - return '%s%r' % (self.__class__.__name__, (self.name, self.type, - self.info_key)) + return '%s%r' % (self.__class__.__name__, (self.name, self.type))