Commit graph

1660 commits

Author SHA1 Message Date
d9069b5b60 Bug 14764 - DBRev 16.12.00.012
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-03-03 18:30:01 +00:00
50c5708fe8 Bug 17260 - DBRev 16.12.00.011
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-03-03 16:45:22 +00:00
Blou
77337a2ab5 Bug 17260: updatedatabase.pl fails on invalid entries in ENUM and BOOLEAN columns
The loading of file admin/searchengine/elasticsearch/mappings.yaml
specifies 'type' as empty, which fails with Mysql 5.7+ which is more
stringent.

Also, forcing an empty value into a boolean also fails.

Both issues arise when updatedatabase.pl hit 3.23.00.050.

NOTE: both issues could also be resolved by actually setting values in
      the load file. This doesn't make this solution incorrect, though.

To Test/reproduce:
-1) Happens with Mysql 5.7.4.  Maybe earlier, but certainly at
    that point. Use a Xenial kohadevbox to more easily test.
0) Find a database on 3.22 or earlier, save it.
    a) place
           sql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
       into the [mysqld] section of /etc/mysql/mysql.conf.d/mysqld.cnf
    b) restart you mysql server
    c) drop the db and recreate it
    d) checkout the 3.22.x branch
    e) do a web install
    f) remove the added sql_mode
    g) restart the mysql server
1) Set your code base to master
2) run updatedatabase.pl
3) See the errors on 3.23.00.050
4) Apply the patch
5) Reload the 3.22 db.
   a) repeat steps 0(a)-0(g)
   b) don't forget the caching issues
6) succeed with updatedatabase.pl
7) drop the db and recreate it
8) run the web installer
9) notice no issues either.
10) run koha qa test tools

NOTE: This bug only solved the upgrade portion.
      I added the kohastructure.sql change as well.
      I confirmed that all the code changes were
      triggered with this test plan.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Mehdi Hamidi <mehdi.hamidi@inlibro.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-03-03 16:43:00 +00:00
11bae489bc Bug 17216: Fix SQL statement to setting marc_subfield_structure.authorised_value to NULL
We want to update it if it's empty, not equal to ';'
nopaste vim mode is to blame

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-02-27 11:03:18 +00:00
9a172ac2ef Bug 16034: (followup) Fix DB update and schema files
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-02-26 16:39:17 +00:00
e9d0337f32 Bug 16034 - DBRev 16.12.00.010
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-02-21 20:01:17 +00:00
d64e4707ff Bug 17453 - DBRev 16.12.00.009
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-02-17 17:17:12 +00:00
1d2001803c Bug 15503 - DBRev 16.12.00.008
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-02-14 15:01:24 +00:00
6abf904bff Bug 17960 - DBRev 16.12.00.007
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-02-06 17:43:47 +00:00
9fe4f3b2ba Bug 17813 - DBRev 16.12.00.006
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-01-20 14:00:47 +00:00
07626b3b6e Bug 17913 - DBRev 16.12.00.005
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-01-20 13:58:52 +00:00
2b303129b8 Bug 17914: Do not try and add the updated_on columns to the borrowers and deletedborrowers table
Bug 10459 has been backported and the DB entry (add borrowers.updated_on and
deletedborrower.updated_on) is now played in
  - 16.06.00.027
  - 16.05.00.002
  - 3.22.08.001

This will raise a MySQL warning if the column already exists.
  DBD::mysql::db do failed: Duplicate column name 'updated_on'

Since bug 17234 we have now a subroutine (C4::Installer::column_exists) to test
if a column exists.
When a DB entry modifying the DB structure is backported, it HAS TO check if the
column, constraint or table exists before executing the query.

