<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nikolas Burk</title>
    <description>The latest articles on DEV Community by Nikolas Burk (@nikolasburk).</description>
    <link>https://dev.to/nikolasburk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F18151%2F24413af4-8896-4642-9157-18d553f35d37.jpg</url>
      <title>DEV Community: Nikolas Burk</title>
      <link>https://dev.to/nikolasburk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nikolasburk"/>
    <language>en</language>
    <item>
      <title>How to set up a free PostgreSQL database on Heroku</title>
      <dc:creator>Nikolas Burk</dc:creator>
      <pubDate>Wed, 26 Feb 2020 08:01:42 +0000</pubDate>
      <link>https://dev.to/prisma/how-to-setup-a-free-postgresql-database-on-heroku-1dc1</link>
      <guid>https://dev.to/prisma/how-to-setup-a-free-postgresql-database-on-heroku-1dc1</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;⚠️ &lt;strong&gt;Update&lt;/strong&gt;: Heroku does not offer hosting free PostgreSQL database any more. Instead, you can &lt;a href="https://dev.to/prisma/set-up-a-free-postgresql-database-on-supabase-to-use-with-prisma-3pk6"&gt;set up a PostgreSQL database for free with Supabase&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://heroku.com/" rel="noopener noreferrer"&gt;Heroku&lt;/a&gt; offers a free plan for hosting PostgreSQL databases. This can be handy if you're getting started with a new project or "just quickly need a hosted database" for experimentation or prototyping.&lt;/p&gt;

&lt;p&gt;This guide explains how to quickly setup a free PostgreSQL database on Heroku. You can learn more in the &lt;a href="https://devcenter.heroku.com/categories/heroku-postgres" rel="noopener noreferrer"&gt;Heroku Postgres documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  TLDR
&lt;/h2&gt;

&lt;p&gt;In order to create a new database on Heroku, you first need to create an &lt;strong&gt;app&lt;/strong&gt; in your personal dashboard. Then you can attach a &lt;strong&gt;Heroku Postgres&lt;/strong&gt; instance to it as a &lt;strong&gt;resource&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Log into Heroku
&lt;/h2&gt;

&lt;p&gt;Navigate your browser to &lt;a href="https://id.heroku.com/login" rel="noopener noreferrer"&gt;&lt;code&gt;https://id.heroku.com/login&lt;/code&gt;&lt;/a&gt; and log in. If you don't have an account yet, you can sign up via the &lt;strong&gt;Sign Up&lt;/strong&gt; button below the login form:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2F8zSjKZI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2F8zSjKZI.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Create a new Heroku app
&lt;/h2&gt;

&lt;p&gt;Once you see your personal app dashboard, you can create a new app. If your dashboard is currently empty, you can click the &lt;strong&gt;Create new app&lt;/strong&gt; button. Otherwise click the &lt;strong&gt;New&lt;/strong&gt; button in the top-right corner and select &lt;strong&gt;Create new app&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2FJnnlOzl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2FJnnlOzl.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since you only need the app to get access to your database, the &lt;strong&gt;App name&lt;/strong&gt; doesn't really matter and you can choose whatever you want. In the screenshot below, &lt;strong&gt;&lt;code&gt;get-my-db&lt;/code&gt;&lt;/strong&gt; is used as an &lt;strong&gt;App name&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2FYnscakp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2FYnscakp.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want, you can also change the &lt;strong&gt;Region&lt;/strong&gt; so that the database is hosted closer to where you are located.&lt;/p&gt;

&lt;p&gt;Once you've provided the &lt;strong&gt;App name&lt;/strong&gt;, you can click the &lt;strong&gt;Create app&lt;/strong&gt; button.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Add a PostreSQL database
&lt;/h2&gt;

&lt;p&gt;To attach a PostgreSQL database to the app you just created, you need to navigate to the &lt;strong&gt;Resources&lt;/strong&gt; tab in the header of your newly created app's dahsboard. Then type &lt;strong&gt;Heroku Postgres&lt;/strong&gt; into the &lt;strong&gt;Add-ons&lt;/strong&gt; search field.&lt;/p&gt;

&lt;p&gt;When shown, select the suggested &lt;strong&gt;Heroku Postgres&lt;/strong&gt; add-on from the dropdown:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2Fo5w5st7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2Fo5w5st7.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The next popup asks you to choose a pricing plan for the database. Select the &lt;strong&gt;Hobby Dev - Free&lt;/strong&gt; plan and click &lt;strong&gt;Provision&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2FsKS1b3m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2FsKS1b3m.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations, you now created a free PostgreSQL database 🎊&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Access the database credentials (and connection URL)
&lt;/h2&gt;

&lt;p&gt;To find the credentials and the connection URL for the PostgreSQL database, you need to navigate to the &lt;strong&gt;Resources&lt;/strong&gt; tab in your app's dashboard again and select the &lt;strong&gt;Heroku Postgres&lt;/strong&gt; resource:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2Fm9d07zx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2Fm9d07zx.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This brings you to the configuration screen of the your PostgreSQL database:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2FdfH6svo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2FdfH6svo.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now select the &lt;strong&gt;Settings&lt;/strong&gt; tab in the header of that screen:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2F0nI2Exv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2F0nI2Exv.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, you can click the &lt;strong&gt;View Credentials&lt;/strong&gt; button to see the credentials of your PostgreSQL database:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2Fu2JmtXU.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2Fu2JmtXU.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can use these credentials to connect to your PostgreSQL database from any PostgreSQL client, e.g. &lt;a href="https://www.postgresql.org/docs/9.3/app-psql.html" rel="noopener noreferrer"&gt;&lt;code&gt;psql&lt;/code&gt;&lt;/a&gt; (CLI), &lt;a href="https://tableplus.com/" rel="noopener noreferrer"&gt;TablePlus&lt;/a&gt; or &lt;a href="https://eggerapps.at/postico/" rel="noopener noreferrer"&gt;Postico&lt;/a&gt; (GUIs).&lt;/p&gt;

&lt;p&gt;For further reading, you can check out the &lt;a href="https://devcenter.heroku.com/categories/heroku-postgres" rel="noopener noreferrer"&gt;Heroku Postgres documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you want to use this database in a Node.js or TypeScript application, be sure to check out &lt;a href="https://github.com/prisma/prisma2" rel="noopener noreferrer"&gt;Prisma&lt;/a&gt; as an alternative to traditional ORMs. Get started with Prisma &lt;a href="https://pris.ly/d/getting-started" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>heroku</category>
      <category>database</category>
      <category>sql</category>
    </item>
  </channel>
</rss>
