SimpleInvoices Group Forum › Forums › Fearless359 SimpleInvoices Discussion Group › Update from 2019 to 2026
Tagged: foreign keys
- This topic has 6 replies, 2 voices, and was last updated 1 hour, 40 minutes ago by
altaphista.
-
AuthorPosts
-
December 11, 2025 at 1:50 am #2272
altaphista
ParticipantHi Fearless,
I finally decided to upgrade from 2019.2 to the newest version, but i’m getting stuck at sqlpatch331.
During the update I had an error earlier, and found what you mentioned in this post. I deleted these references, but now i get this error:[11-Dec-2025 10:36:43 Europe/Amsterdam] SqlPatchManager::runSqlPatch() - SqlPatchManager::prePatch331() = Unable to set Foreign Keys. [11-Dec-2025 10:39:15 Europe/Amsterdam] PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1005 Can't create table <code>my_fact</code>.<code>si_invoice_item_tax</code> (errno: 150 "Foreign key constraint is incorrectly formed") in /volume1/websites_folder/invoices/Inc/Claz/PdoDb.php:1287 Stack trace: #0 /volume1/websites_folder/invoices/Inc/Claz/PdoDb.php(1287): PDOStatement->execute() #1 /volume1/websites_folder/invoices/Inc/Claz/SqlPatchManager.php(145): Inc\Claz\PdoDb->query('ALTER TABLE ' si...') #2 /volume1/websites_folder/invoices/Inc/Claz/SqlPatchManager.php(215): Inc\Claz\SqlPatchManager::runSqlPatch(331, Array) #3 /volume1/websites_folder/invoices/index.php(247): Inc\Claz\SqlPatchManager::runPatches() #4 {main} thrown in /volume1/websites_folder/invoices/Inc/Claz/PdoDb.php on line 1287 [11-Dec-2025 10:42:17 Europe/Amsterdam] PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1005 Can't create table <code>my_fact</code>.<code>si_invoice_item_tax</code> (errno: 150 "Foreign key constraint is incorrectly formed") in /volume1/websites_folder/invoices/Inc/Claz/PdoDb.php:1287 Stack trace: #0 /volume1/websites_folder/invoices/Inc/Claz/PdoDb.php(1287): PDOStatement->execute() #1 /volume1/websites_folder/invoices/Inc/Claz/SqlPatchManager.php(145): Inc\Claz\PdoDb->query('ALTER TABLE 'si...') #2 /volume1/websites_folder/invoices/Inc/Claz/SqlPatchManager.php(215): Inc\Claz\SqlPatchManager::runSqlPatch(331, Array) #3 /volume1/websites_folder/invoices/index.php(247): Inc\Claz\SqlPatchManager::runPatches() #4 {main} thrown in /volume1/websites_folder/invoices/Inc/Claz/PdoDb.php on line 1287-
This topic was modified 1 day, 10 hours ago by
altaphista.
December 11, 2025 at 5:50 pm #2274fearless359
KeymasterCheck the Version Update Process menu topic and the Unable to set Foreign Keys Error Handling tab. What you don’t show in your error log message is the list of foreign key values that prevent the foreign key constraints from being implemented. This issues need to be manually resolved before the update and proceed.
-
This reply was modified 18 hours, 31 minutes ago by
fearless359.
-
This reply was modified 18 hours, 30 minutes ago by
fearless359.
December 12, 2025 at 3:15 am #2277altaphista
ParticipantThanks for your reply @fearless359. I’ve already done all the steps in the Version Update Process topic. I accidently copied to many rows from the php.log in my first quote, it should only be this what’s below. I manually deleted the 16 references to
invoice_item_taxdo not get that error any more.
Just to be sure I ran the update script again and this is the only error I get:[12-Dec-2025 12:12:12 Europe/Amsterdam] PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1005 Can't create table 'my_fact'.'si_invoice_item_tax' (errno: 150 "Foreign key constraint is incorrectly formed") in /volume1/websites_folder/invoices/Inc/Claz/PdoDb.php:1287 Stack trace: #0 /volume1/websites_folder/invoices/Inc/Claz/PdoDb.php(1287): PDOStatement->execute() #1 /volume1/websites_folder/invoices/Inc/Claz/SqlPatchManager.php(145): Inc\Claz\PdoDb->query('ALTER TABLE 'si...') #2 /volume1/websites_folder/invoices/Inc/Claz/SqlPatchManager.php(215): Inc\Claz\SqlPatchManager::runSqlPatch(331, Array) #3 /volume1/websites_folder/invoices/index.php(247): Inc\Claz\SqlPatchManager::runPatches() #4 {main} thrown in /volume1/websites_folder/invoices/Inc/Claz/PdoDb.php on line 1287December 12, 2025 at 5:12 am #2278altaphista
ParticipantI’ve been diving into your SqlPatchManager code trying to retrieve the error. After some time debugging I saw that this query threw an error:
ALTER TABLE 'si_invoice_item_tax' ADD CONSTRAINT 'si_invoice_item_tax_ibfk_2' FOREIGN KEY ('invoice_item_id') REFERENCES 'si_invoice_items'('id') ON DELETE NO ACTION ON UPDATE CASCADE;.Digging further into the database buildup I stumbled upon the error: invoice_items.id did not have the attritbute ‘UNSIGNED’.
The fix:
ALTER TABLE 'si_invoice_items' CHANGE 'id' 'id' INT(11) UNSIGNED NOT NULL AUTO_INCREMENT;Thanks again for your time and efforts Fearless!
-
This reply was modified 7 hours, 8 minutes ago by
altaphista. Reason: typo
-
This reply was modified 7 hours, 8 minutes ago by
altaphista.
December 12, 2025 at 7:57 am #2281altaphista
ParticipantI’ve got a new error now…
[12-Dec-2025 14:16:03 Europe/Amsterdam] modules/invoices/manage.php Unable to store json data.December 12, 2025 at 10:20 am #2282fearless359
KeymasterThe json is stored in the public directory. If this directory doesn’t exist, it is made by SI. Check the directory’s existence and the access permissions. From shell command line the command is
ls -l publicassuming you are in the root directory. On my system (windows running xampp), SI builds the directory with -rw-r–r– or 644 access. If I delete the directory and build it from the shell, I get drwxr-xr-x or directory with 755 access. Which both work on my system.Bottom line, it should come down to directory access permissions. If you want to go whole hog to avoid any possible restrictions you can
chmod 777 publicand give universal access to anyone. This is overkill and should be used just for testing.Hope this helps.
December 12, 2025 at 10:41 am #2283altaphista
ParticipantCheers thanks that worked! I just gave my httpd service the needed read&write access.
-
This topic was modified 1 day, 10 hours ago by
-
AuthorPosts
- You must be logged in to reply to this topic.
Recent Comments