fix: use default instead of default_factory for UUID mixin
SQLAlchemy requires MappedAsDataclass for default_factory. Also adds docker-compose with postgres and redis for local dev.
This commit is contained in:
parent
0eaf70d87f
commit
ab963028d5
29
docker-compose.yml
Normal file
29
docker-compose.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:16-alpine
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: proxypool
|
||||||
|
POSTGRES_USER: proxypool
|
||||||
|
POSTGRES_PASSWORD: proxypool
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
volumes:
|
||||||
|
- pg_data:/var/lib/postgresql/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U proxypool"]
|
||||||
|
interval: 2s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:7-alpine
|
||||||
|
ports:
|
||||||
|
- "6379:6379"
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "redis-cli", "ping"]
|
||||||
|
interval: 2s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
pg_data:
|
||||||
@ -12,7 +12,7 @@ class Base(DeclarativeBase):
|
|||||||
class UUIDPrimaryKeyMixin:
|
class UUIDPrimaryKeyMixin:
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(
|
||||||
primary_key=True,
|
primary_key=True,
|
||||||
default_factory=uuid.uuid4,
|
default=uuid.uuid4,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -45,6 +45,7 @@ class ProxySource(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
|||||||
cron_schedule: Mapped[str | None] = mapped_column(String(64))
|
cron_schedule: Mapped[str | None] = mapped_column(String(64))
|
||||||
default_protocol: Mapped[ProxyProtocol] = mapped_column(
|
default_protocol: Mapped[ProxyProtocol] = mapped_column(
|
||||||
ENUM(ProxyProtocol, name="proxy_protocol"),
|
ENUM(ProxyProtocol, name="proxy_protocol"),
|
||||||
|
default=ProxyProtocol.HTTP,
|
||||||
)
|
)
|
||||||
is_active: Mapped[bool] = mapped_column(default=True)
|
is_active: Mapped[bool] = mapped_column(default=True)
|
||||||
last_scraped_at: Mapped[datetime | None] = mapped_column()
|
last_scraped_at: Mapped[datetime | None] = mapped_column()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user