Primary key unique constraint inherited on tanslation table
thanegill opened this issue · 0 comments
thanegill commented
When a model has a primary key unique constraint the child class translation table inherits this constraint, this then make the the translation table only able to hold one translation for each key.
Example:
class Message(Translatable, db.Model):
__translatable__ = {
'locales': ['en', 'es'],
'fallback_locale': 'en',
}
key = db.Column(db.String(64), primary_key=True, nullable=False, unique=True)
class MessageTranslation(translation_base(Message)):
__tablename__ = 'message_translation'
text = db.Column(db.UnicodeText)
for locale in ['en', 'es']:
message_translation = MessageTranslation(
key='example_key',
locale=locale,
text='text',
)
db.session.add(message_translation)