Flink / dokku-psql-single-container

Plugin for dokku that provides a Postgresql server in a single container
MIT License
51 stars 9 forks source link

Database creation failed: role does not exist #7

Closed Subtletree closed 9 years ago

Subtletree commented 9 years ago

I'm not sure if this is a problem with what I'm doing or with the plugin.

I created a fresh dokku 0.3.19 droplet on digital ocean, set up hostnames etc. (I'm using sub domains for my apps).

I deployed my app 'asc' to the server. Installed 'dokku-psql-single-container'

Then ran $ dokku psql:create asc

root@asc:~# dokku psql:create asc
-----> Creating database asc
ERROR:  syntax error at or near "asc"
LINE 1: CREATE USER asc WITH PASSWORD '4f6a617109a235e0e5778bc20c22b...
                    ^
createdb: database creation failed: ERROR:  role "asc" does not exist
ERROR:  syntax error at or near "asc"
LINE 1: GRANT ALL PRIVILEGES ON DATABASE asc TO asc;
                                         ^
-----> Setting config vars for asc

It seems as though the databse exists but the role doesn't:

root@asc:~# dokku psql:dump asc
pg_dump: [archiver (db)] connection to database "asc" failed: FATAL:  role "asc" does not exist
root@asc:~# dokku psql:create asc
Database for asc already exists
root@asc:~# dokku psql:list
                                 List of databases
   Name    |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges   
-----------+----------+----------+------------+------------+-----------------------
 postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
 template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
(3 rows)

Am I missing something? Thanks

Subtletree commented 9 years ago

After more digging it seems that the app name asc is disallowed I think because it is short for ascending. The app name desc doesn't work either but all others I have tried do.

Flink commented 9 years ago

Yes certain words are reserved: http://www.postgresql.org/docs/9.3/static/sql-keywords-appendix.html So I think the only thing to do is to avoid them ;)