devinivy / dogwater

A hapi plugin integrating Waterline ORM
MIT License
102 stars 14 forks source link

Option to only load waterline-fixtures on first load #28

Closed lynnaloo closed 8 years ago

lynnaloo commented 9 years ago

Right now, the fixtures seem to be loading every time the server starts, even if migrate: safe is set in the models. If there are no unique fields, then it duplicates the data. If there are unique fields, then the plugin fails on server startup. I'd like the option to just load the fixtures on a blank database only.

devinivy commented 9 years ago

Maybe this will get you by for now: if you specify a primary key in your fixture, the record with that id will be updated rather than created.

devinivy commented 9 years ago

@lynnaloo do you have a suggested spec? I like the idea you alluded to of respecting the migrate option per collection.

Also, I'd like to point out that there is a marginally related bug in waterline-fixtures: https://github.com/devinivy/waterline-fixtures/issues/2

lynnaloo commented 9 years ago

@devinivy I simplified my fixtures more and it looks like my issue is with the nested models. Even if I specify the primary key id, it tries to add them again to the join table and gets a constraint violation.

Edit: I can now get this to work if migrate is set to alter, but then it does not work to initially create the database.

devinivy commented 8 years ago

Sadly gotta drop this– the problems around fixtures/migrations are a hard enough to merit their own tools! Next version of dogwater wont have fixtures (#40).