Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nextcloud install can't be run twice #2076

Closed
b-k opened this issue Dec 22, 2021 · 1 comment · Fixed by #2078
Closed

Nextcloud install can't be run twice #2076

b-k opened this issue Dec 22, 2021 · 1 comment · Fixed by #2078

Comments

@b-k
Copy link
Contributor

b-k commented Dec 22, 2021

My nextcloud installation failed, so I tried running the setup twice, which can't work. It fails because this line in setup/nextcloud.sh...

echo "ALTER TABLE oc_flow_operations ADD COLUMN entity VARCHAR;" | sqlite3 $STORAGE_ROOT/owncloud/owncloud.db

...will fail the second time it runs, because you can't add a column twice. You'll get Error: near line 1: duplicate column name: entity.

That means even if I fix whatever is broken with the nextcloud update, I'm not going to be able to get past this line.

One fix might be to check whether the table is already altered, via, e.g.,

sqlite3 $STORAGE_ROOT/owncloud/owncloud.db ".schema" | grep 'oc_flow_operations.*entity'

and skipping the alter table step if grep returns with a status of 0.

@jvolkenant
Copy link
Contributor

Since it exits with a non zero exit code, bash's +x is exiting the run.

You're right, we can search it based on .schema, (or even PRAGMA table_info(oc_flow_operations)), we won't really do anything if it fails, we can just assume it's always successful too.

root@testjammy:~/mailinabox# echo "ALTER TABLE oc_flow_operations ADD COLUMN entity VARCHAR;" | sqlite3 $STORAGE_ROOT/owncloud/owncloud.db
Error: near line 1: duplicate column name: entity
root@testjammy:~/mailinabox# echo $?
1
root@testjammy:~/mailinabox# (echo "ALTER TABLE oc_flow_operations ADD COLUMN entity VARCHAR;" | sqlite3 $STORAGE_ROOT/owncloud/owncloud.db 2>/dev/null) || true
root@testjammy:~/mailinabox# echo $?
0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants