feat: advanced RW sync system
This commit is contained in:
@@ -3,6 +3,7 @@ from .invoice import Invoice
|
||||
from .link_codes import LinkCode
|
||||
from .orders import Order, OrderAddon
|
||||
from .pricing import PricingConfig
|
||||
from .rw_sync_outbox import RWSyncOutbox
|
||||
from .service_notifications import ServiceNotification
|
||||
from .service_signatures import ServiceSignature
|
||||
from .sessions import Session
|
||||
@@ -19,6 +20,7 @@ __all__ = [
|
||||
"Order",
|
||||
"OrderAddon",
|
||||
"PricingConfig",
|
||||
"RWSyncOutbox",
|
||||
"ServiceNotification",
|
||||
"ServiceSignature",
|
||||
"Session",
|
||||
|
||||
34
db/models/rw_sync_outbox.py
Normal file
34
db/models/rw_sync_outbox.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from datetime import UTC, datetime
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from sqlalchemy import INTEGER, DateTime, ForeignKey
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from db.base import Base
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from db.models import Subscription
|
||||
|
||||
|
||||
class RWSyncOutbox(Base):
|
||||
__tablename__ = "rw_sync_outbox"
|
||||
|
||||
id: Mapped[int] = mapped_column(INTEGER, primary_key=True, autoincrement=True)
|
||||
subscription_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("subscriptions.id"), nullable=False, unique=True
|
||||
)
|
||||
revision: Mapped[int] = mapped_column(INTEGER, nullable=False, default=1)
|
||||
attempts: Mapped[int] = mapped_column(INTEGER, nullable=False, default=0)
|
||||
next_attempt_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)
|
||||
locked_until: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), nullable=False, default=lambda: datetime.now(UTC)
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True),
|
||||
nullable=False,
|
||||
default=lambda: datetime.now(UTC),
|
||||
onupdate=lambda: datetime.now(UTC),
|
||||
)
|
||||
|
||||
subscription: Mapped["Subscription"] = relationship("Subscription", lazy="selectin")
|
||||
Reference in New Issue
Block a user