Skip to content

Instantly share code, notes, and snippets.

@FlorianHeigl
Created June 19, 2023 18:43
Show Gist options
  • Save FlorianHeigl/719680d7fe67f1a1b05bc55e72e0a2fe to your computer and use it in GitHub Desktop.
Save FlorianHeigl/719680d7fe67f1a1b05bc55e72e0a2fe to your computer and use it in GitHub Desktop.
nextcloud upgrade script with collection of db fixes, some notes for fixing typical errors with nextcloud-docker
#!/bin/bash -u
occ_wrapper='docker exec -it -u 33 nextcloud-app /var/www/html/occ'
mysql_wrapper='docker exec nextcloud-db mysql nextcloud'
upgrades_db() {
_scmds="db:add-missing-columns
db:add-missing-indices
db:add-missing-primary-keys
db:convert-filecache-bigint
db:convert-mysql-charset
db:convert-type"
# convert type will need a table
for _scmd in ${_scmds} ; do
$occ_wrapper ${_scmd}
done
}
# need to source $env
single_db_fixes(){
$mysql_wrapper -p$MYSQL_ROOT_PASSWORD -e "ALTER TABLE mysql.column_stats MODIFY histogram longblob;"
$mysql_wrapper -p$MYSQL_ROOT_PASSWORD -e "ALTER TABLE mysql.column_stats MODIFY hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB');"
$mysql_wrapper -p$MYSQL_ROOT_PASSWORD -e "ALTER TABLE mysql.event MODIFY definer varchar(255);"
# There is no column with name 'mount_provider_class' on table 'oc_mounts'.
# mysqlcheck -u nextcloud -p$MYSQL_ROOT_PASSWORD --databases nextcloud --optimize
# mysqlcheck -u nextcloud -p$MYSQL_ROOT_PASSWORD --databases nextcloud
# if that don't help, do this
#localhost:~# docker exec nextcloud-db mysql nextcloud -p$MYSQL_ROOT_PASSWORD -e "ALTER TABLE oc_mounts ADD mount_provider_class VARCHAR(128) DEFAULT NULL"
}
# fixing the app version to trigger schema upgrades
# config.php can get stale
#https://help.nextcloud.com/t/update-23-0-0-10-to-23-0-2-1054-unknown-column-argument-hash/134235/3
# 1) occ status - get correct version string
# 2 check version in config.php
# 3) sed -i 's/wrong.ve.rsi.on/occ.sta.tus.version/
# run occ upgrade and repair just in case
#localhost:~/nextcloud-docker# docker exec -it -u 33 nextcloud-app /var/www/html/occ upgrade
#localhost:~/nextcloud-docker# docker exec -it -u 33 nextcloud-app /var/www/html/occ maintenance:repair
$occ_wrapper maintenance:mode --on
upgrades_db
$occ_wrapper maintenance:mode --off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment