Bug 9191

Summary: updatedatabase.pl must have ability to run updates only up to a particular revision
Product: Koha Reporter: Jared Camins-Esakov <jcamins>
Component: Installation and upgrade (command-line installer)Assignee: Jared Camins-Esakov <jcamins>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P1 - high CC: elliott, jonathan.druart, paul.poulain
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 7167    
Attachments: Bug 9191: updatedatabase.pl should only run updates up to the current version
Bug 9191: updatedatabase.pl should only run updates up to the current version
Bug 9191: updatedatabase.pl should only run updates up to the current version
Bug 9191: updatedatabase.pl should only run updates up to the current version

Description Jared Camins-Esakov 2012-12-03 12:58:02 UTC
With the introduction of the non-linear updates in bug 7167, the current updatedatabase.pl mechanism will be phased out. However, it will behoove us to keep copies of the updates that are performed by the non-linear system in the current updatedatabase.pl at least until the 3.12 release, as an insurance policy. In order to do that, though, it must be possible to specify that updates greater than X.XX.XX.XXX should not be run. Replacing our simplistic if ($DBversion < C4::Context->preference('Version')) with a subroutine call that checks these things will solve the problem.
Comment 1 Jared Camins-Esakov 2012-12-03 21:38:02 UTC Comment hidden (obsolete)
Comment 2 Jared Camins-Esakov 2012-12-04 14:14:02 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2012-12-04 14:30:36 UTC
In order to be sure to understand.

Currently the routine final_linear_version returns the kohaversion.pl value.
Once the Bug 7167 will be pushed, this routine will return the last version number in the updatedatabase.pl file ?
Comment 4 Jared Camins-Esakov 2012-12-04 14:39:30 UTC
(In reply to comment #3)
> In order to be sure to understand.
> 
> Currently the routine final_linear_version returns the kohaversion.pl value.
> Once the Bug 7167 will be pushed, this routine will return the last version
> number in the updatedatabase.pl file ?

My idea is that it will be changed to:
return '3.11.000.005';

And then we can use that instead of $koha39.
Comment 5 Jonathan Druart 2012-12-04 15:19:33 UTC Comment hidden (obsolete)
Comment 6 Elliott Davis 2012-12-07 20:40:00 UTC
Created attachment 13951 [details] [review]
Bug 9191: updatedatabase.pl should only run updates up to the current version

[Signed-off][Passed QA]
Check whether a given update should be run when passed the proposed
version number. The update will always be run if the proposed version
is greater than the current database version and less than or equal to
the version returned by C4::Context->final_linear_version (initially set
to be equal to the version in kohaversion.pl). The update is also run if
the version contains XXX, though this behavior will be changed following
the adoption of non-linear updates as implemented in bug 7167.

To test:
1) Make sure that the first example database update added by this patch
   in installer/data/mysql/updatedatabase.pl has a version number one
   greater than the version of Koha you have installed.
2) Set the Version syspref back one version behind your current version.
3) Navigate to the main page of the staff client, and log in to the
   installer.
4) Confirm that the update page claims to have rerun the previous update
   and has displayed the log message:
   "Upgrade to 3.11.00.XXX done (Bug 9191: You should see this)"
   but not the log message:
   "Upgrade to [version number] done (Bug 9191: You shouldn't see this)"

Note: the sample database revisions will be removed by the RM before
this patch is pushed to master.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
works great

Signed-off-by: Elliott Davis <elliott@test.bywatersolutions.com>
Works as expected.  Test plan is great. Code looks to be adherent to standards.
Comment 7 Jared Camins-Esakov 2012-12-11 13:32:42 UTC
This patch has been pushed to master.