Skip to content

Latest commit

 

History

History
81 lines (50 loc) · 1.57 KB

setup-cloud-sql.md

File metadata and controls

81 lines (50 loc) · 1.57 KB

Google Cloud SQL Setup Instructions

Creating a Cloud SQL Instance

  1. Navigate to the Cloud SQL Console

  2. Click on create instance

  3. Select PostgreSQL

  4. Give it an id and password. Make sure to note down the password

  5. Set database version to PostgreSQL 15

  6. Select Enterprise

  7. Select production or development depending on needs

  8. Click on customize instance

  9. In connections, add a new network as authorized network

name: allowall
network: 0.0.0.0/0
  1. Click done

  2. Click create instance

  3. Wait for the instance to be created - this can take 5 to 10 minutes

  4. Once its created, copy the public IP address. This will be used as host when connecting

Restoring the database backup

  1. Install PostgreSQL 15 for the psql command line tool

  2. Run

psql -h <public-ip-address> -U postgres -d postgres
  1. Once connected, run the following command to create a new database
CREATE DATABASE ovatify;
  1. Once the database has been created, run \q to exit

  2. Navigate to the directory of the backup.sql file, then run

psql -h <public-ip-address> -U postgres -d ovatify -f backup.sql
  1. Wait for the operation to complete

  2. Connect to the database

psql -h <public-ip-address> -U postgres -d ovatify
  1. Run a test query
SELECT COUNT(*) FROM users_user;

Using database connection in .env files

DB_USERNAME: postgres
DB_NAME: ovatify
DB_PASSWORD: <database password>
DB_HOST: <database public IP address>