class Region(db.Model): __tablename__ = 'region' region_id = db.Column(db.Integer, primary_key=True) name = db.Column(db.VARCHAR) content = db.Column(db.VARCHAR) photo = db.Column(db.String) write_id = db.Column(db.Integer, db.ForeignKey('write.write_id')) destination = db.relationship('Destination', backref='destination_Region') attraction = db.relationship('Attraction', backref='attraction_Region') def __init__(self, name='', content='', photo='', write_id=''): self.name = name self.content = content self.photo = photo self.write_id = write_id
class Write(db.Model): __tablename__ = 'write' write_id = db.Column(db.Integer, primary_key=True) date = db.Column(db.DateTime, default=datetime.datetime.now()) author_id = db.Column(db.Integer, db.ForeignKey('user.id')) author_name = db.Column(db.VARCHAR) status = db.Column(db.VARCHAR) comment = db.Column(db.VARCHAR, nullable=True) region = db.relationship('Region', backref='region_Write') destination = db.relationship('Destination', backref='destination_Write') attraction = db.relationship('Attraction', backref='attraction_Write') def __init__(self, author_id='', author_name='', status=''): self.author_id = author_id self.author_name = author_name self.status = status
class User(db.Model): __tablename__ = 'user' id = db.Column(db.Integer(), primary_key=True) public_id = db.Column(db.String(50), unique=True) username = db.Column(db.String(32), unique=True, index=True) password_hash = db.Column(db.String(128)) firstname = db.Column(db.String(30)) middlename = db.Column(db.String(30)) lastname = db.Column(db.String(30)) age = db.Column(db.String(5)) contact = db.Column(db.String(15)) address = db.Column(db.TEXT()) birthday = db.Column(db.DATE) role_id = db.Column(db.String(2)) profile = db.Column(db.String(120)) write = db.relationship('Write', backref='write_User')