Plugin database update for new version

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
Hello,
I know that questions has been asked many times, but I just can't find an answer that satisfies me. I am developing a plugin that uses data access as described in the "plugin with data access" article in NopCommerce's documentation. It works fine, but I know I will have many versions, adding many features along the way and I know the data model will evolve over time. How can I make sure I can make that data model evolve without causing major problems for my clients when installing a new version? Must I resort to update scripts? I find it complicated for some less technical clients. Can there be an automated way for the plugin to update its own tables? I've seen some solutions using EF's migration functionality, but some say it does not work with NopCommerce version 4.0 and up. What is the "standard" way to go with this?

Obviously, if I uninstall the plugin and install it again, the tables are created accordingly, but the uninstall process drops the original tables along with the data they contain, so it's not acceptable in a production environment.

What must I do so it's easy for the client and still remains flexible enough so I can provide an evolving product?

Thanks

Dany Latulippe
5 years ago
Hello Dany,

I prefer the best way is to write your own script and run it from plugin installation method directly to Ms Sql if you don't want your customers to do that manually.

This is how we do sometimes too :)

Hope this would help.

Thank you,
Atul
5 years ago
nopAdvance wrote:
run it from plugin installation method directly to Ms Sql


What do you mean by that? I mean, let's say the client has a brand new installation of NopCommerce. He installs my plugin, let's say version 1.0. The tables get created. From then on, the client enters some data. Then, some months later, I release version 1.1 which has 2 more tables and 2 new fields in one of the old tables. What are the options? Does the client just copy the new version in the plugin's directory and restart NopCommerce? Is there an "Update" method? Will NopCommerce call the "Install" method again because it recognizes it's a new version?

I'm pretty new to this. Usually, I develop a plugin for a specific client and manage it myself, so when I have update scripts, I run them myself on the client's server. But now, I have a client through one of my clients, so I don't really have access to the client's server. As a result, someone, not necessarily very tech-savvy will have to install updates.

Thanks a lot for your help. It's very appreciated.

Dany Latulippe
5 years ago
Hello,

Just don't drop the tables on uninstall and when installing the plug-in again you run the script for the tables in the database from plugin install method.

So, your client have to uninstall and install plugin every time you push a new update.

Thank you,
Atul
5 years ago
Thanks a lot
5 years ago
Hi,

Hope my replies would help you. Please vote up answers if this works for you.

Thank you,
Atul
5 years ago
ThunderMusic wrote:
run it from plugin installation method directly to Ms Sql

What do you mean by that? I mean, let's say the client has a brand new installation of NopCommerce. He installs my plugin, let's say version 1.0. The tables get created. From then on, the client enters some data. Then, some months later, I release version 1.1 which has 2 more tables and 2 new fields in one of the old tables. What are the options? Does the client just copy the new version in the plugin's directory and restart NopCommerce? Is there an "Update" method? Will NopCommerce call the "Install" method again because it recognizes it's a new version?

I'm pretty new to this. Usually, I develop a plugin for a specific client and manage it myself, so when I have update scripts, I run them myself on the client's server. But now, I have a client through one of my clients, so I don't really have access to the client's server. As a result, someone, not necessarily very tech-savvy will have to install updates.

Thanks a lot for your help. It's very appreciated.

Dany Latulippe


Hi Dany,

You can add a plugin setting for display upgrade plugin/database button in plugin configuration page.
and execute script for the tables on click of button, once script execute successfully than mark false to new setting and hide that button.

If you execute scripts on plugin installation time without drop old tables than whenever you install plugin next time, it'll throws exception or create duplicate record because of that script is already execute on first time plugin installation.
5 years ago
That's a good idea. I'll see how I can manage such a thing.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.