[Koha-bugs] [Bug 27880] Database migrations in separate files

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Mar 5 13:02:18 CET 2021


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27880

--- Comment #1 from Julian Maurice <julian.maurice at biblibre.com> ---
Created attachment 117835
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=117835&action=edit
Bug 27880: Database migrations in separate files

The goals of this patch are:
- stop the growth of updatedatabase.pl file (which is nearly 24k lines
long at the moment)
- reduce the manual work for RM/RMaints (copy/paste of code from
atomicupdate to updatedatabase.pl + increase of Koha version)
- provide a simple framework for a better control of the database update
process

Database migrations are regular Perl scripts that return migration
metadata and code in a hashref.
Their filename is meaningful. It should always start with a timestamp
(in the form YYYYMMDDHHMMSS), which is used for executing migrations in
the correct order. It should also contain a short description.

Once a migration has been successfully executed, its name is stored into
a new table `executed_migrations`. This is how we avoid executing a
migration twice.

With this new system, the 'Version' system preference becomes useless,
as well as the 4th part of the Koha version. A good part of the patch is
about adapting the code to these changes.

Test plan:
1. Apply patch and restart starman
2. Go to the staff interface, you should be redirected to the installer
3. Enter your credentials, click on "Continue to the next step" until
   you arrive at the "Update database" step
4. You should now see the following message:
   Pending migrations:

     20201002135449-create-executed-migrations-table.pl
   Click on "Update your database"

5. Now you should see
   Update report :

   Migration done:
   20201002135449-create-executed-migrations-table.pl (Create table
executed_migrations)

   Everything went okay. Update done.

6. Log into Koha
7. Verify that the About page shows the correct version
8. Verify that the 'Help' link in the top right corner redirects to the
   correct version of the manual

9. Now, do a fresh install and verify that the executed_migrations table
   exists and is not empty at the end of the install process

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list