Coverage for app / db / postgres / mixin.py: 100%

32 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-10-31 11:23 +0000

1from sqlalchemy import Column, DateTime, ForeignKey 

2from sqlalchemy.dialects.postgresql import UUID 

3from app.util.time import aware_utcnow 

4 

5 

6class FKMixin: 

7 class Provider: 

8 provider_id = Column( 

9 UUID(as_uuid=True), 

10 ForeignKey("providers.id"), 

11 nullable=False, 

12 ) 

13 

14 class Child: 

15 provider_id = Column( 

16 UUID(as_uuid=True), 

17 ForeignKey("providers.id", ondelete="CASCADE"), 

18 nullable=False, 

19 ) 

20 

21 class LLMModel: 

22 model_id = Column( 

23 UUID(as_uuid=True), 

24 ForeignKey("llm_models.id"), 

25 nullable=False, 

26 ) 

27 

28 class Nullable: 

29 model_id = Column( 

30 UUID(as_uuid=True), 

31 ForeignKey("llm_models.id"), 

32 nullable=True, 

33 ) 

34 

35 class Child: 

36 model_id = Column( 

37 UUID(as_uuid=True), 

38 ForeignKey("llm_models.id", ondelete="CASCADE"), 

39 nullable=False, 

40 ) 

41 

42 class NullableChild: 

43 model_id = Column( 

44 UUID(as_uuid=True), 

45 ForeignKey("llm_models.id", ondelete="SET NULL"), 

46 nullable=True, 

47 ) 

48 

49 class Conversation: 

50 conversation_id = Column( 

51 UUID(as_uuid=True), 

52 ForeignKey("conversations.id"), 

53 nullable=False, 

54 ) 

55 

56 class Child: 

57 conversation_id = Column( 

58 UUID(as_uuid=True), 

59 ForeignKey("conversations.id", ondelete="CASCADE"), 

60 nullable=False, 

61 ) 

62 

63 class NullableChild: 

64 conversation_id = Column( 

65 UUID(as_uuid=True), 

66 ForeignKey("conversations.id", ondelete="SET NULL"), 

67 nullable=True, 

68 ) 

69 

70 class ToolInvocation: 

71 class Child: 

72 tool_invocation_id = Column( 

73 UUID(as_uuid=True), 

74 ForeignKey("tool_invocations.id", ondelete="CASCADE"), 

75 nullable=False, 

76 ) 

77 

78 

79class DateMixin: 

80 class Created: 

81 created_at = Column(DateTime, default=aware_utcnow) 

82 

83 class Updated(Created): 

84 updated_at = Column(DateTime, default=aware_utcnow, onupdate=aware_utcnow) 

85 

86 class Sent: 

87 sent_at = Column(DateTime, default=aware_utcnow)