Profile picture Schedule a Meeting
c a n d l a n d . n e t

Setup Postgres with pgvector on Dokku

Dusty Candland | | postgres, pgvector, dokku, route285

I'm starting to experiment with AI on Route285 and need a vector database. Since I'm already using Postgres and Dokku, I'm adding pgvector. Pgvector isn't installed by the main Postgres images.

  1. Install a new version of Postgres with pgvector. Pgvector Docker Image
  2. Migrate the data to the new instance.
  3. Switch the app to the new instance.
  4. Connect and install pgvector.

Setup Postgres with pgvector

Creates a new service using the pgvector docker image.

dokku postgres:create route285-db-15 --image "ankane/pgvector" --image-version "v0.4.4"

Migrate to the new database

Migration process from Upgrade service to the specified versions

dokku ps:stop route285-cms

dokku postgres:export route285-db > route285-db.sql

dokku postgres:import route285-db-15 < route285-db.sql

dokku postgres:unlink route285-db route285-cms
-----> Unsetting DATABASE_URL

dokku postgres:link route285-db-15 route285-cms
-----> Setting config vars
       DATABASE_URL:  postgres://postgres...

dokku ps:start route285-cms

Install the pgvector extension

Connect to the new database.

dokku postgres:connect route285-db-15

Install the extension. Also make sure the imported data looks good.

route285_db_15=# CREATE EXTENSION vector;
CREATE EXTENSION

Cleanup

dokku postgres:stop route285-db
dokku postgres:delete route285-db

References

Webmentions

These are webmentions via the IndieWeb and webmention.io. Mention this post from your site: