Search code examples
postgresqlubuntucloud9-ide

PostgreSQL - Create table in schema privilege on Cloud9


I'm using PostgreSQL on Cloude9. I'm trying to run a nodejs program which creates a schema in a database and then creates some tables in the schema. Here is what I'm trying to do and the error I get:

CREATE SCHEMA IF NOT EXISTS salesforce;
CREATE TABLE IF NOT EXISTS salesforce.contact (
    id              BIGSERIAL,
    firstName       TEXT,
    lastName        TEXT,
    email           TEXT,
    mobilePhone     TEXT,
    leadsource      TEXT,
    accountid       TEXT,
    pictureURL__c   TEXT,
    preference__c   TEXT,
    size__c         TEXT,
    loyaltyid__c    TEXT,
    password__c     TEXT,
    createddate     timestamp
  );

Error initializing Postgres tables initialized
{ [Error: permission denied for schema salesforce]
  severity: 'ERROR',
  code: '42501',
  file: 'aclchk.c',
  line: '3371',
  routine: 'aclcheck_error' }

the PostgreSQL is running under user postgresql, I'm running under user ubuntu, but I granted all privileges on the database to user ubuntu. I also edited the pg_hba.conf file to:

local   all             postgres                                peer
# TYPE  DATABASE        USER            ADDRESS                 METHOD
# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 md5

what am I doing wrong? Thanks, Nir.


Solution

  • started all from scratch and after creating a role with superuser and login options, it worked fine.