w3tecch/typeorm-seeding

[Request] Support for typeorm 0.3 and nestjs/typeorm v8.1.0

mehedi-iitdu opened this issue ยท 20 comments

Can you please add support for TypeORM v0.3 and above and nestjs/typeorm v8.1.0 and above?

I tried upgrading Typeorm to 0.3.7
and typeorm-seeding threw an error saying

Cannot find module 'typeorm/driver/aurora-data-api/AuroraDataApiConnectionOptions' or its corresponding type declarations.

I guess this has something to do when upgrading to 0.3

MrMaz commented

My company has created a fork that is a combination of this project and v3.2.0 on the Jorge Bodega fork. We decided to go in a different direction with the API and how to do TypeORM 0.3 support.

This is not a drop in replacement, but if you need TypeORM v0.3 support you can start using it immediately with some small changes.

https://github.com/conceptadev/typeorm-seeding

Oh, nice!

What are the differences? I'm still working on supporting 0.3 but I'm a bit stuck. Would be great to have some new ideas.

Also, @mehedi-iitdu as you can see on #201 I cannot automate deploy of versions, and I don't have time for taking care of this library and manually deploy new versions.

MrMaz commented

@jorgebodega your idea with the factorized attributes for version 4 is really cool and i tried to make it work, but for our case is a bit too difficult to debug unit tests, and also would require too much refactoring on our projects. we are addicted to the map i guessing, lol.

we are instead creating an "overrides api" for entity customization and sub-factories at run time. having factories and seeders that are re-useable is a high priority for us. we are re-using your seeder tree pattern with some minor tweaks.

TypeORM v0.3 support was tricky because they basically dropped support for connection name and ormconfig file. if you look at our source you can see how we basically do that from scratch now without relying on the TypeORM config options loader at all.

would love to collaborate with you more on this. i believe both seeder styles have a place.

The most painful part of upgrading TypeORM is the connection refactor, that is true, and I really don't like how the Seeder actually work, like a tree, so I'm really open to any idea on how to improve that.

MrMaz commented

@jorgebodega i like the tree, but not that we are forced to have one root. i am going to make a change on our fork where it runs all seeders in order by default, unless you supply one or more root seeders, it will run those each like a tree.

My idea for the next version is just to remove the tree and run all the seeders in order, letting the users to choose the order with 01-Seeder or 01Seeder or something like.

This is just I don't like the idea of run seeders as a side effect of running others, and how that could affect to testing and execution.

Do you use the seeder with some root as entry? Every feedback is welcome

Hello everyone, has any updates on the issue?

No plans to work on this since I can work on this but cannot deploy.

If you can wait until someone came back to work or give me access, it's ok. But I released every change I did on another library, @jorgebodega/typeorm-seeding

@jorgebodega looking at this comment #201 (comment) it seems you now have maintenance over the npm repo...

is there anything else blocking you that someone can assist? Or really depends on the author?

I don't have permissions to add secrets to github, so I cannot add the deploy system I've worked on my fork, and I won't do it manually.

So until I have admin access, I won't work on this. If you need recent support, try to work with the latest version of my fork.

Hi.
Also have this problem.
When running config, everything is ok.
But when run seeding I got an error MissingDriverError: Wrong driver: "undefined" given.

You can also give https://github.com/tada5hi/typeorm-extension a try. Recently i added seeding support, which is highly inspired by this library and the usage should be the same like before.

@jorgebodega the library could also be interesting for you, to use the singleton state management for your reimplementation https://www.npmjs.com/package/typeorm-extension#instances

Our company also maintains a fork of typeorm-seeding but with context support, that has been very important for us. Currently typeorm 0.3.12 is supported. https://github.com/paralo-official/typeorm-seeding

MrMaz commented

Our company also maintains a fork of typeorm-seeding but with context support, that has been very important for us. Currently typeorm 0.3.12 is supported. https://github.com/paralo-official/typeorm-seeding

Hi Paul. Let me know if you want to collaborate on this fork.

Our company also maintains a fork of typeorm-seeding but with context support, that has been very important for us. Currently typeorm 0.3.12 is supported. https://github.com/paralo-official/typeorm-seeding

Hi Paul. Let me know if you want to collaborate on this fork.

Definitely interested. jorgebodega also has a fork I think. We should put our efforts into one fork I think...
For us the context has been very important.
What do you think on this?

MrMaz commented

Our company also maintains a fork of typeorm-seeding but with context support, that has been very important for us. Currently typeorm 0.3.12 is supported. https://github.com/paralo-official/typeorm-seeding

Hi Paul. Let me know if you want to collaborate on this fork.

Definitely interested. jorgebodega also has a fork I think. We should put our efforts into one fork I think... For us the context has been very important. What do you think on this?

Yes I like the idea of adding the context back. Ours is a fork of Jorge's project, but we decided to go in a slightly different direction and set context aside for later. I just created a thread on our repo so we can have the discussion there.

conceptadev#4

I have a fork just to have a functional version of the code, but there are some changes, context is the main one, just because I don't see why it should stay in my version with the changes.

If you want to add me in the discussion, just ping me.

apudiu commented

Our company also maintains a fork of typeorm-seeding but with context support, that has been very important for us. Currently typeorm 0.3.12 is supported. https://github.com/paralo-official/typeorm-seeding

Thank you for making the lib compatible with typeORM 0.3.x

I've followed the instructions on https://github.com/paralo-official/typeorm-seeding/blob/main/README.md
After running npm run seed:run I'm getting following error```

โœ” Seeding Config seeding-source.js loaded
โœ– Could not load the seeding source config file at seeding-source.js! Orginal error was: seedingSource.initialize is not a function
Could not load the seeding source config file at seeding-source.js! Orginal error was: seedingSource.initialize is not a function

scripts in package.json

"seed:config": "typeorm-seeding config -r ./dist/db -c seeding-source.js",
"seed:run": "typeorm-seeding seed -r ./dist/db -c seeding-source.js"

my folder structure (in project root)

db
    factories
    seeders
    seeding-source.ts

Please help me understand what's wrong here.

apudiu commented

I've found the solution, I think the docs need a little improvement. As the docs suggested, I've created SeedingSource class but that needs to be imported from the package. This part also confuses me how does this work!!, Now seeding OK

// result of misleading doc's, need to import this class from package <<
// class SeedingSource {
//   constructor(public options: SeedingSourceOptions) {}
// }

export default new SeedingSource({
  dataSource: DataSource,
  seeders: [UserSeeder],
  // defaultSeeders: [UserSeeder],
});