nextcloud / deck

🗂 Kanban-style project & personal management tool for Nextcloud, similar to Trello
https://apps.nextcloud.com/apps/deck
GNU Affero General Public License v3.0
1.2k stars 274 forks source link

Uninstall & purge deck from nextcloud #4719

Open gonzalo opened 1 year ago

gonzalo commented 1 year ago

Deck seems to be an amazing app to complement our current usage of nextcloud, we’ve tested in our testing instance and we are very satisfied.

But as we have a medium size instance, before moving to production we would like to ensure how to completely remove it in case we need to perform that operation. We have not seen anything about this topic i documentation. Can someone point us about it?

Ideally I would like to have an occ purge command like Polls app has (https://github.com/nextcloud/polls/blob/master/README.md), but anyway... Is possible to do it manually? I mean, to completely remove the decks apps I should...

  1. deactivate app
  2. drop tables from database (https://deck.readthedocs.io/en/latest/structure/)
  3. ...?

UPDATE MANUAL PROCEDURE

  1. Disable deck app (from UI)
  2. Remove app (from UI). Code disappears from Nextcloud installation, data remains in DB
  3. Drop deck related tables, configs and migrations:
    drop table if exists oc_deck_assigned_labels, oc_deck_labels, oc_deck_attachment, oc_deck_assigned_users, oc_deck_cards, oc_deck_board_acl, oc_deck_stacks, oc_deck_boards;
    delete from oc_appconfig where appid= 'deck';
    delete from oc_migrations where app = 'deck';

    Deck now has been completely removed from your system and you're able to reinstall it

gonzalo commented 1 year ago

I've tried two different methods with different results.

In my previous message I miss mentioning that it is important for us to ensure data is COMPLETELY removed as it can affect the legal requirements.

Method 1 - completely remove all references (FAILS)

  1. Disable deck app (from UI)
  2. Remove app (from UI). Code disappears from Nextcloud installation, data remains in DB
  3. Drop deck related tables drop table if exists oc_deck_assigned_labels, oc_deck_labels, oc_deck_attachment, oc_deck_assigned_users, oc_deck_cards, oc_deck_board_acl, oc_deck_stacks, oc_deck_boards;
  4. Remove references from appconfig delete from oc_appconfig where appid="deck";
  5. Application seems to be properly removed but then...
  6. ... "Download & enable" Deck app from UI again (no error seen)
  7. User tries to access Deck application it receives a 500 error

In admin logging tab I see "OC\DB\Exceptions\DbalException: An exception occurred while executing a query: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'nextcloud.oc_deck_cards' doesn't exist". Checking DB confirms that deck tables do not exist, they have not been recreated as I expected.

I tried some other things but only disabling the app bring back nextcloud to life. Remove and enable the deck app again doesn't make any difference. Restoring a previous DB backup is the only way to recover stable status.

-- Method 2 - truncate tables (almost SUCCESS)

  1. Disable deck app (from UI)
  2. Remove app (from UI). Code disappears from Nextcloud installation, data remains in DB
  3. Truncate deck related tables and drop config references
    truncate table oc_deck_assigned_labels;
    truncate table oc_deck_labels;
    truncate table oc_deck_attachment;
    truncate table oc_deck_assigned_users;
    truncate table oc_deck_cards;
    truncate table oc_deck_board_acl;
    truncate table oc_deck_stacks;
    truncate table oc_deck_boards;  
    delete from oc_appconfig where appid="deck";
  4. App seems correctly removed
  5. Reinstall application. No error
  6. User can access deck app in a normal way. The only issue is that default "personal" decks no longer exists.

This could be an "valid" method as this allows to completely remove all the stuff from DBs and reinstall the application but I would like to completely remove DB tables and rebuild if necessary. Is it possible to achieve?

tcitworld commented 1 year ago

For the first method you also need:

DELETE FROM oc_migrations WHERE app = 'deck';

Otherwise they won't be run again to recreate the tables.

gonzalo commented 1 year ago

Thank you @tcitworld, that made the trick!

I'm modifying the comment above. I think this should be enough to reset/uninstall/purge this application. I think I could be interesting to include it in documentation or even create a specific commando for this.

Regards

juliushaertl commented 1 year ago

Yes, documenting definitely makes sense. Ideally the server would provide a generic way to allow apps to purge their data as with https://github.com/nextcloud/server/issues/5539 so not every app has to implement a specific occ command.

zoernert commented 2 months ago

Thanks for this thread!

After half a year of searching why our 10 year old and ever migrated instance of nextcloud stopped working with deck and reinstall brought no success. The trick was:

DELETE FROM oc_migrations WHERE app = 'deck';

As far as I see the tables were not re-created if the app is deactivated and removed via UI.