-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add origin_network to Error model
- Loading branch information
Showing
2 changed files
with
13 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
from datetime import datetime | ||
|
||
from sqlalchemy import Column, Integer, ForeignKey, String, DateTime | ||
from sqlalchemy import Column, Integer, ForeignKeyConstraint, String, DateTime, Enum | ||
from sqlalchemy.orm import relationship, Mapped | ||
|
||
from config.database_config import Base | ||
from models.network import Network | ||
from models.order import Order | ||
|
||
|
||
class Error(Base): | ||
__tablename__ = "error" | ||
id: int = Column(Integer, primary_key=True, nullable=False) | ||
order_id: int = Column(Integer, ForeignKey("orders.order_id"), nullable=False) | ||
order_id: int = Column(Integer, nullable=False) | ||
origin_network: Network = Column(Enum(Network), nullable=False) | ||
order: Mapped[Order] = relationship("Order") | ||
message: str = Column(String, nullable=False) | ||
created_at: datetime = Column(DateTime, nullable=False, server_default="clock_timestamp()") | ||
|
||
# Set order_id and origin_network as composite foreign key | ||
__table_args__ = ( | ||
ForeignKeyConstraint( | ||
["order_id", "origin_network"], | ||
["orders.order_id", "orders.origin_network"] | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters