metwork-framework / mfbase

metwork/mfbase module
http://metwork-framework.org
BSD 3-Clause "New" or "Revised" License
2 stars 2 forks source link

Updating a mfbase plugin drops the database #253

Open matthieumarrast opened 11 months ago

matthieumarrast commented 11 months ago

We have lost a database while updating a plugin mfbase.

Problem

In mfext, updating a plugin trigger the uninstall of the plugin:

def u_plugin(typ, name, fil):
    echo_running("- Updating %s plugin: %s..." % (typ, name))
    try:
        plugins_manager.uninstall_plugin(name)

It causes mfbase to call the preunintall script (https://github.com/metwork-framework/mfbase/blob/master/adm/_plugins.preuninstall) with the dropdb/dropuser commands:

dropdb --if-exists -h "${MFMODULE_RUNTIME_HOME}/var" -p "${MFBASE_POSTGRESQL_PORT}" -U "${MFBASE_POSTGRESQL_USERNAME}" "plugin_${NAME}" || RES=1
dropuser --if-exists -h "${MFMODULE_RUNTIME_HOME}/var" -p "${MFBASE_POSTGRESQL_PORT}" -U "${MFBASE_POSTGRESQL_USERNAME}" "plugin_${NAME}" || RES=1

Proposed solution

During the plugin "update", if the database/user already exists, do not drop them!

But it seems in metwork the update always uninstalls then installs...

thebaptiste commented 11 months ago

Same or different thing than #252 ?

thebaptiste commented 11 months ago

Updating meaning uninstalling previous then installing new one seems quite normal to me (same thing for rpms I think). But we probably should save the database when uninstalling the plugin and provide a way to restore it afer update.

matthieumarrast commented 11 months ago

Yes save+restore the database can be a solution ! but not deleting it can be a better one... but it's not an easy fix, regarding how it's currently done between mfext, mfplugin and mfbase...