Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typical ormconfig.json file for Google Cloud SQL?

I have been trying for hours. What should be the ormconfig.json file for Google Cloud SQL working with TypeORM? I managed to get it working with the IP of the DB locally (with mysql workbench and Google cloud proxy and whitelisting my ip) but I don't know what the connection details should be for app engine.

{
  "name": "default",
  "type": "mysql",
  "host": "/cloudsql/[project:region:instance]",
  "port": "3306",
  "username": "root",
  "password": "xxxx",
  "database": "yyy",
  "synchronize": true,
  "logging": false,
  "entities": [
    "modules/**/*.entity.js"
  ]
}

or

{
  "name": "default",
  "type": "mysql",
  "extra": {
    "socketPath": "/cloudsql/[project:region:instance]"
  },
  "username": "root",
  "password": "xxxx",
  "database": "yyy",
  "synchronize": true,
  "logging": false,
  "entities": [
    "modules/**/*.entity.js"
  ]
}

or anything else?

Thanks a lot!

like image 280
qbodart Avatar asked Dec 14 '22 19:12

qbodart


1 Answers

For those interested, here is the solution:

{
  "name": "default",
  "type": "mysql",
  "extra": {
    "socketPath": "/cloudsql/[project:region:instance]"
  },
  "username": "root",
  "password": "xxxx",
  "database": "yyy",
  "synchronize": true,
  "logging": false,
  "entities": [
    "dist/**/*.entity.js"
  ]
}

Note that I also changed the entities path

like image 85
qbodart Avatar answered Jan 28 '23 21:01

qbodart