rotdrop / nextcloud-app-files-archive

Archive inspection and extraction as Nextcloud app.
Other
9 stars 4 forks source link

ERROR: column "mount_point_file_id" of relation "oc_files_archive_mounts" contains null values #34

Closed tobiasu closed 3 months ago

tobiasu commented 3 months ago

Updating to files_archive: 1.2.0 (installed 1.1.3), I ran into this:

Updating <files_archive> ...                                                        
Exception: Database error when running migration 100004Date20240125084147 for app files_archive    
An exception occurred while executing a query: SQLSTATE[23502]: Not null violation: 7 ERROR:  column "mount_point_file_id" of relation "oc_files_archive_mounts" contains null values        
Update failed

Postgres 15 NC 28.0.3

Sounds like I have to look into the database and clean up some things manually.

EpicJosch commented 3 months ago

I have the same error

rotdrop commented 3 months ago

Sorry for this. @EpicJosch "same error": same db (postgres, same NC version same everything?)

So, seemingly the migration is broken. The cause of the problem is probably the following line:

https://github.com/rotdrop/nextcloud-app-files-archive/blob/458500e61320bf7ca5634006449546e67d117e4d/lib/Migration/Version100004Date20240125084147.php#L73

Are you able to hack your installed version of files_archive and simply remove that line and try again?

Otherwise: to fix the issue manually for just you: modify that database table and remove the "notnull" attribute from any existing "mount_point_file_id" column, or add an integer column "mount_point_file_id" without "not null" constraint.

tobiasu commented 3 months ago

mount_point_file_id doesn't exist yet.

I've had a single entry in oc_files_archive_mounts with a non-existent archive_file_path and mount_point_path (/foo/blah.zip is now /bar/foo/blah.zip, /foo was moved into /bar some time ago)

Once deleted, occ app:enable files_archive updated directly to 1.2.0. Just to be sure I did the app:remove app:install dance, no issue. mount_point_file_id exists now.

rotdrop commented 3 months ago

Actually, the migration I wrote was broken in several aspects :(

However, what we also experienced is that the behaviour of DBAL of the underlying DB engine are quite different when one require "not null" and do not give the column a default value. DBAL/mysql/mariadb implicitly seem to assume "default 0", while DBAL/postgresql errors out.

Still there are also other issues with this migration stuff, unfortunately.

I think that the migration issues show be fixed by 9337eac

The commit sets a default for the non-null column which should avoid the Postgres error and also fixes the update statement to really only work on the current row.