Created
June 22, 2016 12:18
-
-
Save UltraBob/c74f75c0e36427856ab78f530fc89d4c to your computer and use it in GitHub Desktop.
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
company_technologies = db.Table('company_technologies', | |
db.Column('company_id', db.Integer, db.ForeignKey('companies.id')), | |
db.Column('technology_id', db.Integer, db.ForeignKey('technologies.id')) | |
) | |
class Technology(db.Model): | |
__tablename__ = 'technologies' | |
id = db.Column(db.Integer, primary_key=True) | |
name = db.Column(db.String(128), index=True) | |
parent_id = db.Column(db.Integer, default=None, nullable=True, index=True) | |
class Company(db.Model): | |
__tablename__ = 'companies' | |
id = db.Column(db.Integer, primary_key=True) | |
name = db.Column(db.String(128), unique=True, index=True) | |
technologies = db.relationship('Technology', | |
secondary=company_technologies, | |
backref=db.backref('technologies', lazy='dynamic'), | |
lazy='dynamic') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment