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

Skip dropping automatic indices #619

Merged

Conversation

Unpublished
Copy link
Contributor

@Unpublished Unpublished commented Dec 15, 2019

They cannot be dropped manually:
index associated with UNIQUE or PRIMARY KEY constraint cannot be dropped

For automatically created indices (used to implement the PRIMARY KEY or UNIQUE constraints) the sql field is NULL.

From https://sqlite.org/faq.html#q7

Can be reproduced by just upgrading to 2.0.0 (without login).

While at it I used try-with-resources to automatically close the cursor.

@Unpublished Unpublished changed the title Skip dropping automatic indexes Skip dropping automatic indices Dec 15, 2019
They cannot be dropped manually
@Unpublished Unpublished force-pushed the skipDroppingAutoIndex branch from 1f25ce6 to 0679e55 Compare December 15, 2019 14:16
@stefan-niedermann
Copy link
Member

Thank you for the contribution, but maybe you can clearify, what exactly the problem is? I can not understand it.

Upgrading from 1.0.2 to 2.0.0 works without any noticable problem for me. Is there some kind of exception in the Logcat for you? Or does the app crash on upgrade?

@Unpublished
Copy link
Contributor Author

Upgrading from 1.0.2 to 2.0.0 works without any noticable problem for me. Is there some kind of exception in the Logcat for you? Or does the app crash on upgrade?

Sorry for not being clear.
It kept crashing for me on startup after upgrade.
I know it contained the mentioned index associated with UNIQUE or PRIMARY KEY constraint cannot be dropped error with something like sqlite_autoindex_accounts1 and it was caused by the edited method.

But I don't have the logcat anymore...
I'll try to reproduce and post the complete logcat.

@stefan-niedermann stefan-niedermann merged commit a91150d into nextcloud:master Dec 15, 2019
@stefan-niedermann
Copy link
Member

stefan-niedermann commented Dec 15, 2019

@Unpublished, since you seem to know some things about the SQLite stuff: I tried to add an foreign key from the Notes table (account-id) to the accounts-table (id) in version 2.0.0.

Unfortunately i am not sure if i did this right, because in my SQLite browser i can not see any foreign key association.

Maybe you want to have a look at this or have a hint for me? 🚀

@Unpublished
Copy link
Contributor Author

Unpublished commented Dec 15, 2019

First, thanks for merging and I had to look this up as well :)

Your migration to add the foreign key looks fine for me.

I couldn't find it in SQLite browser as well.
Then I opened the db in IntelliJ (there is a database plugin) and there the foreign key is displayed.
Afterwards I discovered it in SQLite browser via selecting NOTES in Database Structure tab, Modify Table, scroll to right in the new popup and there it is under Foreign Key.

@Unpublished Unpublished deleted the skipDroppingAutoIndex branch December 15, 2019 21:22
@stefan-niedermann
Copy link
Member

Thank you for having a look! Well well, know your tools, shame on me 😆

Would be great to see you again contributing in the future :)

@Unpublished
Copy link
Contributor Author

You never stop learning :)

Sure, I'll keep contributing from time to time to the whole nextcloud ecosystem. Might be hard for the notes app as I'm quite happy with it ;)

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 this pull request may close these issues.

2 participants