typeorm icon indicating copy to clipboard operation
typeorm copied to clipboard

Print out a warning if no entities are passed

Open alper opened this issue 1 year ago • 2 comments

Description of change

This is a very common problem for people getting started with Typeorm: They have it configured wrong and no entities are actually being passed into the system. The migration runner will then print out that nothing is to be done and you as a beginner don't really have an easy way to figure out what is going wrong here.

This is a simply check and warning in the migration create CLI to catch this case and print out a message that could help the person debug this situation.

Pull-Request Checklist

  • [x] Code is up-to-date with the master branch
  • [x] npm run format to apply prettier formatting
  • [x] npm run test passes with this change
  • [x] This pull request links relevant issues as: #2961 and #10558
  • [ ] ~~There are new or updated unit tests validating the change~~
  • [ ] ~~Documentation has been updated to reflect this change~~
  • [x] The new commits follow conventions explained in CONTRIBUTING.md

alper avatar Aug 05 '24 07:08 alper

@alper Ha, great. This is actually something I wanted to work on today, but I see you already tackled it. Great addition.

simplenotezy avatar Aug 05 '24 15:08 simplenotezy

@pleerock when you have time; this could've saved me a lot of time

simplenotezy avatar Aug 14 '24 11:08 simplenotezy

HI @alper thanks for your help Can you add a test for this scenario please?

Sure thing!

alper avatar Feb 11 '25 08:02 alper

I'm following the guide in DEVELOPER.md but the tests don't run cleanly as it is.

I don't see how I can add tests given the fact that they look to be broken.

alper avatar Feb 11 '25 16:02 alper

I don't see how I can add tests given the fact that they look to be broken

We should probably add a spy or a stub for console.log but that may require more actions (I'm not sure if console.loging was tested before in this project)

OSA413 avatar Feb 11 '25 16:02 OSA413

In case if you can't run the tests on your machine (currently there's a bug in the tests that prevent it from succession on Windows) you can push changes in this PR and we run tests on GitHub Actions (after we make sure that the tests are fine).

OSA413 avatar Feb 11 '25 16:02 OSA413

OK. Added some tests.

alper avatar Feb 12 '25 22:02 alper

Tests run on my fork. So please check this.

alper avatar Feb 13 '25 10:02 alper

Coverage Status

coverage: 72.337% (-0.04%) from 72.372% when pulling 6dab014a9ad7acd81647be6b2a223bddf04f8caa on alper:add-warning-for-no-entities into b9263d50d6281ed93cd74846527cbbb099b1891f on typeorm:master.

coveralls avatar Feb 14 '25 19:02 coveralls