Hui Wu
04/08/2026, 11:10 AMMarvin
04/08/2026, 11:10 AMMarvin
04/08/2026, 11:14 AMpip install "prefect[redis]"
- Docs
- Prefect Redis integration overview and install: https://docs.prefect.io/integrations/prefect-redis/
- Self-hosted architecture (where Redis is needed): https://docs.prefect.io/v3/advanced/self-hosted/
Quick check
- If you’re on Redis 5.x: core Streams-based features work, but some niceties (like XAUTOCLAIM) are only in 6.2+.
- If you’re starting fresh: use Redis 7.x.
If you can share whether you’re using Prefect Cloud or self-hosting (and which features you plan to use), I can confirm whether Redis is needed at all and pin a precise version recommendation.Hui Wu
04/08/2026, 11:20 AMMarvin
04/08/2026, 11:20 AMMarvin
04/08/2026, 11:24 AMexport PREFECT_API_DATABASE_CONNECTION_URL="<postgresql+asyncpg://user:password@host:5432/prefect>"
- Settings reference (includes all DB settings and TLS/connect args): https://docs.prefect.io/v3/api-ref/settings-ref
Managing the schema without running Alembic directly
Manual “hand-written” table creation is not supported and will lead to schema drift. Instead, if you cannot execute Alembic in your environment, generate the SQL from Prefect’s CLI and run it yourself, then stamp the DB so Prefect knows the migration state.
1) Generate SQL for the current head without applying it
prefect server database upgrade --dry-run -y > prefect_migrations.sql
- This emits the exact SQL Alembic would run (CREATE TABLEs, indexes, etc.).
- You can review or modify this file if your environment requires it.
2) Apply the SQL to PostgreSQL yourself
psql "host=... port=5432 dbname=prefect user=... password=..." -f prefect_migrations.sql
- Ensure your DB user has privileges to CREATE/ALTER/DROP tables, indexes, and sequences.
3) Stamp the database to mark migrations as applied
prefect server database stamp head
- This writes the appropriate row to the alembic_version table so Prefect won’t try to re-apply the same migrations later.
Helpful CLI commands (verified)
- Upgrade (applies migrations automatically if you can run Alembic):
prefect server database upgrade -y
Use --dry-run to inspect SQL first.
- Reset (drop and recreate everything):
prefect server database reset -y
- Stamp a revision (after manual SQL apply):
prefect server database stamp head
- If you’re running multiple API servers, disable auto-migrations on start and run them once, separately:
export PREFECT_API_DATABASE_MIGRATE_ON_START=false
Operational tips
- Long migrations on big tables can time out; increase timeout:
export PREFECT_API_DATABASE_TIMEOUT=600
- If you use a connection pooler like PgBouncer (transaction mode), set asyncpg’s statement cache to 0 via connect args. See the settings reference for SQLAlchemy connect args.
Links
- Self-hosted architecture and requirements: https://docs.prefect.io/v3/advanced/self-hosted/
- Settings reference (DB URL, SQLAlchemy, TLS, timeouts): https://docs.prefect.io/v3/api-ref/settings-ref
If you can share what’s preventing Alembic from running (error message, environment constraints), I can tailor the exact offline/SQL approach for your setup and confirm any additional steps you’ll need. Are you running a single server or a multi-server (HA) deployment?