I’m using datamapper to store a lot of nokogiri-scraped data to rows
This set of data is always changing weekly, and occasionally I want to give the user the ability to “purge posts” so they can re-acquire new data.
Inside the method of post ‘/purge’ do (sinatra) I have the following
Post.all.destroy
The problem is it leaves the key at the auto-incremented amount. While this set of data is associated with other tables, that other data is also being cleared out as well, so I know the keys will have no problem matching. Each purge, my keys are getting huge (40,000) after some period of time though.
The reason that I don’t use DataMapper.auto_migrage! is because there is one particular table (with no associations) that I don’t want to touch (the Settings table).
PS. I tagged activerecord even though I’m using datamapper because i assume the process is very similar, just syntactically different.
The responsibility for
AUTO INCREMENTvalues belongs to the DB engine, not to the ORM. So, if you want to reset its value, you have to issue a query like:Probably you will have something like: