Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem using another schema than 'public' on a PostgreSQL database #15

Open
jlwarg opened this issue Apr 8, 2020 · 4 comments
Open
Labels
bug Something isn't working

Comments

@jlwarg
Copy link

jlwarg commented Apr 8, 2020

Version I'm using:

$ sequelize-automate --version
1.2.0

I've tried to use this configuration

module.exports = {
    dbOptions: {
        database: "mydb",
        username: "user",
        password: "mypassword",
        dialect: "postgres",
        host: "myhost",
        port: "5432",
        schema: "app"
    },
    options: {
        type: "js",
        dir: "new",
    }
}

And got this result:

$ sequelize-automate -c .sequelize-automate-new.config.js
Database options: {"database":"mydb","username":"user","password":"****","dialect":"postgres","host":"myhost","port":"5432","schema":"app"}
Automate options: {"type":"js","camelCase":false,"dir":"new","emptyDir":false}
Executing (default): SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' AND table_type LIKE '%TABLE' AND table_name != 'spatial_ref_sys';
Done!

As you can see, "app" gets recognized as the value of Database option "schema", but when the list of tables gets queried, "public" is used as the schema instead.
I suspect that the cause of this is the function showTablesQuery() in the sequelize codebase:

showTablesQuery() {
	return "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' AND table_type LIKE '%TABLE' AND table_name != 'spatial_ref_sys';";
}

https://github.com/sequelize/sequelize/blob/master/lib/dialects/postgres/query-generator.js#L117-L119

IMHO this function should take a parameter schema that defaults to "public" instead of just querying the "public" schema. I haven't investigated further yet because I'm new to sequelize and sequelize-automate and am not sure that I'm using it correctly.

@nodejh nodejh added the bug Something isn't working label Apr 9, 2020
@gioppoluca
Copy link

I have the same problem.
PostgreSQL schema is not taken into account.
Is there a proper way to address this or is a missing feature?
Thanks

@nodejh
Copy link
Owner

nodejh commented May 11, 2020

Hi @gioppoluca, could you give me a demo schema of PostgreSQL table? Let me have a test.

@osmanraifgunes
Copy link

@osmanraifgunes
Copy link

temporary solution is #18 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants