30 lines
1.4 KiB
Python
30 lines
1.4 KiB
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, Integer, String
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.auth_db import AuthBase
|
|
|
|
|
|
class PublicIPState(AuthBase):
|
|
__tablename__ = "public_ip_state"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
current_ipv4: Mapped[str] = mapped_column(String(45), nullable=False)
|
|
previous_ipv4: Mapped[str | None] = mapped_column(String(45), nullable=True)
|
|
first_seen_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)
|
|
last_checked_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)
|
|
last_changed_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
|
last_check_status: Mapped[str] = mapped_column(String(32), nullable=False)
|
|
last_check_error: Mapped[str | None] = mapped_column(String(255), nullable=True)
|
|
last_provider: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
|
|
|
|
|
class PublicIPHistory(AuthBase):
|
|
__tablename__ = "public_ip_history"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
ipv4: Mapped[str] = mapped_column(String(45), nullable=False)
|
|
observed_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)
|
|
change_type: Mapped[str] = mapped_column(String(32), nullable=False)
|
|
provider: Mapped[str | None] = mapped_column(String(64), nullable=True) |