deployment-docs

Django (PP4) : Migrating your data

Migrating your data from Heroku to ElephantSQL.


Now that you have a new blank database set up in ElephantSQL, we’ll run a program to copy your data from Heroku into it.

Process

  1. Navigate to the Postgres Migration Tool repo on GitHub in a new browser tab

    the Heroku to render GitHub repo page

  2. Click the Gitpod button to open a new workspace

    Gitpod button

  3. Run the script with the following command in the terminal

     python3 reel2reel.py
    
  4. In a different browser tab, go to your app in Heroku and select the Settings tab

    the settings tab on the Heroku app

  5. Click the “Reveal Config Vars” button

    reveal config vars button

  6. Copy the value in the DATABASE_URL Config Var. It will start with postgres://

    database url config var

  7. Return to Gitpod and paste in the URL you just copied into the terminal where prompted to provide your DATABASE_URL and click enter

    reel2reel running in a terminal with one input for a database url

  8. In your original browser tab, get your ElephantSQL database URL. Again, it will start with postgres://

    the details page of a database instance with the URL available to copy

  9. Return to Gitpod and paste in the URL where prompted

    reel2reel running in a terminal with two inputs for a database url

  10. The data will now be downloaded from Heroku and uploaded to your ElephantSQL database

  11. To test that your database has been moved successfully, return to ElephantSQL and select BROWSER

    the browser tab highlighted as the third menu item on the left in an elephant s q l database details page

  12. Click the “Table queries” button. If you see any options in the dropdown, your tables have been created

    the table queries dropdown button has been clicked

  13. Select a table name you recognise, and then click “Execute

    execute button

  14. You should see your data displayed relating to the table you selected

    a table showing data from a database

Up Next

You have successfully created a new database instance and migrated all your data. Next we will take a look at what needs to be changed within your repository to prepare it for hosting on Render.com.