Spaces:
Sleeping

axeronis commited on
Commit
f0811af
·
1 Parent(s): abc13a7

fix: add is_blocked field to Lead model to fix hot leads scheduler error

Browse files
backend/alembic/versions/2025_12_25_add_is_blocked.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Add is_blocked field to leads table
2
+
3
+ Revision ID: add_is_blocked_field
4
+ Revises: 2025_12_25_add_image_urls
5
+ Create Date: 2025-12-25
6
+
7
+ """
8
+ from alembic import op
9
+ import sqlalchemy as sa
10
+
11
+
12
+ # revision identifiers, used by Alembic.
13
+ revision = 'add_is_blocked_field'
14
+ down_revision = '2025_12_25_add_image_urls'
15
+ branch_labels = None
16
+ depends_on = None
17
+
18
+
19
+ def upgrade():
20
+ # Add is_blocked column with default False
21
+ op.add_column('leads', sa.Column('is_blocked', sa.Boolean(), nullable=True, server_default='false'))
22
+
23
+ # Update existing rows to have False
24
+ op.execute("UPDATE leads SET is_blocked = false WHERE is_blocked IS NULL")
25
+
26
+ # Make it not nullable
27
+ op.alter_column('leads', 'is_blocked', nullable=False)
28
+
29
+
30
+ def downgrade():
31
+ op.drop_column('leads', 'is_blocked')
backend/app/models/lead.py CHANGED
@@ -98,6 +98,9 @@ class Lead(SQLModel, table=True):
98
  needs_attention: bool = Field(default=False)
99
  escalation_reason: Optional[str] = None # negative_sentiment, low_confidence, etc.
100
  escalation_at: Optional[datetime] = None
 
 
 
101
 
102
 
103
  # Timestamps
 
98
  needs_attention: bool = Field(default=False)
99
  escalation_reason: Optional[str] = None # negative_sentiment, low_confidence, etc.
100
  escalation_at: Optional[datetime] = None
101
+
102
+ # Blocking (spam, unsubscribed, etc.)
103
+ is_blocked: bool = Field(default=False)
104
 
105
 
106
  # Timestamps