I made a post yesterday to fix the issues with my database code, and I had a few typos to fix and it works now. The only problem is I can only connect to my database as the default postgres user, when I want to connect as my created user in the file. I pictured the status below:
CREATE DATABASE equipment;
CREATE USER equipment WITH ENCRYPTED PASSWORD 'testing';
GRANT ALL PRIVILEGES ON DATABASE "equipment" to equipment;
GRANT USAGE ON SCHEMA public TO equipment;
GRANT CONNECT ON DATABASE equipment TO equipment;
ALTER USER equipment WITH SUPERUSER;
\c equipment equipment;
CREATE TABLE material (
material_id INTEGER NOT NULL,
name VARCHAR(128) NOT NULL,
description VARCHAR(256) NOT NULL,
tensile_strength INTEGER NOT NULL,
PRIMARY KEY ( material_id )
);
CREATE TABLE costs (
cost_id INTEGER NOT NULL,
material_id INTEGER NOT NULL,
price DECIMAL(10,2) NOT NULL,
CONSTRAINT fk_material_id FOREIGN KEY (material_id) REFERENCES material(material_id)
PRIMARY KEY ( cost_id )
);
CREATE TABLE usages (
usage_id INTEGER NOT NULL,
cost_id INTEGER NOT NULL,
purpose VARCHAR(256) NOT NULL,
location_to_purchase VARCHAR(256) NOT NULL,
CONSTRAINT fk_cost_id FOREIGN KEY (cost_id) REFERENCES costs(cost_id)
PRIMARY KEY ( usage_id )
);
GRANT ALL PRIVILEGES ON material, costs, usages TO equipment;
EDIT: can connect with equipment user after editing pg_hba.conf;
Content containing changes in the conf file:
# Database administrative login by Unix domain socket
local all postgres peer
local all equipment md5
After running this this is the output:
GRANT
GRANT
GRANT
ALTER ROLE
Password for user equipment:
Entering 'testing' allows me in (Is there an automatic way to enter this?)