Test plan:
git checkout 3.22.x (16.05.x or 16.11.x)
install Koha
git checkout master
execute the installer
=> Without this patch you will get a warning when adding borrowers.updated_on)
=> With this patch, you should not get it

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-01-18 15:22:03 +00:00
c5a758d9a0 Bug 17196 - DBRev 16.12.00.004
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-01-13 14:00:55 +00:00
46085442e0 Bug 17486 - DBRev 16.12.00.003
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-01-13 12:35:11 +00:00
a2afebe115 Bug 14187 - DBRev 16.12.00.002
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-01-13 12:24:39 +00:00
05fdd855c8 Bug 17234: Need to separate KEY and FOREIGN KEY checks
In the previous patch we use the constraint_exists subroutine to verify
if an index or a foreign key exists.
But the `SHOW INDEX` query does not return foreign keys (as its name
suggests!).
We need another subroutine foreign_key_exists to check the FK existence.

I have found that because t/db_dependent/TestBuilder.t fails on
oai_sets_biblios, because oai_sets_biblios_ibfk_1 has not been removed.

Test plan:
0/ Do not apply this patch
1/ Use a 3.20 DB
2/ update the DB
3/ SHOW CREATE TABLE oai_sets_biblios
will display oai_sets_biblios_ibfk_1

Apply the patch and repeat 1, 2, 3
=> Will not display oai_sets_biblios_ibfk_1
It has been removed as expected.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-01-12 12:43:10 +00:00
0b15c5e2cc Bug 17234: Move new subroutines to C4::Installer
Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-01-11 10:52:10 +00:00
c08922180e Bug 17234: Add constraint_exists and column_exists to updatedatabase.pl
These 2 subroutines will help us deal with the absense of ALTER IGNORE
TABLE

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-01-11 10:52:10 +00:00
Mark Tompsett
4ea484677e Bug 17234: Follow up to handle new problems
Bug 16276 added two more ALTER IGNORES. This removes them.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-01-11 10:52:09 +00:00
Blou
acf425bbbc Bug 17234 - updatedatabase.pl's ALTER IGNORE break with mysql 5.7.4+
The doc says: "As of MySQL 5.7.4, the IGNORE clause for ALTER TABLE is removed and its use produces an error."
This fix replaces ALTER IGNORE with ALTER in updatedatabase.pl

To TEST, try an upgrade from 3.18 to 3.22 after installing the latest mysql (at least 5.7.4, by the doc).
Some will fail with error

DBD::mysql::db do failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IGNORE TABLE aqbasket
            ADD KEY authorisedby (authorisedby)' at line 1 [for Statement "
        ALTER IGNORE TABLE aqbasket
            ADD KEY authorisedby (authorisedby)
    "] at ./installer/data/mysql/updatedatabase.pl line 10563.

0) Find a database on 3.18, save it.
1) Set your code base to 3.22(or master)
2) run updatedatabase.pl
3) See the errors.
4) Apply the patch
5) Reload the 3.18 database
6) succeed with updatedatabase.pl

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-01-11 10:52:09 +00:00
28d81cb7bb Bug 17767 - DBRev 16.12.00.001
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-12-28 13:59:03 +00:00
c9e95aa22e Bug 17666: Revert "Bug 16685 [QA Followup] - Use Path::Tiny::slurp instead of File::Slurp"
This reverts commit 7ac1bc3537.

On a kohadevbox:
Error flock (1) on
'/home/vagrant/kohaclone/installer/data/mysql/atomicupdate/bug_xxxx.perl':
No locks available at installer/data/mysql/updatedatabase.pl line 13637.

This is because Path::Tiny->slurp[_utf8] uses flocks which does not work
with NFS

Test plan:
Execute a .perl atomic update file on a kohadevbox
=> Without this patch you should get the flock error
=> With this patch the update should work fine

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-12-16 11:14:49 +00:00
6f4cbc8dad Bug 17676: Update default COLLATE of marc_subfield_structure
(This issue has been raised on bug 17216 comments 93-103)
On bug 11944 (3.19.00.006) we updated the default COLLATE for all our tables to
utf8_unicode_ci but not the marc_subfield_structure table.
Indeed we want to keep tagsubfield a utf8_bin (to allow lowercase and uppercase
of the same letter for subfields).
We should have set the default collate to utf8_unicode_ci for further changes.

This patch updates the DB entry 3.19.00.006 to set the default COLLATE to this
table (for people upgrading from prior to 3.19.00.006) and set this
default COLLATE on 16.06.00.033 (for people upgrading from after 3.19.00.006).

The error is:
DBD::mysql::db do failed: Can't create table `koha_kohadev`.`#sql-306_9f9` (errno: 150 "Foreign key constraint is incorrectly formed") [for Statement "
            ALTER TABLE marc_subfield_structure
            MODIFY COLUMN authorised_value VARCHAR(32) DEFAULT NULL,
            ADD CONSTRAINT marc_subfield_structure_ibfk_1 FOREIGN KEY (authorised_value) REFERENCES authorised_value_categories (category_name) ON UPDATE CASCADE ON DELETE SET NULL;
            "] at installer/data/mysql/updatedatabase.pl line 13175.
Upgrade to 16.06.00.033 done (Bug 17216 - Add a new table to store authorized value categories)

Test plan:
1/ git checkout v3.18.00
2/ Do an install
3/ git checkout master;
4/ perl installer/data/mysql/updatedatabase.pl
=> Without this patch, you get the error
=> With this patch applied you will not get it and the default COLLATE for
marc_subfield_structure will be correctly set. Make sure tagsubfield is
still utf8_bin

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Will put some notes on the Bugzilla report.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-11-29 17:41:34 +00:00
5485f10ed2 DBRev 16.12.00.000 - the road goes ever on
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-11-29 17:38:30 +00:00
3c9d916641 Bug 17292 Follow-up, fix typos
- wrong assignation
- reference to 'serials' table rather than 'serial'

Signed-off-by: Frédéric Demians <f.demians@tamil.fr>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-11-28 11:54:46 +00:00
7636c68d76 DBRev 16.11.00.000
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-11-22 17:48:00 +00:00
312783f8fc Bug 8835 - DBRev 16.06.00.050 2016-11-22 17:45:35 +00:00
0fee84690e Bug 8835: Drop issn_idx for completeness
When dbrev 3.15.00.049 failed, the still existing issn_idx must have
been the cause.
This patch only adjusts the old db rev.
Still thinking if we also need a new db rev to fix isbn and issn for
those installs where 3.15.00.049 failed too. (In that case the fields
may not have been changed to mediumtext and no indexes were added.)

Test plan:
Ideally, run an upgrade from something older than 3.15.00.49.
But running the added sql command from the command line might convince
you too.

Signed-off-by: Nicolas Legrand <nicolas.legrand@bulac.fr>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
2016-11-22 17:45:21 +00:00
141538fb51 Bug 17391 - DBRev 16.06.00.049
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-11-22 11:38:26 +00:00
d9be9950b3 Bug 17663 - DBRev 16.06.00.048
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-11-21 16:34:46 +00:00
674d3875c8 Bug 17518 - DBRev 16.06.00.047
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-11-02 11:02:09 +00:00
e67c202609 Bug 15581 - DBRev 16.06.00.046
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-11-02 10:53:35 +00:00
10b3bb8f46 Bug 17443 - DBRev 16.06.00.045
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-28 16:51:58 +00:00
ade5362586 Bug 17397 - DBRev 16.06.00.044
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-28 15:43:20 +00:00
3f7098a02f Bug 17356: Add atomic update .perl skeleton file
To show devs how it should be written.

Test plan:
% cp installer/data/mysql/atomicupdate/skeleton.perl
installer/data/mysql/atomicupdate/bug_XXXXX.perl
% perl installer/data/mysql/updatedatabase.pl

You should see:
DEV atomic update: bug_xxxxx.perl
Upgrade to 16.06.00.XXX done (Bug XXXXX - description)

Signed-off-by: Liz Rea <liz@catalyst.net.nz>
Very good. I'll submit a patch for the readme to make the instructions better.

Signed-off-by: Liz Rea <liz@catalyst.net.nz>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-28 14:47:04 +00:00
25adf52334 Bug 13323 - DBRev 16.06.00.043
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-28 14:28:40 +00:00
9beffec5aa Bug 13321 - DBRev 16.06.00.042
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-28 14:23:24 +00:00
c7bc14cead Bug 14629 - DBRev 16.06.00.041
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-28 11:59:55 +00:00
2354e41b61 Bug 5260 - DBRev 16.06.00.040
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-28 11:54:58 +00:00
5d5a1509d1 Bug 14598 - DBRev 16.06.00.039
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-28 11:30:38 +00:00
3660c451a3 Bug 14598: [QA Follow-up] Small changes
[1] Renames the dbrev version to XXX; adding a my for $sth, although
    not strictly necessary it feels better.
[2] Circulation.t stumbles over:
    Undefined subroutine &C4::Circulation::GetItem called at ... line 1283.
    Somehow this is related to use_ok instead of a regular use.
    Worked around this by require_ok and adding a regular use.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-28 11:29:59 +00:00
Tomas Cohen Arazi
3fa514133b Bug 14598: (QA followup) use deleted{items|biblioitems} during upgrade
If the 'statistics' table contains circulation information about items
that are no longer on the DB it will raise a warning. This patch
makes the updatedatabase.pl script use the deleteditems and deletedbiblioitems
tables to get information for those items on the statistics table.

To reproduce:
- Have your sample DB contain some circulation data on the statistics table
- Make sure some of them have NULL itemtype:
> UPDATE statistics SET itemtype = NULL WHERE type='return';
- Check the upgrade query catches them:
> SELECT s.itemnumber, i.itype, b.itemtype FROM  ( SELECT DISTINCT itemnumber    FROM statistics    WHERE ( type = "return" OR type = "localuse" ) AND itemtype IS NULL ) s  LEFT JOIN  ( SELECT itemnumber,biblionumber, itype      FROM items    UNION    SELECT itemnumber,biblionumber, itype      FROM deleteditems ) i  ON (s.itemnumber=i.itemnumber)  LEFT JOIN  ( SELECT biblionumber, itemtype      FROM biblioitems    UNION    SELECT biblionumber, itemtype      FROM deletedbiblioitems ) b  ON (i.biblionumber=b.biblionumber);
+------------+-------+----------+
| itemnumber | itype | itemtype |
+------------+-------+----------+
|        732 | BK    | BK       |
|        731 | BK    | BK       |
+------------+-------+----------+
2 rows in set (0.00 sec)

- Delete the items, and some biblio too.
- Re-run the query
=> SUCCESS: Same results
- Go reset to NULL the itemtypes
> UPDATE statistics SET itemtype = NULL WHERE type='return';
- Run the updatedatabase.pl script:
 $ sudo koha-shell koahdev ; cd kohaclone
 $ perl installer/data/mysql/updatedatabase.pl
=> SUCCESS: No warnings

Note: It is possible that on production sites, if the sysadmin is cleaning the
deleted{items|biblioitems|biblio} tables, there will be warnings. This is expected
as they need to know some data lacks information.

Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-28 11:29:59 +00:00
c042307db3 Bug 14598 [QA Followup] - Update localuse statistics also
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-28 11:29:58 +00:00
2cdec7ff91 Bug 14598: (DB update) fix NULL itemtypes in statistics on 'return' rows
This patch introduces an updatedatabase.pl entry that takes care of
updating existing statistics rows.

It does so by looping on the statistics rows, collecting itemnumber occurences
that are have NULL itemtypes.
It then chooses the right itemtype following what is proposed on bug 14651, and
then updates the rows in statistics using the calculated itemtype.

Regards

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-28 11:29:57 +00:00
239b81c1dd Bug 14874 - DBRev 16.06.00.038
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-27 14:02:19 +00:00
33ff591731 Bug 14610 - DBRev 16.06.00.037
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-26 12:22:37 +00:00
2578d8cd96 Bug 5670 - DBRev 16.06.00.036
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-21 18:20:44 +00:00
8b570a8808 Bug 15131 - DBRev 16.06.00.035
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-21 17:28:42 +00:00
35101c9127 Bug 10455 - DBRev 16.06.00.034
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-21 14:37:46 +00:00
Brendan Gallagher
3fe925ee19 UPdating the DBREv for Bug 17216 - Add a new table to store authorized
value categories
2016-10-11 11:18:50 +00:00