Files
PecHub/backend/alembic/versions/0013_add_scheduled_send.py
T
2026-03-27 20:59:06 +01:00

31 lines
704 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
Migrazione 0013: campo scheduled_at su send_jobs
(Feature 5 Invio differito).
"""
from alembic import op
import sqlalchemy as sa
revision = "0013"
down_revision = "0012"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.add_column(
"send_jobs",
sa.Column("scheduled_at", sa.DateTime(timezone=True), nullable=True),
)
op.create_index(
"idx_sendjobs_scheduled",
"send_jobs",
["scheduled_at"],
postgresql_where=sa.text("status = 'pending' AND scheduled_at IS NOT NULL"),
)
def downgrade() -> None:
op.drop_index("idx_sendjobs_scheduled", table_name="send_jobs")
op.drop_column("send_jobs", "scheduled_at")