Bug 35338 - Error in SQL syntax when upgrading to 22.06.00.084
Summary: Error in SQL syntax when upgrading to 22.06.00.084
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Database (show other bugs)
Version: Main
Hardware: All All
: P5 - low major
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords: RM_priority
Depends on: 32162
Blocks:
  Show dependency treegraph
 
Reported: 2023-11-14 20:31 UTC by Magnus Enger
Modified: 2024-01-22 20:52 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Magnus Enger 2023-11-14 20:31:34 UTC
I have done a few upgrades to 22.11.x and 23.05.x now, but I have not seen this error before: 

Upgrade to 22.06.00.084  [21:21:43]: Bug 31162 - Add primary key to erm_eholdings_packages_agreements
ERROR - {UNKNOWN}: DBI Exception: 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 'CONSTRAINT erm_eholdings_packages_agreements_uniq,
                ADD PRIMARY K' at line 3 at /usr/share/koha/lib/C4/Installer.pm line 741

I can find that constraint in two places: 

* 220600079.pl:

        unless ( TableExists('erm_eholdings_packages_agreements') ) {
            $dbh->do(q{
                CREATE TABLE `erm_eholdings_packages_agreements` (
                    `package_id` INT(11) NOT NULL COMMENT 'link to the package',
                    `agreement_id` INT(11) NOT NULL COMMENT 'link to the agreement',
                    UNIQUE KEY `erm_eholdings_packages_agreements_uniq` (`package_id`, `agreement_id`),
                    CONSTRAINT `erm_eholdings_packages_agreements_ibfk_1` FOREIGN KEY (`package_id`) REFERENCES `erm_eholdings_packages` (`package_id`) ON DELETE CASCADE ON UPDATE CASCADE,
                    CONSTRAINT `erm_eholdings_packages_agreements_ibfk_2` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
            });
            say $out "Added new table 'erm_eholdings_packages_agreements'";
        }

* 220600084.pl:

        unless ( primary_key_exists('erm_eholdings_packages_agreements') ){
            $dbh->do(q{
                ALTER TABLE erm_eholdings_packages_agreements
                DROP FOREIGN KEY erm_eholdings_packages_agreements_ibfk_1,
                DROP FOREIGN KEY erm_eholdings_packages_agreements_ibfk_2,
                DROP CONSTRAINT erm_eholdings_packages_agreements_uniq,
                ADD PRIMARY KEY(`package_id`, `agreement_id`)
            });
            $dbh->do(q{
                ALTER TABLE erm_eholdings_packages_agreements
                ADD CONSTRAINT `erm_eholdings_packages_agreements_ibfk_1` FOREIGN KEY (`package_id`) REFERENCES `erm_eholdings_packages` (`package_id`) ON DELETE CASCADE ON UPDATE CASCADE,
                ADD CONSTRAINT `erm_eholdings_packages_agreements_ibfk_2` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE
            });
        }


Database version: MariaDB 5.7.34-0ubuntu0.18.04.1-log

OS: 
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.6 LTS
Release:	20.04
Codename:	focal
Comment 1 Jonathan Druart 2024-01-04 08:52:52 UTC
From bug 32162

(In reply to Nick Clemens from comment #9)
> (In reply to Jonathan Druart from comment #8)
> > What's the version of the DBMS, Nick?
> 
> Server version: 5.7.12 MySQL Community Server (GPL)

If this is a MySQL 5.7 thing, are we still supporting it?

See also bug 29805.
Comment 2 Katrin Fischer 2024-01-22 20:52:39 UTC
(In reply to Jonathan Druart from comment #1)
> From bug 32162
> 
> (In reply to Nick Clemens from comment #9)
> > (In reply to Jonathan Druart from comment #8)
> > > What's the version of the DBMS, Nick?
> > 
> > Server version: 5.7.12 MySQL Community Server (GPL)
> 
> If this is a MySQL 5.7 thing, are we still supporting it?
> 
> See also bug 29805.

22.06... is an update to 22.11. 22.11 as the LTS is still maintained and will be for a while.

We list these OS as supported on the requirements page in the wiki:

* Debian 12
* Debian 11
* Debian 10
* Ubuntu 22.04
* Ubuntu 20.04

So if 5.7 is in 20.04... we are still supporting it I guess?