Postgresql Windows - v22-appfactory/appfactory-wiki GitHub Wiki
Installing Postgresql on Windows consists of the following steps:
- Install Postgresql for Windows - https://www.postgresql.org/download/windows/
- Add postgresql bin to Path
- Create appfactory users in psql
create role appowner with login password 'appowner password'; # POSTGRES-PSWD environment variable
create role appuser with login password 'appuser password';
- Create database and schemas
-- Create database and schemas (*create-database-schemas.sql*)
CREATE DATABASE appfactory;
-- In psql change to appfactory database
\c appfactory
-- Create schemas and change owner
CREATE SCHEMA app;
ALTER SCHEMA app OWNER TO appowner;
CREATE SCHEMA metadata;
ALTER SCHEMA metadata OWNER TO appowner;
-- check schemas
\dn
- Load initial database from SQL script
psql appfactory < \workspace\appfactory-migrations\migrations\V1.1__initial_setup.sql
- Change environment variable for POSTGRESQL to localhost
set POSTGRES_HOST=localhost
2a. Setup local user as Postgresql user and remove the need to enter password
- create user user-name with password null;
- create database user-name;
- alter user user-name with superuser;
- alter pg_hba.conf file login methdod from md5 to allow Trust login
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
- after changing the environment variables it is necessary to re-open any cmd boxes (terminals) that are being used (example: running PM2 for the services application)