Post by netbull » Sun Feb 21, 2021 8:14 pm

Hello,

I have custom extension which uses own tables in the DB. Now I have an upgrade to the extension which needs to add one additional table to the DB.

My problem is that I can't find any information how to tell OC to update the existing installed extension...

Example:
My extension is installed on version 1.0.0 with DB tables A and B
I have a new version 1.0.1 which have DB tables A, B and C

If I remove version 1.0.0 and install fresh 1.0.1 everything is find, but If I just use the installed to install 1.0.1 then the new table "C" is not created.

Any info will be appreciated!

Newbie

Posts

Joined
Mon Sep 21, 2020 6:16 pm

Post by mikeinterserv » Sun Feb 21, 2021 11:16 pm

What are you saying that the DB tables A and B from version 1 contain data so you don't want to delete the extension because it will drop the tables A and B and you lose the data ?

If so export tables A and B - delete extension - install new extension - Tables A B and C - Now import tables A and B
Back up your DB first

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by netbull » Mon Feb 22, 2021 4:20 am

Thank you for the reply!

It's kinda nonsense to backup the export/import the DB or even drop the tables just to upgrade the extension from version 1.0.0 to 1.1.0.. the extension should be configured to upgrade the DB schema accordingly WITHOUT loosing data at all.

Newbie

Posts

Joined
Mon Sep 21, 2020 6:16 pm

Post by mikeinterserv » Mon Feb 22, 2021 4:21 am

netbull wrote:
Mon Feb 22, 2021 4:20 am
Thank you for the reply!

It's kinda nonsense to backup the export/import the DB or even drop the tables just to upgrade the extension from version 1.0.0 to 1.1.0.. the extension should be configured to upgrade the DB schema accordingly WITHOUT loosing data at all.
Well you better take that up with the extension developer its not the fault of opencart
and I agree with you.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by netbull » Mon Feb 22, 2021 4:42 am

I'm not looking to blame anyone or anything... I'm just asking is there a way as a developer to code the extension to gradually update itself from one minor version to another without asking the client to reinstall the extension...

I can only see that there are install and uninstall methods, but no update method or something like that...

For example another platform have a mechanism to do that: the developer can put special file called update_VERSION.php which contains the diff in code for this version. Basically my question was: Does OC have such mechanism or not...

Newbie

Posts

Joined
Mon Sep 21, 2020 6:16 pm

Post by mikeinterserv » Mon Feb 22, 2021 5:08 am

netbull wrote:
Mon Feb 22, 2021 4:42 am
I'm not looking to blame anyone or anything... I'm just asking is there a way as a developer to code the extension to gradually update itself from one minor version to another without asking the client to reinstall the extension...

I can only see that there are install and uninstall methods, but no update method or something like that...

For example another platform have a mechanism to do that: the developer can put special file called update_VERSION.php which contains the diff in code for this version. Basically my question was: Does OC have such mechanism or not...
No - a good developer would manage to do it though anyway
If the extension ONLY adds an extra DB column it should be easy to eliminate table A and B from the install unless those tables have changed
What is the extension

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by netbull » Mon Feb 22, 2021 5:58 am

Yes, it's easy to just add the new create table query in the install method, but if the extension is already installed with older version the install method is not invoked... or I'm missing something?

Newbie

Posts

Joined
Mon Sep 21, 2020 6:16 pm

Post by mikeinterserv » Mon Feb 22, 2021 6:06 am

netbull wrote:
Mon Feb 22, 2021 5:58 am
Yes, it's easy to just add the new create table query in the install method, but if the extension is already installed with older version the install method is not invoked... or I'm missing something?
To be blunt - if you are waiting for the extension developer or anyone else to just solve this problem for you - you could have a long wait.
Sometimes you just have to get on and do what is necessary. Which takes me back to my earlier post about dealing with it yourself by exporting those tables - deleting the extension - installing the new extension and then re importing table A and B there is nothing to it if the tables are identical in structure.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by netbull » Mon Feb 22, 2021 6:12 am

Man, you just don't read what I write...

to clarify:
1- I am the developer of the extension!
2- it's just stupid my clients to be forced to export and import database just to install 3rd party extension...

Newbie

Posts

Joined
Mon Sep 21, 2020 6:16 pm

