<@ULVA73B9P> How do I upgrade from the default SQL...
# ask-marvin
m
@Marvin How do I upgrade from the default SQLite DB to Postgres as seamlessly as possible?
m
To upgrade from the default SQLite database to PostgreSQL in Prefect 3.x, follow these steps: 1. Install PostgreSQL: Ensure you have PostgreSQL installed and running. Create a new database for Prefect. 2. Configure Prefect to Use PostgreSQL: - Modify your Prefect configuration to point to your PostgreSQL database. You can set the connection string in your environment variables or Prefect profile. For example:
Copy code
bash
     export PREFECT_API_DATABASE_CONNECTION_URL="<postgresql+asyncpg://user:password@localhost/prefect_db>"
3. Migrate the Database: - Prefect uses Alembic for database migrations. Run the migration commands to set up your PostgreSQL database schema:
Copy code
bash
     prefect database upgrade
4. Transfer Data: - You'll need to manually transfer your data from SQLite to PostgreSQL. This may involve exporting data from SQLite and importing it into PostgreSQL using tools like
pgloader
or custom scripts. 5. Verify Configuration: - Ensure your Prefect server is running with the new configuration and test your flows to confirm everything is working as expected. For more detailed instructions and considerations, you can refer to the Prefect self-hosting documentation. Keep in mind that Prefect 3.x has some changes from previous versions, such as replacing agents with workers and using pydantic 2. Ensure your setup is compatible with these changes. More gotchas can be found here.
m
@Marvin Which version of postgreSQL is fit for prefect 3?
m
Prefect 3.x does not specify a particular version of PostgreSQL, but it is compatible with the latest versions of PostgreSQL. When setting up PostgreSQL for Prefect, ensure that you use an async driver, such as
postgresql+asyncpg
, for compatibility. You can start a PostgreSQL instance using the latest version of the official PostgreSQL Docker image, which is confirmed to be compatible. For more details, you can refer to the self-hosting guide.