I'm trying to get sequelize going on GAE. But am struggling with the cloud SQL proxy that uses sockets on non-standard paths.
My understanding is that a url would get passed direct to the pg library, and based on this post, it would suggest the below string is what I need
I've setup the db configuration to be
{
url: 'postgresql:///db_user:db_password@/db_name?host=./cloudsql/my-project-1234:us-central1:my-cloud-sql-instance',
dialect: 'postgres'
}
However, if I run ./node_modules/.bin/sequelize db:migrate
I end up with the error:
ERROR: database "db_user:db_password@/db_name" does not exist
After a lot of trial and error, it is possible to pass the socket path using the host variable, but there are a few gotcha's:
/
(otherwise it assumes it is a hostname)ENOENT
(file not found), but moving the sockets to /cloudsql
in the root path fixed it./.s.PGSQL.5432
to that (which is fine because Google's SQL proxy socket is in that file)So with the following config, I was able to run a database migration through google's cloud SQL proxy:
{
username: 'my_user',
password: 'my_password',
database: 'my_database',
host: `/cloudsql/my-app-12345:us-central1:my_database`,
logging: false,
dialect: 'postgres',
// Google cloud_sql_proxy is encrypted, so no need to encrypt
ssl: false,
dialectOptions: {
ssl: false,
},
operatorsAliases: false,
}