Post by mikeinterserv » Mon Feb 22, 2021 6:23 am

netbull wrote:
Mon Feb 22, 2021 6:12 am
Man, you just don't read what I write...

to clarify:
1- I am the developer of the extension!
2- it's just stupid my clients to be forced to export and import database just to install 3rd party extension...
:-) where did you say you were the developer - I don't see that.
But I do now understand more clearly what you are saying - sorry if I offended you, not intended.
is it possible for me to see the code of the extension - you could pm it and I would be happy to see if I can add anything to help you

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by mikeinterserv » Mon Feb 22, 2021 6:33 am

OK here is what you can do
You rewrite the extension to install the 3 table C D and F - you copy the data from existing tables A and B INTO D and F - delete A and B then rename D and F as A and B - job done - then the user uninstalls extension 1.0 as the only thing they have to do on successful install of extension 1.1 are you OK with the sql to do that
OR
You just install table C for existing users. There is no problem to just install OVER the TOP of existing. It will install and just create 1 table C as long as the name and code are the same, if there is other stuff going on as well - then check for tables A and B then if exist ignore - This depends on whether the table STRUCTURE is identical or if you changed something

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by netbull » Mon Feb 22, 2021 6:48 am

mikeinterserv wrote:
Mon Feb 22, 2021 6:23 am
netbull wrote:
Mon Feb 22, 2021 6:12 am
Man, you just don't read what I write...

to clarify:
1- I am the developer of the extension!
2- it's just stupid my clients to be forced to export and import database just to install 3rd party extension...
:-) where did you say you were the developer - I don't see that.
But I do now understand more clearly what you are saying - sorry if I offended you, not intended.
is it possible for me to see the code of the extension - you could pm it and I would be happy to see if I can add anything to help you
it's from here:
...I'm just asking is there a way as a developer to code the extension to gradually update itself ...
I'm not offended in any way, so don't worry about it..

You can have a look at the extension from here. It's free anyway.

Newbie

Posts

Joined
Mon Sep 21, 2020 6:16 pm

Post by mikeinterserv » Mon Feb 22, 2021 7:31 am

OK so you have 6 or 7 tables being created in this version
How many in OLD version
All you have to do is check IF EXISTS for existing tables and ignore them
However if the structure of those tables has changed in any way there is more work to do - has the structure changed in new tables compared to existing or not.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by sw!tch » Mon Feb 22, 2021 7:52 am

netbull wrote:
Sun Feb 21, 2021 8:14 pm
If I remove version 1.0.0 and install fresh 1.0.1 everything is find, but If I just use the installed to install 1.0.1 then the new table "C" is not created.
I would think you could store the version of your module in the DB.

Create an event hook on install that checks the installed version and compares with the version being installed. You then run the table procedure or any other DB updates as needed.

When successfully updated, you update your module version in the DB to the current version.

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm
Location - USA

Post by mikeinterserv » Mon Feb 22, 2021 8:09 am

netbull wrote:
Sun Feb 21, 2021 8:14 pm
If I remove version 1.0.0 and install fresh 1.0.1 everything is find, but If I just use the installed to install 1.0.1 then the new table "C" is not created.
Further to switches advice above - what did the OCMod log tell you about the install
Were there any errors in the system maintenance log - there is no good reason the new tables were not created.

I just tested a mock extension with 2 tables - I was able to install a new version with 3 tables with no trouble at all.
I could replace all tables or I could ignore existing and add just 1 so you have some error preventing the creation of the DB tables
I did not uninstall - I just installed again and the first install is overwritten
This is with 3.0.3.2 and 3.0.3.6
Your database routines are probably failing because you are failing to detect the tables already exist even though your sql has CREATE TABLE IF NOT EXISTS it is not working correctly AND you do not need IF NOT EXITS when you implicitly KNOW they DO NOT EXIST

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by netbull » Mon Feb 22, 2021 2:40 pm

mikeinterserv wrote:
Mon Feb 22, 2021 8:09 am
netbull wrote:
Sun Feb 21, 2021 8:14 pm
If I remove version 1.0.0 and install fresh 1.0.1 everything is find, but If I just use the installed to install 1.0.1 then the new table "C" is not created.
Further to switches advice above - what did the OCMod log tell you about the install
Were there any errors in the system maintenance log - there is no good reason the new tables were not created.

