Updating and moving to a new server

Think I managed to get this done, Chat GPT timed out in free mode so I used Chat2DB. One of the table updates sql changes threw an error and I used CHATGPT to fix this error.

– Update the ip_products table
MODIFY provider_name text DEFAULT NULL,
ADD COLUMN unit_id int(11) DEFAULT NULL AFTER tax_rate_id,
ADD COLUMN product_tariff int(11) DEFAULT NULL AFTER unit_id; how do i fix this problem in myphpadmin

Seems like it worked, then I continued with the rest of the Chat2DB method (about 20 steps all up) It can do it slightly differently and the third try looked best to me for some reason…

It all Looks very promising om my test server, but I still have some testing to do and had to re-edit the pdf invoice templates etc to the latest versions with my edits and invoicing requirements. (e.g. tax invoice instead of invoice and used the language files to change VAT to GST etc.

Fingers crossed!

Your “hello chat gpt” hint was the trick UnderDog. Thanks again!

1 Like

Also I think Chat gpt could not paste the whole Database table and Chat2DB was fine with it.

1 Like

In case you need to paste the entire database or other large chunks:

“Hey ChatGPT, stand by, more source coming.
Wait with your response until i’ve pasted everything”

Then you can just paste in 2 / 3 chunks

Thanks for the hint

Chat2db was actually very easy to understand. Posted an image of the start and end of the tasks FYI

After the database update us complete and after you’ve made a couple of extra backups, you’re not done yet.

I think you’re 75% there.

Take a look here: InvoicePlane/application/modules/setup/models/Mdl_setup.php at development · InvoicePlane/InvoicePlane · GitHub

Remember having to to to /setup after all of this is done? You don’t have to, but you might need to.

See this?
public function upgrade_023_1_5_0()
Those extra things were done during the upgrade, so when users were going to /setup these functions were executed

You might have skipped those functions, because aftrr this is done your ip_versions table is up-to-date.

I still think you need those extra things.
Ask ChatGPT or Chat2db.
Just paste the link or the contents of the file.

Tell them you’re at version 1.6.2 but not all updates to the database have been applied.

And then let’s see what they say.

Response 1

It appears you’re experiencing issues with database updates not being fully applied after upgrading to InvoicePlane version 1.6.2. This is a known issue that was reported during the beta phase of version 1.6.2, where the database migration process could fail, leaving the application in an inconsistent state. The development team addressed this problem in the final release of 1.6.2 by correcting the migration scripts. ​GitHub

Recommended Steps to Resolve the Issue:

  1. Verify Your Current Version:
  • Ensure that you are running the final release of InvoicePlane 1.6.2. If you had previously installed a beta version, it’s advisable to upgrade to the final release to benefit from the fixes implemented.​
  1. Backup Your Data:
  1. Reapply the Update:
  • Download the final release of InvoicePlane 1.6.2 from the official source.
  • Replace the existing files in your InvoicePlane installation with the new ones, ensuring not to overwrite the following:
    • /application/config/database.php
    • Customized templates in /application/views/
    • Custom styles in assets/core/css/custom.css and assets/core/css/custom-pdf.css
    • Uploaded files in the uploads/ directory
  • Access http://yourdomain.com/setup in your browser and follow the on-screen instructions to complete the update process. ​wiki.invoiceplane.com+2InvoicePlane Community Forums+2wiki.invoiceplane.com+2wiki.invoiceplane.com
  1. Check for Successful Migration:
  • After completing the setup, verify that all database migrations have been applied correctly. You can check the ip_versions table in your database to see which migration scripts have been executed.​
  1. Enable Debugging (If Issues Persist):
  • If you continue to experience problems, enable debugging in InvoicePlane to identify any errors:
    • Open /index.php in a text editor.
    • Set the environment to development by changing:

php

CopyEdit

define('ENVIRONMENT', 'development');
* This will display detailed error messages that can help in troubleshooting.
  1. Consult the Community:
  • If you’re still facing issues after following the above steps, consider reaching out to the InvoicePlane community forums for assistance. Provide details about the errors you’re encountering and any steps you’ve already taken. ​

By following these steps, you should be able to resolve the database update issues in InvoicePlane 1.6.2. If you need further assistance, feel free to ask.

Response 2

If you’re on InvoicePlane version 1.6.2 and noticing that not all database updates have been applied, here are some steps and considerations to help you resolve the issue:


:white_check_mark: 1. Verify the Upgrade Process

Ensure that you followed the official upgrade procedure:

  1. Backup: Always start by backing up your database and files.
  2. Download: Obtain the latest version from the official InvoicePlane website.
  3. Replace Files: Copy all files to your InvoicePlane installation directory, but do not overwrite:
  • ipconfig.php
  • Customized templates in /application/views/
  • Custom styles: assets/core/css/custom.css and assets/core/css/custom-pdf.css
  • Uploaded files in the uploads/ folder
  1. Run Setup: Navigate to http://yourdomain.com/setup and follow the on-screen instructions. The application should automatically apply necessary updates .

:hammer_and_wrench: 2. Check for Applied Updates

InvoicePlane tracks applied database updates in the ip_versions table. To verify which updates have been applied:

  • Access your database using a tool like phpMyAdmin or via command line.
  • Execute the following query:

sql

CopyEdit

SELECT version_file FROM ip_versions ORDER BY version_date_applied;
  • Compare the listed version_file entries with the SQL files present in the application/modules/setup/sql/ directory. Any missing files indicate updates that haven’t been applied.

:bug: 3. Address Known Issues in v1.6.2

There have been reports of issues related to database migrations in version 1.6.2. Specifically, an error concerning database migration was discussed in GitHub Issue #1147. The issue pertained to problems with SQL migrations, and a fix was implemented in pull request #1159. Ensure that your installation includes this fix.


:arrows_counterclockwise: 4. Manually Apply Missing Updates

If certain updates haven’t been applied:

  1. Identify Missing SQL Files: Based on the comparison from step 2, note which SQL files are missing.
  2. Apply SQL Scripts: For each missing SQL file:
  • Open the file to review its contents.
  • Execute the SQL commands manually using your database management tool.
  • After applying, insert a corresponding record into the ip_versions table to indicate the update has been applied.Example:

sql

CopyEdit

INSERT INTO ip_versions (version_date_applied, version_file, version_sql_errors)
VALUES (UNIX_TIMESTAMP(), 'missing_file.sql', 0);

Replace 'missing_file.sql' with the actual filename.

Caution: Always back up your database before performing manual updates.


:test_tube: 5. Test in a Staging Environment

Before applying changes to your live environment:

  • Set up a staging environment that mirrors your production setup.
  • Apply the updates and thoroughly test the application to ensure stability.
  • Once confirmed, replicate the changes in your live environment.

If you need assistance identifying specific missing updates or applying them, feel free to provide more details, and I can guide you through the process.

Response 2

If you’re on InvoicePlane version 1.6.2 and noticing that not all database updates have been applied, here are some steps and considerations to help you resolve the issue:


:white_check_mark: 1. Verify the Upgrade Process

Ensure that you followed the official upgrade procedure:

  1. Backup: Always start by backing up your database and files.
  2. Download: Obtain the latest version from the official InvoicePlane website.
  3. Replace Files: Copy all files to your InvoicePlane installation directory, but do not overwrite:
  • ipconfig.php
  • Customized templates in /application/views/
  • Custom styles: assets/core/css/custom.css and assets/core/css/custom-pdf.css
  • Uploaded files in the uploads/ folder
  1. Run Setup: Navigate to http://yourdomain.com/setup and follow the on-screen instructions. The application should automatically apply necessary updates .

:hammer_and_wrench: 2. Check for Applied Updates

InvoicePlane tracks applied database updates in the ip_versions table. To verify which updates have been applied:

  • Access your database using a tool like phpMyAdmin or via command line.
  • Execute the following query:

sql

CopyEdit

SELECT version_file FROM ip_versions ORDER BY version_date_applied;
  • Compare the listed version_file entries with the SQL files present in the application/modules/setup/sql/ directory. Any missing files indicate updates that haven’t been applied.

:bug: 3. Address Known Issues in v1.6.2

There have been reports of issues related to database migrations in version 1.6.2. Specifically, an error concerning database migration was discussed in GitHub Issue #1147. The issue pertained to problems with SQL migrations, and a fix was implemented in pull request #1159. Ensure that your installation includes this fix.


:arrows_counterclockwise: 4. Manually Apply Missing Updates

If certain updates haven’t been applied:

  1. Identify Missing SQL Files: Based on the comparison from step 2, note which SQL files are missing.
  2. Apply SQL Scripts: For each missing SQL file:
  • Open the file to review its contents.
  • Execute the SQL commands manually using your database management tool.
  • After applying, insert a corresponding record into the ip_versions table to indicate the update has been applied.Example:

sql

CopyEdit

INSERT INTO ip_versions (version_date_applied, version_file, version_sql_errors)
VALUES (UNIX_TIMESTAMP(), 'missing_file.sql', 0);

Replace 'missing_file.sql' with the actual filename.

Caution: Always back up your database before performing manual updates.


:test_tube: 5. Test in a Staging Environment

Before applying changes to your live environment:

  • Set up a staging environment that mirrors your production setup.
  • Apply the updates and thoroughly test the application to ensure stability.
  • Once confirmed, replicate the changes in your live environment.

If you need assistance identifying specific missing updates or applying them, feel free to provide more details, and I can guide you through the process.

These are from chat gpt. Above

Below is Chat2DB

I can help you apply the missing database updates to your InvoicePlane installation. There are a few ways to approach this:

Option 1: Run the setup/upgrade process through the web interface

  1. Go to your InvoicePlane installation URL and add /setup at the end, like: https://yourdomain.com/invoiceplane/index.php/setup
  2. You should see the setup screen with an option to upgrade your database. Select this option and follow the instructions.

Option 2: Manually trigger the upgrade function

If the web interface doesn’t work, you can manually create a simple PHP script to run the upgrade:

  1. Create a file called upgrade.php in your InvoicePlane root directory with the following content:
<?php
define('BASEPATH', true);
require_once('index.php');

$CI =& get_instance();
$CI->load->model('setup/mdl_setup');
$result = $CI->mdl_setup->upgrade_tables();

if ($result) {
    echo "Database upgrade completed successfully!";
} else {
    echo "Database upgrade failed. Errors:";
    print_r($CI->mdl_setup->errors);
}
  1. Access this file through your browser or run it from the command line.

Option 3: Check which updates are missing and apply them manually

  1. Look at your ip_versions table to see which SQL updates have been applied:
SELECT * FROM ip_versions ORDER BY version_date_applied ASC;
  1. Compare this with the SQL files in the application/modules/setup/sql directory to identify which ones are missing.
  2. Apply the missing SQL files manually through phpMyAdmin or another database management tool.

Important Notes:

  1. Make a backup of your database before attempting any upgrade!
  2. The error you’re encountering might be related to MySQL’s strict mode settings, especially if you’re using MySQL 5.7+ or 8.0+. The upgrade_036_1_6() function in the code specifically handles issues related to strict mode.
  3. If you’ve made customizations to your InvoicePlane installation, the upgrade process might overwrite them.

Would you like me to provide more detailed instructions for any of these approaches?

1 Like

Ignore response 1 and 2 they don’t belong to your problem.

You can go with chat2db option 2, but you’ll have to have backups.

It’s more important that you pasted the contents of that link i gave you and then say that you want to apply those updates, but ok…
If you’re comfortable making an upgrade.php just go for that

I have made a full site backup. I have tried a few options and lead to issues not finding directories etc.

I have done a comparison of all files and found and downloaded the sql files missing…

The ones i have


The ones missing
image
I tried executing the 023_1.5.0 and got the errors of duplicate files
something like… Error

SQL query: [Copy](https:// my hosting
3/cpsess9609657225/3rdparty/phpMyAdmin/index.php?route=/database/sql&db=bestfl9_invo686#)

``

ALTER TABLE ip_products
  ADD COLUMN unit_id INT(11);

MySQL said: [![Documentation](https:// my hosting :2083/cpsess9609657225/3rdparty/phpMyAdmin/themes/dot.gif “Documentation”)](https:// my hosting cpsess9609657225/3rdparty/phpMyAdmin/url.php?url=https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F8.0%2Fen%2Fserver-error-reference.html)

#1060 - Duplicate column name 'unit_id'

I’ve run our of credit with The CHATGPT but happy to manually go forward??? HAve to leave the shop now as we are shut…
Would applying these sql commands to the ip versions work despite the errors?

Download .zip of 1.6.2 of InvoicePlane.com website.
The files of 1.5.0 through 1.6.2 are in /application/modules/setup/sql

The contents of those files you’re about to paste have already been executed.
All you need to dk is execute the contents of the link i gave you.

Ah ok

So run an sql querie by cutting and pasting this to myphpadmin?

Or paste above link to chat GPT and ask what to do? Once again i apologise for my ignorance.

Needed:

  • structure from 1.6.2
  • custom php script that Chat2db gave you
Hello ChatGPT,
I had to manually upgrade a database.
The only thing that is left is update statements fkr the database that weren't in SQL scripts.

They are in https://github.com/InvoicePlane/InvoicePlane/blob/development/application/modules/setup/models/Mdl_setup.php#L227

My question is:
If i have this perfectly structured database
(paste structure of 1.6.2)
Then which are the possible ways to add those update statements from the .php file?

Can i do it with extra SQL scripts?
Can i run `/setup/upgrade_tables`? Which will call this script?

Or will the script not run, because `ip_versions` is completed up to version 1.6.2?

If i remove some records from `ip_versions` i will get errors, because the structure already has been updated.

Are the only ways the SQL update statements and the custom PHP script Chat2db gave me?

:white_check_mark: TL;DR - Recommended Path for You:

Use Option 2 (custom PHP script) — but modify it to only apply the logic you actually want (skip structural updates that have already been done).

OR

Extract just the relevant REPLACE INTO ip_settings and other non-structural SQL from Mdl_setup.php and run it manually.


Here’s a Deep Dive on Each Option:


:wrench: Option 1: /setup Web Interface

NOT RECOMMENDED in your case.

  • The setup UI relies heavily on the ip_versions table to skip upgrades it thinks were already done.
  • Since you’ve already manually updated the schema, using this may try to re-run dangerous schema changes or skip needed data updates.

Unless you completely reset ip_versions and manually revert structural changes, it’s not a good path.


:brain: Option 2: Custom upgrade.php Script

RECOMMENDED — with a catch.

Running this raw script will call Mdl_setup::upgrade_tables() and execute everything in that method, including things you already did.

To safely use this:

  1. Copy only the relevant logic (e.g., REPLACE INTO ip_settings(...), and UPDATE statements).
  2. Skip any ALTER TABLE, ADD COLUMN, etc. — you’ve already handled those.
  3. Wrap it in your own custom_upgrade.php that includes just that portion.

I can help you extract just that logic if you’d like.


:computer: Option 3: Manual SQL Based on Mdl_setup.php

Also safe and clean — if you’re comfortable writing SQL.

You open up the Mdl_setup.php file, start from line 227, and extract only these types of logic:

php

CopyEdit

$this->db->query("REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('...')");

Then manually run them via a SQL GUI like phpMyAdmin, TablePlus, or your CLI tool.

You avoid PHP entirely, and only apply what’s needed.


:closed_lock_with_key: A Word of Caution: Don’t Touch ip_versions Unless You Reverse Structure

As you said:

If I remove some records from ip_versions I will get errors, because the structure already has been updated.

Exactly right — InvoicePlane does not support partial upgrade rollbacks. So don’t fake a lower version to try and re-trigger the upgrader — it can break your DB.


:toolbox: My Offer to You

If you want, I can:

  • Extract just the relevant SQL update logic from Mdl_setup.php
  • OR Help clean up that custom PHP script to only apply the safe data updates

Just say the word — or paste the file contents and I’ll refactor it right away.

What would you prefer? SQL script or custom PHP?

:white_check_mark: Safe SQL Extracted from Mdl_setup.php for 1.6.2

sql

CopyEdit

-- Ensure default settings exist
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('version', '1.6.2');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('disable_quickactions', '0');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('enable_profiler', '0');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('results_per_page', '15');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('cron_key', '');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('overdue_invoice_email', '0');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('overdue_invoice_email_template', '');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('log_all_ip_access', '0');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('stop_on_view', '0');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('invoice_pre_password', '');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('invoice_pre_password_type', 'hash');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('client_change_invoice', '0');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('disable_client_login', '0');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('disable_client_registration', '0');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('client_can_view_quotes', '1');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('client_can_view_invoices', '1');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('client_can_view_payments', '1');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('client_can_view_documents', '1');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('client_can_view_tasks', '1');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('client_can_view_projects', '1');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('default_document_template', '');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('amount_thousands_separator', ',');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('amount_decimal_separator', '.');
REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('round_tax_decimals', '2');

-- This was part of handling strict mode issues; safe to include
UPDATE `ip_invoices` SET `payment_method` = NULL WHERE `payment_method` = 0;

:white_check_mark: How to Run This

  1. Back up your database (seriously).
  2. Paste this SQL into phpMyAdmin, TablePlus, MySQL CLI, or your preferred SQL tool.
  3. Run it — if you get no errors, you’re golden.

Optional Cleanup: Check for Duplicates

These are REPLACE INTO statements, so if the setting already exists, it will be updated. If it doesn’t, it will be created. Safe either way.


Want me to generate this as a .sql file you can download and run? Or do you want a version that only includes settings missing from your current ip_settings table?

using myphpmyadmin i got the following result

1 row affected. Inserted row id: 118 (Query took 0.0126 seconds.) -- Ensure default settings exist REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('version', '1.6.2'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 119 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('disable_quickactions', '0'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 120 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('enable_profiler', '0'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 121 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('results_per_page', '15'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 122 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('cron_key', ''); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 123 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('overdue_invoice_email', '0'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 124 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('overdue_invoice_email_template', ''); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 125 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('log_all_ip_access', '0'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 126 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('stop_on_view', '0'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 127 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('invoice_pre_password', ''); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 128 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('invoice_pre_password_type', 'hash'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 129 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('client_change_invoice', '0'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 130 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('disable_client_login', '0'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 131 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('disable_client_registration', '0'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 132 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('client_can_view_quotes', '1'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 133 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('client_can_view_invoices', '1'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 134 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('client_can_view_payments', '1'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 135 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('client_can_view_documents', '1'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 136 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('client_can_view_tasks', '1'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 137 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('client_can_view_projects', '1'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 138 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('default_document_template', ''); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 139 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('amount_thousands_separator', ','); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 140 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('amount_decimal_separator', '.'); [ Edit inline ] [ Edit ] [ Create PHP code ] 1 row affected. Inserted row id: 141 (Query took 0.0001 seconds.) REPLACE INTO `ip_settings` (`setting_key`, `setting_value`) VALUES ('round_tax_decimals', '2'); [ Edit inline ] [ Edit ] [ Create PHP code ] 0 rows affected. (Query took 0.0167 seconds.)
-- This was part of handling strict mode issues; safe to include UPDATE `ip_invoices` SET `payment_method` = NULL WHERE `payment_method` = 0; [ Edit inline ] [ Edit ] [ Create PHP code ] Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null Warning: #1048 Column 'payment_method' cannot be null
ChatGPT said:

It looks like your SQL update ran successfully for the ip_settings table, where new settings values were inserted, but there was an issue with the payment_method column in the ip_invoices table.

Issue Breakdown:

  • The query to update payment_method values in ip_invoices tried to set the value to NULL where it was previously 0, but your payment_method column does not allow NULL values, resulting in the warnings.Error Details:
    • The warning #1048 Column 'payment_method' cannot be null indicates that the payment_method column is set to NOT NULL, but the query tried to insert a NULL value.

Possible Solutions:

  1. Update Query for payment_method: Since payment_method cannot be NULL, you can:
  • Update the column to a default valid value (e.g., 0 or another value like 'default_method' if your system uses such identifiers).To fix this issue, you can manually run the following query to update the payment_method values:

sql

CopyEdit

UPDATE ip_invoices
SET payment_method = 0
WHERE payment_method = 0;

If you want to reset all problematic values to something else (e.g., if 0 should be replaced by a valid payment method identifier), you can modify the value accordingly.
2. Check the Column Definition: Ensure that the payment_method column allows for default values or other valid entries instead of NULL. You can modify the column definition if needed, but this should only be done if your system allows for NULL values in this column:

sql

CopyEdit

ALTER TABLE ip_invoices MODIFY payment_method INT DEFAULT 0;

This would set the column to allow NULL values or apply a default value if no value is provided.
3. Double-Check the ip_invoices Data: If the payment_method column contains unexpected or invalid values, you might want to examine the data before applying fixes. You can check for all entries where payment_method equals 0 or NULL and update them as necessary:

sql

CopyEdit

SELECT * FROM ip_invoices WHERE payment_method IS NULL OR payment_method = 0;

Proceeding with the Update:

After applying the manual fixes, you can rerun the SQL file and continue with the upgrade process. If you encounter any further issues, feel free to reach out, and I can assist with additional troubleshooting.

not sure if this is all heading the right way as the database has no new sql versions added… Which is the main goal here I am still assuming?

Should i continue with the chat gpt suggestions?
RE

etc?

Well, there are a couple of problems.

I must ask you to not copy/paste every error output, because it’s really unreadable.

Focus on 2 problems (the second one is waaaaay below the first one):

UPDATE ip_invoices SET payment_method = NULL WHERE payment_method = 0;

It gave you 1 error, for all your invoices.

Let’s break it down:

  • The ip_invoices table hasn’t been changed to allow null values.
  • it means the structure hasn’t been improved.
  • it means either a .sql file from /application/modules/setup/sql hasn’t run or an SQL statement from that link i gave you hasn’t run.

The problem is: i don’t know when the ip_invoices table was changed to allow null values.

For now, you can do:

ALTER TABLE ip_invoices MODIFY payment_method INT DEFAULT 0;

and after that:

UPDATE ip_invoices SET payment_method = NULL WHERE payment_method = 0;

The second problem is this:

Hello ChatGPT,
In my `ip_versions` table i have all updates up until version 1.4.10`
The updates between 1.5 and 1.6 are missing.

Take a look in this url: https://github.com/InvoicePlane/InvoicePlane/tree/development/application/modules/setup/sql
and give me an SQL statement to fill the `ip_versions` table with all those version numbers