Skip to content

Don't create cards_abiduri it if already exists - #31221

Merged
PVince81 merged 1 commit into
masterfrom
feat/dont_create_oc_cards_index_if_it_exists
Mar 24, 2022
Merged

Don't create cards_abiduri it if already exists#31221
PVince81 merged 1 commit into
masterfrom
feat/dont_create_oc_cards_index_if_it_exists

Conversation

@artonge

@artongeartonge commented Feb 16, 2022

Copy link
Copy Markdown
Collaborator

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/bashset -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

@artongeartonge self-assigned this Feb 16, 2022
@artongeartonge added this to the Nextcloud 24 milestone Feb 16, 2022
Comment threadcore/Command/Db/AddMissingIndices.php Outdated
@artonge
artongeforce-pushed the feat/dont_create_oc_cards_index_if_it_exists branch from 3abd033 to f2a0614CompareFebruary 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');
}
}

@artongeartongeFeb 17, 2022

Copy link
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

@artonge

Copy link
Copy Markdown
CollaboratorAuthor

/rebase

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

@PVince81PVince81 left a comment

Copy link
Copy Markdown
Member

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 masterMar 24, 2022
@PVince81
PVince81 deleted the feat/dont_create_oc_cards_index_if_it_exists branch March 24, 2022 16:12
@artonge

Copy link
Copy Markdown
CollaboratorAuthor

/backport to stable23

Sign up for freeto 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

@artonge@PVince81@tcitworld@come-nc