nextcloud / recognize

👁 👂 Smart media tagging for Nextcloud: recognizes faces, objects, landscapes, music genres
https://apps.nextcloud.com/apps/recognize
GNU Affero General Public License v3.0
539 stars 45 forks source link

undefined table after manual uninstall/purge followed by reinstall #623

Closed kc9jud closed 1 year ago

kc9jud commented 1 year ago

Which version of recognize are you using?

3.3.4

Enabled Modes

Object recognition, Face recognition

TensorFlow mode

Normal mode

Which Nextcloud version do you have installed?

25.0.2

Which Operating system do you have installed?

Ubuntu 20.04.5

Which Docker container are you using to run Nextcloud? (if applicable)

v25.0.2

How much RAM does your server have?

64GiB

What processor Architecture does your CPU have?

x86_64

Describe the Bug

While trying to debug another issue, I tried completely uninstalling Recognize, deleting all of its oc_recognize_* tables, and reinstalling. Now, when I run occ recognize:classify, I get errors like

An exception occurred while executing a query: SQLSTATE[42P01]: Undefined table: 7 ERROR:  relation "oc_recognize_queue_imagenet" does not exist
LINE 1: DELETE FROM "oc_recognize_queue_imagenet" WHERE "id" = $1
                    ^

It seems like the database schema was not recreated correctly on reinstall.

Expected Behavior

When re-installing/re-enabling, Recognize should probably check the integrity of the database schema.

To Reproduce

1) Install Recognize. 2) Disable and uninstall Recognize. 3) Manually delete tables using psql:

DROP TABLE oc_recognize_face_clusters, oc_recognize_face_detections, oc_recognize_queue_faces, oc_recognize_queue_imagenet, oc_recognize_queue_landmarks, oc_recognize_queue_movinet, oc_recognize_queue_musicnn;

4) Reinstall Recognize from app store.

Debug log

Result for oc_tmp_gDLBmA-.jpg = ["Seashore","Beach","Water","Landscape","Nature"]
An exception occurred while executing a query: SQLSTATE[42P01]: Undefined table: 7 ERROR:  relation "oc_recognize_queue_imagenet" does not exist
LINE 1: DELETE FROM "oc_recognize_queue_imagenet" WHERE "id" = $1
                    ^
kc9jud commented 1 year ago

My immediate question is how to get my database into a coherent state...

kc9jud commented 1 year ago

Of course, this is related to #621, since I tried to do things "by hand"...

kc9jud commented 1 year ago

It appears that doing something like the process in https://github.com/nextcloud/spreed/issues/772#issuecomment-384211357 managed to get me back into a workable state. In particular, I think I needed to remove the entries from the oc_migrations table.

marcelklehr commented 1 year ago

Yes, that's the correct procedure :)