bkyryliuk commented on a change in pull request #10605:
URL: 
https://github.com/apache/incubator-superset/pull/10605#discussion_r476647323



##########
File path: superset/models/alerts.py
##########
@@ -100,3 +119,187 @@ class AlertLog(Model):
     @property
     def duration(self) -> int:
         return (self.dttm_end - self.dttm_start).total_seconds()
+
+
+class Observer(Model):
+
+    __tablename__ = "alert_observers"
+
+    id = Column(Integer, primary_key=True)
+    name = Column(String(150), nullable=False)
+    observer_type = Column(Enum(AlertObserverType))
+    validation_type = Column(Enum(AlertValidationType))
+
+    @declared_attr
+    def alert_id(self) -> int:
+        return Column(Integer, ForeignKey("alerts.id"), nullable=False)
+
+    @declared_attr
+    def alert(self) -> RelationshipProperty:
+        return relationship(
+            "Alert",
+            foreign_keys=[self.alert_id],
+            backref=backref("alert_observers", cascade="all, delete-orphan"),
+        )
+
+    @declared_attr
+    def database_id(self) -> int:
+        return Column(Integer, ForeignKey("dbs.id"), nullable=False)
+
+    @declared_attr
+    def database(self) -> RelationshipProperty:
+        return relationship(
+            "Database",
+            foreign_keys=[self.database_id],
+            backref=backref("alert_observers", cascade="all, delete-orphan"),
+        )
+
+    __mapper_args__ = {
+        "polymorphic_identity": "base_observer",

Review comment:
       for this use case let's keep it simple for now and unify into a single 
SQLObserver
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to