I just tested a mock extension with 2 tables - I was able to install a new version with 3 tables with no trouble at all.
I could replace all tables or I could ignore existing and add just 1 so you have some error preventing the creation of the DB tables
I did not uninstall - I just installed again and the first install is overwritten
This is with 3.0.3.2 and 3.0.3.6
Your database routines are probably failing because you are failing to detect the tables already exist even though your sql has CREATE TABLE IF NOT EXISTS it is not working correctly AND you do not need IF NOT EXITS when you implicitly KNOW they DO NOT EXIST
Again thank you for your help!

I don't think the DB routines are failing because when I added createTables call in index() it works as it should be /frankly speaking I borrowed this idea from the google's extension/

Newbie

Posts

Joined
Mon Sep 21, 2020 6:16 pm

Post by mikeinterserv » Mon Feb 22, 2021 10:18 pm

netbull wrote:
Mon Feb 22, 2021 2:40 pm
I don't think the DB routines are failing because when I added createTables call in index() it works as it should
But it is failing because you said it FAILED to create table C

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by straightlight » Mon Feb 22, 2021 10:57 pm

netbull wrote:
Sun Feb 21, 2021 8:14 pm
Hello,

I have custom extension which uses own tables in the DB. Now I have an upgrade to the extension which needs to add one additional table to the DB.

My problem is that I can't find any information how to tell OC to update the existing installed extension...

Example:
My extension is installed on version 1.0.0 with DB tables A and B
I have a new version 1.0.1 which have DB tables A, B and C

If I remove version 1.0.0 and install fresh 1.0.1 everything is find, but If I just use the installed to install 1.0.1 then the new table "C" is not created.

Any info will be appreciated!
If this is a custom extension developed on your own and causes an issue on one side and not on the other, this may require advanced troubleshooting to track down the root cause. I would, then, suggest to create a new service request in the Commercial Support section of the forum to get this issue investigated as a custom job.

If this is a downloaded extension by another party, I would suggest to contact the extension developer to resolve this issue. If no response, at this point, to follow the previous paragraph's instructions for advanced troubleshooting.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by netbull » Tue Feb 23, 2021 3:26 am

mikeinterserv wrote:
Mon Feb 22, 2021 10:18 pm
netbull wrote:
Mon Feb 22, 2021 2:40 pm
I don't think the DB routines are failing because when I added createTables call in index() it works as it should
But it is failing because you said it FAILED to create table C
Not really, I wrote the the "new table is not created". Failing means that it tried, but it did not succeeded..
straightlight wrote:
Mon Feb 22, 2021 10:57 pm
netbull wrote:
Sun Feb 21, 2021 8:14 pm
Hello,

I have custom extension which uses own tables in the DB. Now I have an upgrade to the extension which needs to add one additional table to the DB.

My problem is that I can't find any information how to tell OC to update the existing installed extension...

Example:
My extension is installed on version 1.0.0 with DB tables A and B
I have a new version 1.0.1 which have DB tables A, B and C

If I remove version 1.0.0 and install fresh 1.0.1 everything is find, but If I just use the installed to install 1.0.1 then the new table "C" is not created.

Any info will be appreciated!
If this is a custom extension developed on your own and causes an issue on one side and not on the other, this may require advanced troubleshooting to track down the root cause. I would, then, suggest to create a new service request in the Commercial Support section of the forum to get this issue investigated as a custom job.

If this is a downloaded extension by another party, I would suggest to contact the extension developer to resolve this issue. If no response, at this point, to follow the previous paragraph's instructions for advanced troubleshooting.
However.. this thread does not lead to anywhere... Someone from the moderators or admin can close is.

Anyway, mikeinterserv thank you for your help.

Newbie

Posts

Joined
Mon Sep 21, 2020 6:16 pm

Post by mikeinterserv » Tue Feb 23, 2021 3:54 am

That's OK
Its not a good resolution because I don't think your problem is great.
I think some misunderstanding as well
If you want to look further you can pm me
I have the code but I don't have the first version to test your problem send me that also if you want

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales
Who is online

Users browsing this forum: No registered users and 12 guests