Add db migration and DNS dmarc entries
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
"""add domain dns snapshots
|
||||
|
||||
Revision ID: 20260520_0001
|
||||
Revises:
|
||||
Create Date: 2026-05-20 00:00:00.000000+00:00
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision = "20260520_0001"
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def _domain_dns_snapshots() -> sa.Table:
|
||||
return sa.Table(
|
||||
"domain_dns_snapshots",
|
||||
sa.MetaData(),
|
||||
sa.Column("id", sa.Integer(), primary_key=True),
|
||||
sa.Column("domain", sa.String(length=255), nullable=False),
|
||||
sa.Column("checked_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("dmarc_record", sa.Text(), nullable=True),
|
||||
sa.Column("dmarc_policy_p", sa.String(length=40), nullable=True),
|
||||
sa.Column("dmarc_policy_sp", sa.String(length=40), nullable=True),
|
||||
sa.Column("dmarc_policy_pct", sa.Integer(), nullable=True),
|
||||
sa.Column("dmarc_adkim", sa.String(length=20), nullable=True),
|
||||
sa.Column("dmarc_aspf", sa.String(length=20), nullable=True),
|
||||
sa.Column("dmarc_fo", sa.String(length=80), nullable=True),
|
||||
sa.Column("dmarc_rua", sa.Text(), nullable=True),
|
||||
sa.Column("dmarc_ruf", sa.Text(), nullable=True),
|
||||
sa.Column("spf_record", sa.Text(), nullable=True),
|
||||
sa.Column("spf_all", sa.String(length=20), nullable=True),
|
||||
sa.Column("spf_includes_json", sa.Text(), nullable=False, server_default="[]"),
|
||||
sa.Column("dkim_records_json", sa.Text(), nullable=False, server_default="[]"),
|
||||
sa.Column("mx_records_json", sa.Text(), nullable=False, server_default="[]"),
|
||||
sa.Column("errors_json", sa.Text(), nullable=False, server_default="[]"),
|
||||
)
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
table = _domain_dns_snapshots()
|
||||
table.create(bind=bind, checkfirst=True)
|
||||
op.create_index(
|
||||
op.f("ix_domain_dns_snapshots_checked_at"),
|
||||
"domain_dns_snapshots",
|
||||
["checked_at"],
|
||||
unique=False,
|
||||
if_not_exists=True,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_domain_dns_snapshots_domain"),
|
||||
"domain_dns_snapshots",
|
||||
["domain"],
|
||||
unique=False,
|
||||
if_not_exists=True,
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index(op.f("ix_domain_dns_snapshots_domain"), table_name="domain_dns_snapshots", if_exists=True)
|
||||
op.drop_index(op.f("ix_domain_dns_snapshots_checked_at"), table_name="domain_dns_snapshots", if_exists=True)
|
||||
_domain_dns_snapshots().drop(bind=op.get_bind(), checkfirst=True)
|
||||
Reference in New Issue
Block a user