| 32 | from sqlalchemy.orm import DeclarativeBase, Mapped, declared_attr, mapped_column |
32 | from sqlalchemy.orm import DeclarativeBase, Mapped, declared_attr, mapped_column |
| 33 | from sqlalchemy.types import JSON |
33 | from sqlalchemy.types import JSON |
| 34 | |
34 | |
| |
35 | +import socket |
| |
36 | + |
| 35 | from src.config import REQUIRED_NODE |
37 | from src.config import REQUIRED_NODE |
| 36 | |
38 | |
| |
39 | +CURRENT_NODE = REQUIRED_NODE or socket.gethostname().split(".")[0].lower() |
| |
40 | + |
| 37 | # BIGSERIAL sur PostgreSQL ; INTEGER auto-incrémenté en dev SQLite. |
41 | # BIGSERIAL sur PostgreSQL ; INTEGER auto-incrémenté en dev SQLite. |
| 38 | BigIntPK = BigInteger().with_variant(Integer(), "sqlite") |
42 | BigIntPK = BigInteger().with_variant(Integer(), "sqlite") |
| 39 | # JSONB sur PostgreSQL ; JSON générique en dev SQLite. |
43 | # JSONB sur PostgreSQL ; JSON générique en dev SQLite. |
| 170 | records_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0) |
174 | records_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0) |
| 171 | duration_seconds: Mapped[float] = mapped_column(Float, nullable=False, default=0.0) |
175 | duration_seconds: Mapped[float] = mapped_column(Float, nullable=False, default=0.0) |
| 172 | error_message: Mapped[str | None] = mapped_column(Text, nullable=True) |
176 | error_message: Mapped[str | None] = mapped_column(Text, nullable=True) |
| 173 | − node: Mapped[str] = mapped_column(Text, nullable=False, default=REQUIRED_NODE) |
177 | + node: Mapped[str] = mapped_column(Text, nullable=False, default=CURRENT_NODE) |
| 174 | started_at: Mapped[datetime.datetime] = mapped_column( |
178 | started_at: Mapped[datetime.datetime] = mapped_column( |
| 175 | DateTime(timezone=True), nullable=False |
179 | DateTime(timezone=True), nullable=False |
| 176 | ) |
180 | ) |
| 177 | |
181 | |