I have two fields:
class Person(base):
     field1 = Column(String(32), unique=True, nullable=True)
     field2 = Column(String(128), unique=True, nullable=True)
     field3 = ...
     ...
I need to create a constraint, to check if at least one of [field1, field2] is available.  I guess I need to use CheckConstraint, but I failed to get a result.  Any ideas?
Thanks to this post:
__table_args__ = (
        CheckConstraint('NOT(field1 IS NULL AND field2 IS NULL)'),
        )
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With