Welcome! If you're reading this, you're probably running a legacy Redis-powered installation of shorty.
Don't worry, because migrating to Postgres is super easy; barely an inconvenience!
Before doing anything else, please update shorty to the latest commit. If running in Docker, pull the latest image from either cjdenio/shorty:latest
or ghcr.io/cjdenio/shorty:latest
.
That's it. You'll need to start a Postgres database before continuing migration.
REDIS_URL
should be set to your Redis datastore's URL. Please copy this over fromDB_URL
.DATABASE_URL
(orDB_URL
, they're identical) should be set to the Postgres database's URL. You probably already have this set to your Redis datastore's URL, so please change this.TOKEN
- if you haven't already set a token, please do that now. (more info in the README)
To run the migration, simply run the following API request in a terminal:
curl "http://<YOUR INSTANCE'S URL>/api/migrate" -H "Authorization: Bearer <YOUR TOKEN>"
The response should contain something like Successfully migrated 5 links from Redis to Postgres!
. If so, you're all set! 🎉
To verify that all links have been moved over, make a request to /api/link
:
curl "http://<YOUR INSTANCE'S URL>/api/link" -H "Authorization: Bearer <YOUR TOKEN>"
The output should contain all of your links.
You can now safely destroy your Redis database and unset the REDIS_URL
env var.