# HG changeset patch # User Mads Kiilerich # Date 1452007812 -3600 # Node ID b9f4b444a17231476b216d0b2dc444231452dd2f # Parent 83f7b5449860d8ee235e1bc0f311b43a11c2b73f db: fix uniqueness constraint on the Ui table; it is on the composite key of section and key diff -r 83f7b5449860 -r b9f4b444a172 kallithea/model/db.py --- a/kallithea/model/db.py Tue Jan 05 16:30:12 2016 +0100 +++ b/kallithea/model/db.py Tue Jan 05 16:30:12 2016 +0100 @@ -331,7 +331,10 @@ class Ui(Base, BaseModel): __tablename__ = DB_PREFIX + 'ui' __table_args__ = ( + # FIXME: ui_key as key is wrong and should be removed when the corresponding + # Ui.get_by_key has been replaced by the composite key UniqueConstraint('ui_key'), + UniqueConstraint('ui_section', 'ui_key'), _table_args_default_dict, ) @@ -348,11 +351,6 @@ ui_value = Column(String(255), nullable=True, unique=None, default=None) ui_active = Column(Boolean(), nullable=True, unique=None, default=True) - # def __init__(self, section='', key='', value=''): - # self.ui_section = section - # self.ui_key = key - # self.ui_value = value - @classmethod def get_by_key(cls, key): return cls.query().filter(cls.ui_key == key).scalar()