@@ -328,6 +328,7 @@ class ApplicationEnvironment(Model, Timestamp):
328328 foreign_keys = "Ingress.application_environment_id" ,
329329 cascade = "all, delete-orphan" ,
330330 )
331+ alerts : Mapped [list [Alert ]] = relationship (back_populates = "application_environment" )
331332
332333 __table_args__ = (
333334 Index (
@@ -500,6 +501,7 @@ def __init__(self, *args, **kwargs):
500501 back_populates = "application" ,
501502 cascade = "all, delete-orphan" ,
502503 )
504+ alerts : Mapped [list [Alert ]] = relationship (back_populates = "application" )
503505
504506 @property
505507 def active_application_environments (self ):
@@ -1848,85 +1850,52 @@ class Alert(Model, Timestamp):
18481850 __versioned__ : dict = {}
18491851 __tablename__ = "alerts"
18501852
1851- id = db . Column (
1853+ id : Mapped [ uuid . UUID ] = mapped_column (
18521854 postgresql .UUID (as_uuid = True ),
18531855 server_default = text ("gen_random_uuid()" ),
1854- nullable = False ,
18551856 primary_key = True ,
18561857 )
1857- fingerprint = db .Column (
1858- db .String (256 ),
1859- nullable = False ,
1860- index = True ,
1861- )
1862- status = db .Column (
1863- db .String (32 ),
1864- nullable = False ,
1865- )
1866- alertname = db .Column (
1867- db .String (256 ),
1868- nullable = False ,
1869- index = True ,
1870- )
1871- labels = db .Column (
1872- postgresql .JSONB (),
1873- nullable = False ,
1874- )
1875- annotations = db .Column (
1876- postgresql .JSONB (),
1877- nullable = False ,
1878- server_default = text ("'{}'::jsonb" ),
1879- )
1880- starts_at = db .Column (
1881- db .DateTime ,
1882- nullable = False ,
1883- index = True ,
1884- )
1885- ends_at = db .Column (
1886- db .DateTime ,
1887- nullable = True ,
1888- )
1889- generator_url = db .Column (
1890- db .Text (),
1891- nullable = True ,
1892- )
1893- group_key = db .Column (
1894- db .Text (),
1895- nullable = True ,
1896- )
1897- receiver = db .Column (
1898- db .String (256 ),
1899- nullable = True ,
1858+ fingerprint : Mapped [str ] = mapped_column (String (256 ), index = True )
1859+ status : Mapped [str ] = mapped_column (String (32 ))
1860+ alertname : Mapped [str ] = mapped_column (String (256 ), index = True )
1861+ labels : Mapped [Any ] = mapped_column (postgresql .JSONB ())
1862+ annotations : Mapped [Any ] = mapped_column (
1863+ postgresql .JSONB (), server_default = text ("'{}'::jsonb" )
19001864 )
1901- application_id = db .Column (
1865+ starts_at : Mapped [datetime .datetime ] = mapped_column (DateTime , index = True )
1866+ ends_at : Mapped [datetime .datetime | None ] = mapped_column (DateTime )
1867+ generator_url : Mapped [str | None ] = mapped_column (Text ())
1868+ group_key : Mapped [str | None ] = mapped_column (Text ())
1869+ receiver : Mapped [str | None ] = mapped_column (String (256 ))
1870+ application_id : Mapped [uuid .UUID | None ] = mapped_column (
19021871 postgresql .UUID (as_uuid = True ),
1903- db .ForeignKey ("project_applications.id" ),
1904- nullable = True ,
1872+ ForeignKey ("project_applications.id" ),
19051873 index = True ,
19061874 )
1907- application_environment_id = db . Column (
1875+ application_environment_id : Mapped [ uuid . UUID | None ] = mapped_column (
19081876 postgresql .UUID (as_uuid = True ),
1909- db .ForeignKey ("application_environments.id" ),
1910- nullable = True ,
1877+ ForeignKey ("application_environments.id" ),
19111878 index = True ,
19121879 )
1913- version_id = db . Column ( db . Integer , nullable = False )
1880+ version_id : Mapped [ int ] = mapped_column ( Integer )
19141881
1915- application = db .relationship ("Application" , backref = "alerts" )
1916- application_environment = db .relationship (
1917- "ApplicationEnvironment" , backref = "alerts"
1882+ application : Mapped [Application | None ] = relationship (
1883+ back_populates = "alerts" ,
1884+ )
1885+ application_environment : Mapped [ApplicationEnvironment | None ] = relationship (
1886+ back_populates = "alerts" ,
19181887 )
19191888
19201889 __table_args__ = (
1921- db . Index (
1890+ Index (
19221891 "ix_alerts_fingerprint_status" ,
1923- fingerprint ,
1924- status ,
1892+ " fingerprint" ,
1893+ " status" ,
19251894 ),
1926- db . Index (
1895+ Index (
19271896 "ix_alerts_fingerprint_starts_at" ,
1928- fingerprint ,
1929- starts_at ,
1897+ " fingerprint" ,
1898+ " starts_at" ,
19301899 unique = True ,
19311900 ),
19321901 )
0 commit comments