RobinCK / typeorm-fixtures

:pill: Fixtures loader for typeorm 🇺🇦
https://robinck.github.io/typeorm-fixtures/
MIT License
566 stars 45 forks source link

Order of fixture save/insert #125

Closed Kalhama closed 4 years ago

Kalhama commented 4 years ago

Hi,

I've got an application where database schema is designed to store immutable data and every new row represents new revision of the data. Thus the order of rows is very important.

I noticed after using this package that because of dependency resolving some of the entities I created were not being saved to database in the same order specified in the .yml file.

I thought that one way could be adding an option in where previous node would be set to dependency.

More flexible implementation of this would be to allow Fixture item tell that it depends on previous item in Fixture.yml

Kalhama commented 4 years ago

I found a rather viable workaround for this:

entity: Item
items:
  revision1:
    id: 1
  revision2:
    id: 1
    depends:  @revision1

By settings this depends field [which may not actually exist in entity schema] revisions of Item get saved in proper order.

I think this issue can be closed, this feature is anyways rather niche.