2021-04-21 16:47:18 +00:00
|
|
|
"""
|
|
|
|
This module defines the Alert database class.
|
|
|
|
"""
|
|
|
|
|
2021-05-07 17:46:14 +00:00
|
|
|
from ..base import ext
|
2021-04-21 16:47:18 +00:00
|
|
|
|
|
|
|
|
2021-05-07 17:46:14 +00:00
|
|
|
class Alert(ext.Model):
|
2021-04-21 16:47:18 +00:00
|
|
|
__tablename__ = "alert"
|
2021-05-07 17:46:14 +00:00
|
|
|
id = ext.Column(ext.Integer, primary_key=True)
|
|
|
|
name = ext.Column(ext.String, nullable=False)
|
|
|
|
limit = ext.Column(ext.Integer, nullable=False)
|
|
|
|
window_size = ext.Column(ext.Integer, nullable=False)
|
2021-04-21 16:47:18 +00:00
|
|
|
# Foreign Keys
|
2021-05-07 17:46:14 +00:00
|
|
|
repository_id = ext.Column(ext.Integer, ext.ForeignKey("repository.id", ondelete="CASCADE"), nullable=False)
|
2021-04-21 16:47:18 +00:00
|
|
|
# Relationships
|
2021-05-07 17:46:14 +00:00
|
|
|
repository = ext.relationship("Repository", back_populates="alerts")
|
|
|
|
notifications = ext.relationship("Notification", back_populates="alert", cascade="all, delete")
|
|
|
|
operations = ext.relationship("BoolOperation", back_populates="alert", cascade="all, delete")
|