Closed rtman closed 3 years ago
here it is like this
here it is like this
not sure what you mean
Do I need to provide more information, would be great to get some guidance here.
@rtman I thing you have a typo in your ormconfig.js
. Check seeds
property, you should have something like this:
seeds: ['src/seeds/**/*{.ts,.js}'],
I have the same issue :(
@SiarheiLunski I believe I tried that initially and it didn't work. But also if the orm config is incorrect, how is it importing seeds as per the image I posted?
seeds
and factories
are both in the correct format.src/database/factories
folder and suffixed with .factory
like src/database/factories/user.factory.tsHere's my ormconfig.js
module.exports = {
type: 'mysql',
host: process.env.DB_HOST,
port: process.env.DB_PORT,
username: process.env.DB_USER,
password: process.env.DB_PASS,
database: process.env.DB_NAME,
entities: [__dirname + '/../**/*.entity.{js,ts}'],
seeds: [__dirname + '/../database/seeds/**/*{.ts,.js}'],
factories: [__dirname + '/../database/factories/**/*{.ts,.js}'],
namingStrategy: new SnakeNamingStrategy(),
legacySpatialSupport: false,
};
same issue here
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.
I had the same issue. With this code:
export default class CreateColors implements Seeder {
public async run(): Promise<void> {
return Transaction.run(
() => this.save(),
);
}
private async save() {
const promises: Promise<LangColor>[] = [];
colors.forEach((color) => {
promises.push(this.saveColor(color));
});
Promise.all(promises);
}
private async saveColor(color: ColorsProperties) {
....
}
The issue was in the line Promise.all(promises);
. I added await Promise.all(promises);
and it works properly.
Closing, since it seems to be misconfig issue. If you have any further issues regarding this topic please feel free to reopen.
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:
One might think that it was able to locate the files and just didn't log them individually.
Same error here, I have my seeds in another directory outside src
and even though I changed the ormconfig accordingly and "✔ Seeders are imported" appears, it doesn't actually find anything, but when I change to the default route it works...
The error happen when trying to execute a single Seed by class name
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.
Here's my ormconfig.js
Heres the seeder I'm running.
How can the seed complete sucessfully but there be no rows?