Skip to content

Commit de3699d

Browse files
committed
index on table_args rather than uniqueconstraint
1 parent a43c325 commit de3699d

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

omnipath_metabo/schema/_structure.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
Numeric,
1010
Index,
1111
UniqueConstraint,
12+
func
1213
)
1314
from sqlalchemy.orm import relationship
1415
from ._base import Base
@@ -26,19 +27,15 @@ class Structure(Base):
2627
id = Column(Integer, primary_key = True)
2728
name = Column(String)
2829
smiles = Column(String)
29-
inchi = Column(String(4096), unique = True)
30+
inchi = Column(String(4096), unique= True)
3031
mol = Column(MolType)
3132
identifier = relationship(
3233
'Identifier',
3334
backref='structure',
3435
foreign_keys='Identifier.structure_id'
3536
)
3637
__table_args__ = (
37-
UniqueConstraint(
38-
'inchi',
39-
name = 'uq_inchi',
40-
postgresql_using = 'hash' # Specify the index type here
41-
),
38+
Index('inchi_large_index', func.md5(inchi), unique=True ),
4239
)
4340

4441

0 commit comments

Comments
 (0)