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!
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!
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
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
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.
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 opencartnetbull wrote: ↑Mon Feb 22, 2021 4:20 amThank 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.
and I agree with you.
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...
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 anywaynetbull wrote: ↑Mon Feb 22, 2021 4:42 amI'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...
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
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.
:-) 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
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
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
it's from here:mikeinterserv wrote: ↑Mon Feb 22, 2021 6:23 am:-) 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
I'm not offended in any way, so don't worry about it.....I'm just asking is there a way as a developer to code the extension to gradually update itself ...
You can have a look at the extension from here. It's free anyway.
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.
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.
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.
Backup and learn how to recover before you make any changes!
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!mikeinterserv wrote: ↑Mon Feb 22, 2021 8:09 amFurther 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
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/
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.netbull wrote: ↑Sun Feb 21, 2021 8:14 pmHello,
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 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.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Not really, I wrote the the "new table is not created". Failing means that it tried, but it did not succeeded..mikeinterserv wrote: ↑Mon Feb 22, 2021 10:18 pmBut it is failing because you said it FAILED to create table C
However.. this thread does not lead to anywhere... Someone from the moderators or admin can close is.straightlight wrote: ↑Mon Feb 22, 2021 10:57 pmIf 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.netbull wrote: ↑Sun Feb 21, 2021 8:14 pmHello,
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 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.
Anyway, mikeinterserv thank you for your help.
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
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
Who is online
Users browsing this forum: No registered users and 17 guests