-
Add PostgreSQL Apt Repository
sudo apt-get install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
-
Add the repository to your system
RELEASE=$(lsb_release -cs) echo "deb http://apt.postgresql.org/pub/repos/apt/ ${RELEASE}"-pgdg main | sudo tee /etc/apt/sources.list.d/pgdg.list
-
Install PostgreSQL
sudo apt-get update
sudo apt -y install postgresql-11
-
Go to /etc/postgresql/11/main directory
-
Change permission of pg_hba.conf file
sudo chmod 777 pg_hba.conf
-
Open pg_hba.conf file
Changepeer
tomd5
in"local" is for Unix domain socket connections only
line and save the file. -
Change password of postgres role
sudo su - postgres
psql
\password
enter new password -
Create a new role for test database
sudo su - postgres
psql
CREATE ROLE role_name WITH PASSWORD "your_password";
ALTER ROLE role_name WITH superuser;
-
Bundle Install If pg gemfile error occurs use
sudo apt-get install libpq-dev
-
Set up Env Variables
Add these lines in .bashrc file
export LEVEL_ME_UP_USERNAME="postgres"
LEVEL_ME_UP_PASSWORD="your_password_set_in_step_4"
POSTGRES_11_PORT="5432"
export LEVEL_ME_UP_DEV="database_name"
-
Create Database
Go to project directory
rails db:create
-
Run Migration
rails db:migrate