Error During Database Migration: Foreign Key Issues in Koha 22.05
Title
Question
<font face="Arial, Helvetica">Hello Koha Community,
I am currently migrating an old Koha database to a new installation (Koha version 22.05 on Ubuntu 22.04). I followed the steps outlined in this guide: <a class="msgbody" href="https://kohageek.blogspot.com/2015/08/move-old-koha-database-to-new.html" target="_blank">https://kohageek.blogspot.com/2015/08/move-old-koha-database-to-new.html</a>.
During Step 4 (sudo koha-upgrade-schema library), I encountered the following error:
Upgrading database schema for library
{UNKNOWN}: DBI Exception: DBD::mysql::db do failed: Cannot drop table 'subscription_frequencies' referenced by a foreign key constraint 'subscription_ibfk_1' on table 'subscription'. at /usr/share/perl5/DBIx/Class/Schema.pm line 1118.
DBIx::Class::Schema::throw_exception(Koha::Schema=HASH(0x55e0c2885d78), "DBI Exception: DBD::mysql::db do failed: Cannot drop table 's"...) called at /usr/share/perl5/DBIx/Class/Storage.pm line 113
DBIx::Class::Storage::throw_exception(DBIx::Class::Storage::DBI::mysql=HASH(0x55e0c7b4bdd0), "DBI Exception: DBD::mysql::db do failed: Cannot drop table 's"...) called at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1623
DBIx::Class::Storage::DBI::__ANON__("DBD::mysql::db do failed: Cannot drop table 'subscription_fre"..., DBI::db=HASH(0x55e0c83a7f90), undef) called at /usr/share/koha/intranet/cgi-bin/installer/data/mysql/updatedatabase.pl line 7382
Steps Followed:
Backed up the old database using mysqldump.
Imported the backup into the new Koha instance.
Verified database user permissions.
Encountered the above error when upgrading the schema.
Observations:
The issue seems to be related to foreign key constraints between the subscription_frequencies and subscription tables. I believe this is causing the schema upgrade to fail.
Request for Assistance:
Could anyone guide me on resolving this foreign key constraint issue?
</font>
Thank you in advance for your help. I appreciate the time and effort of the community in assisting users like me.
</font>
I am currently migrating an old Koha database to a new installation (Koha version 22.05 on Ubuntu 22.04). I followed the steps outlined in this guide: <a class="msgbody" href="https://kohageek.blogspot.com/2015/08/move-old-koha-database-to-new.html" target="_blank">https://kohageek.blogspot.com/2015/08/move-old-koha-database-to-new.html</a>.
During Step 4 (sudo koha-upgrade-schema library), I encountered the following error:
Upgrading database schema for library
{UNKNOWN}: DBI Exception: DBD::mysql::db do failed: Cannot drop table 'subscription_frequencies' referenced by a foreign key constraint 'subscription_ibfk_1' on table 'subscription'. at /usr/share/perl5/DBIx/Class/Schema.pm line 1118.
DBIx::Class::Schema::throw_exception(Koha::Schema=HASH(0x55e0c2885d78), "DBI Exception: DBD::mysql::db do failed: Cannot drop table 's"...) called at /usr/share/perl5/DBIx/Class/Storage.pm line 113
DBIx::Class::Storage::throw_exception(DBIx::Class::Storage::DBI::mysql=HASH(0x55e0c7b4bdd0), "DBI Exception: DBD::mysql::db do failed: Cannot drop table 's"...) called at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1623
DBIx::Class::Storage::DBI::__ANON__("DBD::mysql::db do failed: Cannot drop table 'subscription_fre"..., DBI::db=HASH(0x55e0c83a7f90), undef) called at /usr/share/koha/intranet/cgi-bin/installer/data/mysql/updatedatabase.pl line 7382
Steps Followed:
Backed up the old database using mysqldump.
Imported the backup into the new Koha instance.
Verified database user permissions.
Encountered the above error when upgrading the schema.
Observations:
The issue seems to be related to foreign key constraints between the subscription_frequencies and subscription tables. I believe this is causing the schema upgrade to fail.
Request for Assistance:
Could anyone guide me on resolving this foreign key constraint issue?
</font>
<font face="Arial, Helvetica"> Is there a recommended approach for handling schema upgrades when foreign key relationships are involved?
</font>
</font>
<font face="Arial, Helvetica">
</font>
</font>
<font face="Arial, Helvetica">The old koha version is 3.12.00.000.
is the issue arises for the significant version gap between Koha 3.12.00.000 and Koha 22.05?
Should I import the database in intermediate versions? </font>
<font face="Arial, Helvetica"> is the issue arises for the significant version gap between Koha 3.12.00.000 and Koha 22.05?
Should I import the database in intermediate versions? </font>
Thank you in advance for your help. I appreciate the time and effort of the community in assisting users like me.
</font>
Koha-Library-Management-System General