-
-
Save johndiego/2b7d6b29385e2006b9f3d69724f1725d to your computer and use it in GitHub Desktop.
Flask SQLAlchemy multiple column unique constraint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ComponentCommit(db.Model): | |
__tablename__ = 'component_version' | |
__table_args__ = ( | |
db.UniqueConstraint('component_id', 'commit_id', name='unique_component_commit'), | |
) | |
id = db.Column(db.Integer, primary_key=True) | |
component_id = db.Column(db.Integer, db.ForeignKey("component.id")) | |
commit_id = db.Column(db.String) | |
branch = db.Column(db.String) | |
dependencies = db.Column(db.Text) | |
created_date = db.Column(db.DateTime, default=datetime.datetime.utcnow) | |
updated_date = db.Column(db.DateTime) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment