question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Migrations aren't working

See original GitHub issue

Running npm run setup, I get the following error:

Could not run seed { QueryFailedError: ER_NO_SUCH_TABLE: Table 'my_database.user' doesn't exist at new QueryFailedError (/Users/fraccaman/Projects/express-typescript-boilerplate/src/error/QueryFailedError.ts:7:9) at Query._callback (/Users/fraccaman/Projects/express-typescript-boilerplate/src/driver/mysql/MysqlQueryRunner.ts:157:37) at Query.Sequence.end (/Users/fraccaman/Projects/express-typescript-boilerplate/node_modules/mysql/lib/protocol/sequences/Sequence.js:88:24) at Query.ErrorPacket (/Users/fraccaman/Projects/express-typescript-boilerplate/node_modules/mysql/lib/protocol/sequences/Query.js:90:8) at Protocol._parsePacket (/Users/fraccaman/Projects/express-typescript-boilerplate/node_modules/mysql/lib/protocol/Protocol.js:279:23) at Parser.write (/Users/fraccaman/Projects/express-typescript-boilerplate/node_modules/mysql/lib/protocol/Parser.js:76:12) at Protocol.write (/Users/fraccaman/Projects/express-typescript-boilerplate/node_modules/mysql/lib/protocol/Protocol.js:39:16) at Socket.<anonymous> (/Users/fraccaman/Projects/express-typescript-boilerplate/node_modules/mysql/lib/Connection.js:103:28) at Socket.emit (events.js:159:13) at addChunk (_stream_readable.js:265:12) message: 'ER_NO_SUCH_TABLE: Table \'my_database.user\' doesn\'t exist', code: 'ER_NO_SUCH_TABLE', errno: 1146, sqlMessage: 'Table \'my_database.user\' doesn\'t exist', sqlState: '42S02', index: 0, sql: 'INSERT INTO user(id, first_name, last_name, email) VALUES (\'25220231-36b6-4031-8ae1-6cf3739074bd\', \'Bruce\', \'Wayne\', \'bruce.wayne@wayne-enterprises.com\')', name: 'QueryFailedError', query: 'INSERT INTO user(id, first_name, last_name, email) VALUES (?, ?, ?, ?)', parameters: [ '25220231-36b6-4031-8ae1-6cf3739074bd', 'Bruce', 'Wayne', 'bruce.wayne@wayne-enterprises.com' ] } The script called "db.seed" which runs "nps banner.seed && nps config && ts-node --transpileOnly ./src/lib/seed/cli.ts" failed with exit code 1 https://github.com/kentcdodds/nps/blob/v5.9.0/other/ERRORS_AND_WARNINGS.md#failed-with-exit-code The script called "setup.script" which runs "yarn install && nps db.drop && nps db.migrate && nps db.seed" failed with exit code 1 https://github.com/kentcdodds/nps/blob/v5.9.0/other/ERRORS_AND_WARNINGS.md#failed-with-exit-code

I think this is due to the fact that during the migration stage, the tables are not created.

nps is executingconfig: ts-node --transpileOnly ./commands/tsconfig.ts && ts-node --transpileOnly ./commands/ormconfig.ts query: SELECT * FROMINFORMATION_SCHEMA.COLUMNSWHERETABLE_SCHEMA= 'my_database' ANDTABLE_NAME= 'migrations' query: CREATE TABLEmy_database.migrations (idint NOT NULL AUTO_INCREMENT,timestampbigint NOT NULL,name varchar(255) NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB query: SELECT * FROM my_database.migrations migrationsNo migrations are pending nps is executingdb.seed: nps banner.seed && nps config && ts-node --transpileOnly ./src/lib/seed/cli.ts nps is executingbanner.seed : ts-node --transpileOnly ./commands/banner.ts seed

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:6

github_iconTop GitHub Comments

6reactions
jahumescommented, May 24, 2018

@Fraccaman So, I had the same issue and spent an hour tracking it down. The problem stems from TypeORM looking for .env variables to see if your environment is where it should pull it’s config. (See line 98 of ConnectionOptionsReader.ts) Since this is the name of the .env variable that this boilerplate uses to choose the database for typeorm, the ormconfig.json file is being ignored. All you have to is either uncomment the other typeorm configs in the .env file, or rename TYPEORM_CONNECTION to anything else in the .env file and the env.ts file.

3reactions
disovicommented, May 29, 2018

@jahumes is right, the problem is in TYPEORM_CONNECTION from .env file which clashes with TypeORM config loader. This bug was introduced in https://github.com/w3tecch/express-typescript-boilerplate/pull/95 PR. Two solutions:

  1. Use master branch

or

  1. Rename TYPEORM_CONNECTION to TYPEORM_CONNECTION_BP in .env and in env.ts
Read more comments on GitHub >

github_iconTop Results From Across the Web

Django Migration is not applying the migration changes
Go to you migration folder, delete 0001_initial.py file then run python manage.py makemigrations myproj then run python manage.py migrate . This ...
Read more >
Migration troubleshooting in development - Prisma
This guide describes how to resolve issues with Prisma Migrate in a development environment, which often involves resetting your database.
Read more >
Code First Migrations are not applied during publish
When I publish, everything reports success, yet none of my migrations are being applied to the specified database(s). This deployment and application has...
Read more >
Troubleshooting migration tasks in AWS Database Migration ...
The most common reason for a migration task running slowly is that there are inadequate resources allocated to the AWS DMS replication instance....
Read more >
Django migrations are not running - Fly.io
Hello, I've got a small django app in a fly instance. Recently, I added some migrations and wanted to run them.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found