simov / express-admin

MySQL, MariaDB, PostgreSQL, SQLite admin for Node.js
MIT License
1.17k stars 223 forks source link

Empty schema! error with postgresql #68

Closed emekanw closed 10 years ago

emekanw commented 10 years ago

I have a public schema but keep getting this error when trying to run the admin.

simov commented 10 years ago

You need some tables in your database. Exress Admin can't create tables for you, it can only edit existing ones.

emekanw commented 10 years ago

I have a table, I even used the express-admin-example but got the same error. For some reason SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' works on pgadmin and returns the tables but returns an empty array with

var sql = query.replace('show-tables', schema);.

this.client.query(sql, function (err, rows) { console.log(rows); if (err) return cb(err); if (rows.length) return cb(null, false); cb(null, true); }

in https://github.com/simov/express-admin/blob/master/lib/db/database.js

simov commented 10 years ago

This error message might not be correct. Can you check out if the database user you are connecting with have granted permissions for this schema, tables and sequences you are using.

Example for granting permissions to your user here - https://github.com/simov/express-admin-examples/#postgresql

emekanw commented 10 years ago

yes I did that, my user has permission.

simov commented 10 years ago

That's very strange, the only problem I can think of is misconfiguration or missing privileges (the error message isn't correct, which is silly)

Here is what I normally do

# import
sudo -u postgres psql 'db' < dump.sql
# cmd
sudo -u postgres psql
\c "to-the-database-first!"
grant all on database "express-admin-examples" to liolio;
grant all on schema "public" to liolio;
grant all on all tables in schema "public" to liolio;
grant all on all sequences in schema "public" to liolio;

-- additionally you may need to change the owner of each table and sequence
alter table [tableName] owner to liolio;
alter sequence [sequenceName] owner to liolio;
emekanw commented 10 years ago

That helped thanks