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

Don't create cards_abiduri it if already exists #31221

Merged
merged 1 commit into from
Mar 24, 2022

Conversation

artonge
Copy link
Contributor

@artonge artonge commented Feb 16, 2022

During migration from ownCloud, the cards_abiduri index is created but the addressbookid_uri_index index is not deleted. This leads to an error in this code path.

This PR make sure that we do not try to create the cards_abiduri index if it already exists and that the addressbookid_uri_index index is properly deleted.

Handy script to test the migration. Use it from a nextcloud root directory containing the migration.

#!/bin/bash

set -eu

# Serving ownCloud then Nextcloud at localhost:8080
# Username: admin
# Password: admin

docker kill oc || true
docker rm oc || true

docker run \
	--rm \
	--name oc \
	--detach \
	--env OWNCLOUD_DOMAIN=localhost:8080 \
	--publish 8080:8080 \
	--volume /var/www/owncloud \
	--volume "$PWD":/mnt/local \
	owncloud/server:10.5

docker exec -it oc apt update
docker exec -it oc apt install -y nano rsync

docker exec -it oc sed -i '9,14d' /var/www/owncloud/config/config.php
docker exec -it oc occ app:enable oauth2
docker exec -it oc occ market:install calendar
docker exec -it oc occ app:enable configreport
docker exec -it oc cp /var/www/owncloud/config/config.php /var/www/config.php

instance=""
read -rp "> Double press enter to start the migration." instance

docker exec -it oc rsync --delete --recursive --human-readable --exclude .git --exclude node_modules /mnt/local/ /var/www/owncloud
docker exec -it oc cp /var/www/config.php /var/www/owncloud/config/config.php
docker exec -it oc chown -R www-data:www-data /var/www/owncloud

docker exec -it oc occ upgrade -vvv || true

occ db:convert-filecache-bigint
occ db:add-missing-columns
occ db:add-missing-indices
occ db:add-missing-primary-keys

# Use this command to copy your change in MigrateOauthTables.php to the docker container.
# docker exec -it oc cp /mnt/local/lib/private/Repair/Owncloud/MigrateOauthTables.php /var/www/owncloud/lib/private/Repair/Owncloud/MigrateOauthTables.php

@artonge artonge self-assigned this Feb 16, 2022
@artonge artonge added this to the Nextcloud 24 milestone Feb 16, 2022
@artonge artonge force-pushed the feat/dont_create_oc_cards_index_if_it_exists branch from 3abd033 to f2a0614 Compare February 17, 2022 10:43
Comment on lines +230 to 270
foreach ($table->getIndexes() as $index) {
if ($index->getColumns() === ['addressbookid', 'uri']) {
$table->renameIndex('addressbookid_uri_index', 'cards_abiduri');
}
}
Copy link
Contributor Author

@artonge artonge Feb 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@julius, looks like you wrote the code.

Can you tell me why we use a foreach instead of renaming the index directly? I feel like I am missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@artonge
Copy link
Contributor Author

artonge commented Mar 24, 2022

/rebase

Signed-off-by: Louis Chemineau <louis@chmn.me>
@nextcloud-command nextcloud-command force-pushed the feat/dont_create_oc_cards_index_if_it_exists branch from f2a0614 to 970fb7c Compare March 24, 2022 10:42
@artonge artonge requested review from a team, PVince81, icewind1991 and blizzz and removed request for a team March 24, 2022 13:09
@skjnldsv skjnldsv mentioned this pull request Mar 24, 2022
Copy link
Member

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@PVince81 PVince81 merged commit 04d4666 into master Mar 24, 2022
@PVince81 PVince81 deleted the feat/dont_create_oc_cards_index_if_it_exists branch March 24, 2022 16:12
@artonge
Copy link
Contributor Author

artonge commented Mar 28, 2022

/backport to stable23

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

Successfully merging this pull request may close these issues.

4 participants