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.

seed:run completes successfully but there is no added rows.

See original GitHub issue

Hey,

I’m migrating my seeding from sequelize (which currently works) to this package. I’m a bit confused here, I’m running the following seeder on a docker migration container. There is another container that also connects to typeorm which works fine, this is the main connection where all the app work is done. I assume you can have multiple typeorm connections active at once, anyways so the seed:run completes without any indication of failure but there are no rows added.

Screen Shot 2020-10-04 at 2 21 31 PM Screen Shot 2020-10-04 at 2 22 14 PM

Here’s my ormconfig.js

module.exports = {
  type: 'postgres',
  port: 5432,
  database: process.env.DATABASE_DB,
  username: process.env.DATABASE_USER,
  password: process.env.DATABASE_PASSWORD,
  host: process.env.DATABASE_HOST,
  synchronize: true,
  logging: false,
  entities: ['../graphql/src/orm/models/artist.ts'],
  // "migrations": [
  //    "src/migration/**/*.ts"
  // ],
  // "subscribers": [
  //    "src/subscriber/**/*.ts"
  // ]
  seeds: ['src/seeds/*{.ts,.js}'],
  // "factories": ['src/factories/**/*{.ts,.js}'],
};

Heres the seeder I’m running.

import { Factory, Seeder } from 'typeorm-seeding';
import { Connection } from 'typeorm';
import { Artist } from '../../graphql/src/orm/models';

export default class CreateUsers implements Seeder {
  public async run(factory: Factory, connection: Connection): Promise<any> {
    await connection
      .createQueryBuilder()
      .insert()
      .into(Artist)
      .values([
        {
          id: '0b600e0a-96d0-4ec0-bc94-2587a6b3507a',
          name: 'Various Artists',
          description: '',
          profileImageStoragePathLarge:
            'test',
          profileImageStoragePathSmall:
            'test',
          profileImageStoragePathThumb:
            'test',
          profileImageUrlLarge:
            'test',
          profileImageUrlSmall:
            'test',
          profileImageUrlThumb:
            'test',
          createdAt: new Date(),
          updatedAt: new Date(),
          followers: 0,
        },
      ])
      .execute();
  }
}

How can the seed complete sucessfully but there be no rows?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:13

github_iconTop GitHub Comments

2reactions
malteneusscommented, Mar 6, 2021

I had a the same problem and debugged it by using the default folder structure src/seeds/.. and src/factories/.. with ormconfig.js being

...
   seeds: ['src/seeds/**/*{.ts,.js}'],
  factories: ['src/factories/**/*{.ts,.js}'],
...

as in the guides. There i saw the CLI actually working: When the CLI recognizes seed files like add-users.seed.ts, you see

✔ Database connected
✔ Seeder AddUsers executed
👍  Finished Seeding

in the log. Turns out i had a typo in my custom seed path property in my ormconfig.js file.

1reaction
rtmancommented, Sep 14, 2021

Just fyi that @malteneuss is correct, but this package should say if it cannot locate any seed files instead of displaying Finished Seeding when it didn’t find anything to seed:

Screen Shot 2021-09-14 at 9 18 26 AM

One might think that it was able to locate the files and just didn’t log them individually.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A serious question about a run - Forum - Tetris 2 (NES)
Hello, I am not a speedrunner of this game at all but having tried it myself a month or two back I figured...
Read more >
The Return Of The King (How The Speedrun Ended 2.0 #1)
Returning to GTA 5 Speedrunning after over 2 years away. Long past are my days of having all the Grand Theft Auto 5...
Read more >
Kirby and the Forgotten Land Any% Speedrun in 1:42:30 ...
We reclaimed the Any% speedrun world record for Kirby and the Forgotten Land! This run was NUTS. This is about as good as...
Read more >
Left 4 Dead 2's Insanely Lucky Speedrun World Record
Left 4 Dead 2 has many speedruns and they are all extremely luck based but there is one world record for dark canival...
Read more >
Speedrun of Dishonored (SPEEDRUN EXPLAINED - Any%)
15:47 - When seeker interacts with the door to enter this area, he is sure not to spam F to interact. If he...
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