Michael Hafen a écrit :
Calling out to atomic files would be a good idea. It only partially alleviates merge conflicts though, because the reference to the file still have to appear in updatedatabase.pl. You would end up missing an entire update rather than potentially messing up part of an update with a merge conflict. Missing the update is probably the better outcome though, and the updatedatabase.pl file will be much smaller that way.
So having atomic update files, referenced from updatedatabase.pl, for large updates (several lines of code) would be part of my proposal.
Could be in fact a loop calling update files while $data->{active}{ my $filecontent=File::Slurp(getfilename($data->{dbrev_name})) eval {$filecontent}} and not including them in the update file. Imagine we had a column activate in your table where an active update would HAVE to be done. We would be able to "check" that it has been done. I think that we should not have to do the loop over and over again at each page loading. But have a maintenance or an about screen where you can check against the updates applied and not applied.
As for having do() and undo() in the included file... It's a nice idea, but in practice un-deleting a column can be difficult. Imagine trying to reverse the database changes from the labels rewrite or the acquisitions rewrite.
I think that standard practice for updating is to backup the database first. Then restore from the backup if there is a problem. This practice falls flat though if you don't notice the problem right away. In which case having an undo() would be preferable. But it would be totally dependent on being able to pull the information from somewhere to fill the un-deleted column.
Really the reason I don't like the idea is because I'm lazy. That practically doubles the work it takes to change the database.
Comments?
I am lazy too... not only, busy also. And I would like the process to be as sure as possible so that maintenance is less time consuming. But this was day dreaming and brain dumping. -- Henri-Damien LAURENT BibLibre