Created
May 14, 2018 16:21
-
-
Save asyd/3cff61ed09eabe187d3fbec2c8a3ee39 to your computer and use it in GitHub Desktop.
Flask SQLAlchemy multiple column unique constraint
This file contains 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