My web dev diary ๐Ÿ“”โœจ

Notes on my journey learning to code with Python & Django

Deployed PostgreSQL db to Vercel

AMartin1987 | Published on: Dec. 25, 2023, 9:59 p.m.

So, here I am after a few months of not writing on here... I spent some time working full-time at a beauty products store. Whenever I had a moment to rest, I found myself too tired to study ๐Ÿ˜…, so I ended up cleaning my house and playing Baldur's Gate 3 (GOTY, and Astarion, I LOVE YOU and your voice actor Neil Newbon SO MUCH).

Me with my beloved main crew ๐Ÿ’š I'm a Seldarine half-drow and Circle of the Moon Druid (and a follower of Selune).

 

Before my stint at the store, I managed to host my PostgreSQL on a free account with Railway. I even uploaded a lengthy post detailing the process of learning how to do that. Unfortunately, that post is now lost in the digital abyss since Railway decided to shift to a paid model, and my account, including the one hosting my database, became part of the paid plan ๐Ÿ™. To make matters worse, I hadn't locally backed up the last version of my database, which included that final entry.

Regardless, I successfully migrated my database to Vercel, which turned out to be a straightforward process. Although I can't recall all the challenges I faced during the migration, I distinctly remember that after creating a blank PostgreSQL database in Vercel, I used the following syntax in the psql CLI to upload my local database schema and its data to this blank database in Vercel:

pg_dump postgres://<user>:<pass>@<hostname>:5432/mydb | psql postgres://default:<secret>@<vercel_storage_host>:5432/verceldb

This syntax involves two components: 1) credentials corresponding to the source database (local mydb), and 2) credentials corresponding to the target database (myvercel db).

Next, I entered the environmental variables provided by Vercel into the settings.py file in my project (actually, into an .env file whose variables were referenced  by settings.py).

And that's the story of how you're reading this on the internet right now!

Well, today is December 25th, so Merry Christmas to all! ๐ŸŽ„๐Ÿฅณ

Ale ๐Ÿ’œ๐ŸŒฟ

Categories:

 

Videogames  

Python  

Django  

PostgreSQL  

About me
notByAI badge