from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() class TwitterAccount(db.Model): __tablename__ = 'twitter_account' id = db.Column(db.String(36), primary_key=True) user_id = db.Column(db.String(64), nullable=False) twitter_account_id = db.Column(db.String(32), nullable=False) username = db.Column(db.String(16), nullable=False) access_token = db.Column(db.String(256), nullable=False) access_token_secret = db.Column(db.String(256), nullable=False) class TwitterCampaign(db.Model): __tablename__ = 'twitter_campaign' id = db.Column(db.String(36), primary_key=True) user_id = db.Column(db.String(64), nullable=False) campaign_name = db.Column(db.String(64), nullable=False) twitter_account_id = db.Column(db.String(32), nullable=False) user_input = db.Column(db.String(100), nullable=False) posts = db.relationship('TwitterPost', backref='campaign', lazy=True) class TwitterPost(db.Model): __tablename__ = 'twitter_post' id = db.Column(db.String(36), primary_key=True) campaign_id = db.Column(db.String(36), db.ForeignKey(TwitterCampaign.id), nullable=False) user_id = db.Column(db.String(64), nullable=False) post_content = db.Column(db.String(300), nullable=False) twitter_post_id = db.Column(db.String(32), unique=True, nullable=False)