Closed anassarfraz closed 5 months ago
@anassarfraz can you provide a reproduction (git) repository ?
@anassarfraz can you provide a reproduction (git) repository ?
yes sure i will create and share repository
@tada5hi this code just related to problem i remove extra code from this repository.
https://github.com/anassarfraz/typeorm-extension-issue
just try to run npm run seed:specific
for run the seed for specific file i mentioned in package.json file.
actually it runs the commands in cli but not save the data in database.
but if i run npm run seed:run
it will save the data in database.
what actually i want to do? i am trying to run seed with this flag. --name seed:create & seed:run undefined Name (or relative path incl. name) of the seeder.
Thanks for your response.
You have to adjust the paths for seeds, migrations & factories in your typeorm-data-source.ts
file:
After the adjustment everything works fine :)
const options: DataSourceOptions & SeederOptions = {
type: 'postgres', // IF you are using a different type of connector, please mention here explicitly.
database: process.env.DATABASE_NAME || '',
host: process.env.DATABASE_HOST || 'localhost',
port: parseInt(process.env.DATABASE_PORT) || 5432,
username: process.env.DATABASE_USERNAME,
password: process.env.DATABASE_PASSWORD,
migrationsRun: true,
entities: ['src/**/**/*.entity.{ts,js}'],
migrations: ['src/migrations/*{.ts,.js}'],
seeds: ['src/seeders/*.seeder{.ts,.js}'],
};
@anassarfraz please close the issue if this solved your issue.
i will check in a while then if resolved for me i will closed it.
thanks
your welcome!
@tada5hi did you try to run code which i gave to you (https://github.com/anassarfraz/typeorm-extension-issue)
my typeorm-data-source.ts setting are fine and its paths for seed and migrations are fine , i am using swc compiler for compailing nestjs code.
my path for seeders and migrations are corrects thats why my code create table in migration and run all seeds on seed:run i just want to ask run seeder only for specific file not working ..
@tada5hi did you try to run code which i gave to you (https://github.com/anassarfraz/typeorm-extension-issue)
yes, without modifications, the run seed:specific
does not work.
my typeorm-data-source.ts setting are fine and its paths for seed and migrations are fine , i am using swc compiler for compailing nestjs code.
When i modified them, everything worked
my path for seeders and migrations are corrects thats why my code create table in migration and run all seeds on seed:run i just want to ask run seeder only for specific file not working ..
The reason for this is, that none of the seed paths detected by the pattern 'dist/seeders/*.seeder{.ts,.js}'
does match with the path src/seeders/user.seeder.ts
Versions
Reproduction
Additional Details
Steps to reproduce
this is my pacakge.json script cmd which i run for specific seed file
What is Expected?
The command should execute the seed logic defined in user.seeder.ts after successfully locating and loading the seed file.
What is actually happening?
The response only displays the data source name, directory, and file name, and doesn't actually trigger the execution of the seed logic within user.seeder.ts.
@tada5hi @guillaumedeslandes @ckaeslin @faloi @fossamagna