last day (15 days later) » 

6:11 AM
2
A: TypeOrm migration:run not working errno: -3008,getaddrinfo ENOTFOUND

Eranga HeshanYour VS Code terminal is running inside your machine. So it can't resolve users-service-db host. You can do this in two ways. 1. Using a new config file and execute migrations from your localhost Create a new typeorm connection config file migrationsOrmConfig.ts and put it inside your project (L...

 
Thanks for the answer. First step i tried but still the same =>PS C:\Users\edibi\eclipse-workspace\nodejsSocketTypescriptGraph‌​QL\users-service> node --require ts-node/register .\node_modules\typeorm\cli.js --config .\src\db\migrations\typeOrmConfig.ts migration:run Error during migration run: Error: getaddrinfo ENOTFOUND users-service-db at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:69:26) { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'users-service-db', fatal: true } When execute step 2 it says =>/bin/sh: 1: node: not found
 
Okay, I updated the migration command in my 1st answer. For the second one, I made a mistake by asking you to go into the MySQL container. Can you try 1st answer again? For the 2nd, are you using docker-compose to run your backend? If so, can you share the full docker-compose file?
 
okey you moved typeorm migrations:run command to the front. That's ok but the error won't go away. Thanks i edited the docker-compose.yml file
 
No worries, based on your docker-compose file, I updated my second answer, could you try it now?
 
yes i think we are on the right path it seems that typeorm is not in the node-modules folder for whatsoever reason. it cannot find the typeorm package in node-modules: Error: Cannot find module '/opt/app/node_modules/typeorm/cli.js' So why it is not installing the package in the image
 
6:11 AM
Do you have typeorm in package.json?
 
Hey thanks for inviting me to chat 😹
Yes I have package.json with typeorm
 
Cool, it is suggested by stackoverflow since the discussion is long
So you open a terminal inside the container and tried to run the migration command, right?
 
Correct
 
Can you go back to the terminal inside the container, and try to install typeorm?
npm i typeorm
 
hi yes i tried but sadly it was throwning exception again
Error during migration run:
Error: No connection options were found in any orm configuration files.
at ConnectionOptionsReader.<anonymous> (/opt/app/src/connection/ConnectionOptionsReader.ts:42:19)
at step (/opt/app/node_modules/tslib/tslib.js:143:27)
at Object.next (/opt/app/node_modules/tslib/tslib.js:124:57)
at fulfilled (/opt/app/node_modules/tslib/tslib.js:114:62)
 
6:23 AM
Cool, where is your typeorm config file? Could you put the path to your config?
 
C:\Users\edibi\eclipse-workspace\nodejsSocketTypescriptGraphQL\users-service\ormconfig.json
{
"cli": {
"migrationsDir": "src/db/migrations"
},
"entities": ["src/db/entities/*.ts"],
"logging": false,
"migrations": ["src/db/migrations/*.ts"],
"synchronize": true,
"type": "mysql",
"url": "mysql://root:password@users-service-db/db"
}
 
Okay, nice
Now can you try to modify the command you used to run the migration to have the config we used?
You have to rerun the docker-compose
node --require ts-node/register ./node_modules/typeorm/cli.js migration:run --config src/migrations/migrationsOrmConfig
Oh wait
When I earlier told you to create a new config file, what was the content you put inside
Can you put it here as well?
 
export = {
host: 'localhost',
port: '7201',
type: 'mysql',
url: "mysql://root:password@users-service-db/db",
// user : 'password',
password : 'password',
database : 'db' ,
hostname: 'localhost'
};
 
Damn, I see the problem
I was hoping you would be using a different property set inside and I was wrong
Remove host, and port properties
Update your url to "mysql://root:password@localhost:7201/db"
Now, you should be able to try the 1st answer I put in the stackoverflow
 
is it now ok ?
export = {
type: 'mysql',
url: "mysql://root:password@localhost:7201/db",
password : 'password',
database : 'db' ,
};
or even remove password and database
 
6:34 AM
Yes this should work
And if this works, don't end the chat
 
ok
 
I have a suggestion to make
 
ok it did work.. partly
a migration table was created in phpmyadmin
 
Why partly?
 
but the user table and rover table is missing
 
6:38 AM
Ah, we can take care that later
What I wanted to point to you was, maybe it will be better if you try not to use url property
Because whenever you want to change the name, database or anything else, you will have to change the URL and it is not that nice
 
nice man thanks big time
i try to run a new migration:create
to generate the missing tables right?
 
Instead, you can use this config
export = {
host: 'localhost',
port: '7201',
type: 'mysql',
user : 'root',
password : 'password',
database : 'db' ,
};
Yeah, for the migrations that were not available, you can try to generate them
Also, I suggest to put synchronize to false when you actually put this into your production
Otherwise, your database will change whenever you update your entities and you will have no clue how it happened
If that's all, I will update my answer in the question
 
haha ok nice man thanks
 
Good luck. Have a nice weekend
 

last day (15 days later) »