Using pgvector in dokku (migrating from vanilla Postgres)

Thought I’d share this cool snipped as it’s really easy to migrate from “vanilla” Postgres to pgvector in dokku:

# Create pgvector db
dokku postgres:create your-new-db-name --image "pgvector/pgvector" --image-version "pg17"

# Export data of current db
dokku postgres:export your-old-db-name > backup.pgsql

# Import data into pgvector db
dokku postgres:import your-new-db-name < backup.pgsql

# Stop container
dokku ps:stop your-app-name

# Unlink old db, link pgvector db
dokku postgres:unlink your-old-db-name your-app-name
dokku postgres:link your-new-db-name your-app-name

# Start container again
dokku ps:start your-app-name

And that’s all there is. The only step causing downtime here is stopping the container to link it to the new db. The actual copying of data is done before that, so this is a very-low-downtime change which is very, very cool.

Dokku is magic. You should use it.

Leave a Reply

Your email address will not be published. Required fields are marked *