I'm trying to use ExcludeConstraint in my SQLAlchemy model:
class MyModel(db.Model):
some_string = Column(Unicode(length=20), nullable=True)
some_type = Column('some_type', Integer, nullable=False)
__table_args__ = (
ExcludeConstraint(
('some_string', '='), ('some_type', '<>'),
name='my_constraint'
),
)
But I've got an exception, when I run my test suite using temporary db:
E ProgrammingError: (psycopg2.ProgrammingError) data type character varying has no default operator class for access method "gist"
E HINT: You must specify an operator class for the index or define a default operator class for the data type.
Which means, that I have to execute CREATE EXTENTION btree_gist
before creating table. Can I do it somehow using SQLAlchemy? Any smarter way then manual SQL execute before creating temporary database for test suite?