class Build(db.Model): """ Table containing CI builds. Subclasses ``wptdash.app.db.Model`` """ __tablename__ = 'build' id = db.Column(db.Integer, primary_key=True) number = db.Column(db.Integer, nullable=False) pull_request_id = db.Column(db.Integer, db.ForeignKey('pull_request.id')) head_sha = db.Column(db.String, db.ForeignKey('commit.sha')) base_sha = db.Column(db.String, db.ForeignKey('commit.sha')) status = db.Column(db.Enum(BuildStatus), nullable=False) started_at = db.Column(db.TIMESTAMP()) finished_at = db.Column(db.TIMESTAMP()) jobs = db.relationship('Job', back_populates='build') pull_request = db.relationship('PullRequest', back_populates='builds') head_commit = db.relationship('Commit', foreign_keys=[head_sha], backref='builds_as_head') base_commit = db.relationship('Commit', foreign_keys=[base_sha], backref='builds_as_base')
class PullRequest(db.Model): """ Table containing GitHub Pull Requests. Subclasses ``wptdash.app.db.Model`` """ __tablename__ = 'pull_request' id = db.Column(db.Integer, primary_key=True) number = db.Column(db.Integer, nullable=False) title = db.Column(db.String, nullable=False) state = db.Column(db.Enum(PRStatus), nullable=False) head_sha = db.Column(db.String, db.ForeignKey('commit.sha'), nullable=False) base_sha = db.Column(db.String, db.ForeignKey('commit.sha'), nullable=False) head_repo_id = db.Column(db.Integer, db.ForeignKey('repository.id'), nullable=False) base_repo_id = db.Column(db.Integer, db.ForeignKey('repository.id'), nullable=False) head_branch = db.Column(db.String, nullable=False) base_branch = db.Column(db.String, nullable=False) created_by = db.Column(db.Integer, db.ForeignKey('github_user.id')) created_at = db.Column(db.TIMESTAMP(), nullable=False) merged = db.Column(db.Boolean, nullable=False) merged_by = db.Column(db.Integer, db.ForeignKey('github_user.id')) merged_at = db.Column(db.TIMESTAMP()) updated_at = db.Column(db.TIMESTAMP(), nullable=False) closed_at = db.Column(db.TIMESTAMP()) comment_url = db.Column(db.String) builds = db.relationship('Build', back_populates='pull_request') creator = db.relationship('GitHubUser', foreign_keys=[created_by], backref='pulls') merger = db.relationship('GitHubUser', foreign_keys=[merged_by], backref='merges') head_commit = db.relationship('Commit', foreign_keys=[head_sha], backref='pull_requests') base_commit = db.relationship('Commit', foreign_keys=[base_sha]) head_repository = db.relationship('Repository', foreign_keys=[head_repo_id], backref='pull_requests') base_repository = db.relationship('Repository', foreign_keys=[base_repo_id]) mirror = db.relationship('TestMirror', back_populates='pull_request', uselist=False, cascade='all, delete-orphan') watchers = db.relationship('GitHubUser', secondary=USER_PR, back_populates='prs_watching')
class StabilityStatus(db.Model): """ Table containing stability statuses for tests in jobs Subclasses ``wptdash.app.db.Model`` """ __tablename__ = 'stability_status' id = db.Column(db.Integer, primary_key=True) job_id = db.Column(db.Integer, nullable=False) test_id = db.Column(db.Text, nullable=False) status = db.Column(db.Enum(TestStatus), nullable=False) count = db.Column(db.Integer, nullable=False) db.ForeignKeyConstraint(['job_id', 'test_id'], ['job_result.job_id', 'job_result.test_id'])
class Job(db.Model): """ Table containing Travis build jobs. Subclasses ``wptdash.app.db.Model`` """ __tablename__ = 'job' id = db.Column(db.Integer, primary_key=True) number = db.Column(db.String) build_id = db.Column(db.Integer, db.ForeignKey('build.id'), nullable=False) product_id = db.Column(db.Integer, db.ForeignKey('product.id'), nullable=False) state = db.Column(db.Enum(JobStatus)) message = db.Column(db.Text) allow_failure = db.Column(db.Boolean, nullable=False) started_at = db.Column(db.TIMESTAMP()) finished_at = db.Column(db.TIMESTAMP()) build = db.relationship('Build', back_populates='jobs') product = db.relationship('Product', back_populates='jobs') tests = db.relationship('JobResult', back_populates='job')