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

Fixing database error #238

Merged
merged 5 commits into from
Apr 13, 2021
Merged

Conversation

cnohall
Copy link
Contributor

@cnohall cnohall commented Apr 9, 2021

This PR is created to fix this error. I was able to recreate the error and has done some small changes in order to fix it.

There are mainly two things that have changed. The register_activation_hook() has been introduced. It is true that this is not called during an update. However, it seems to be necessary during plugin initiation.

$sql CREATE TABLE IF NOT EXISTS has been changed to CREATE TABLE. This is the way it is structured in the WordPress documentation. It seems to be the case that dbDelta() does not require IF NOT EXISTS, but will instead discern this itself.

As part of testing I've deleted, installed, upgraded the database, with and without orders. It seems to work as it should,

Please review this PR.

@shivaenigma
Copy link
Collaborator

There are mainly two things that have changed. The register_activation_hook() has been introduced. It is true that this is not called during an update. However, it seems to be necessary during plugin initiation.

What is the reason of doing this change and changing the update logic ? As we know plugins_loaded is called on each page so this is really uncessary

It is not enough to just address the real reason of this error? Changing CREATE IF NOT EXISTS TO CREATE should be sufficient.

@cnohall
Copy link
Contributor Author

cnohall commented Apr 9, 2021

If only CREATE IF NOT EXISTS TO CREATE is changed it results in a new database related error. It seems to have to
image.

Using register_activation_hook() to fire blockonomics_create_table() resolved the error given in the image above.

1 similar comment
@cnohall
Copy link
Contributor Author

cnohall commented Apr 9, 2021

If only CREATE IF NOT EXISTS TO CREATE is changed it results in a new database related error. It seems to have to
image.

Using register_activation_hook() to fire blockonomics_create_table() resolved the error given in the image above.

@shivaenigma
Copy link
Collaborator

Looking good. Will merge after some testing

@shivaenigma shivaenigma merged commit 72f9624 into blockonomics:master Apr 13, 2021
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