stream icon indicating copy to clipboard operation
stream copied to clipboard

Create the database tables if they do not exist when resetting the DB

Open tomjn opened this issue 4 years ago • 3 comments
trafficstars

Create the database tables if they do not exist when resetting the database

Fixes #1284

If the plugin is loaded without activation, tables are never created and resetting the database does not create tables. This PR changes that so that if tables are missing, a reset creates them.

Checklist

  • [ ] Project documentation has been updated to reflect the changes in this pull request, if applicable.
  • [ ] I have tested the changes in the local development environment (see contributing.md).
  • [ ] I have added phpunit tests.

Release Changelog

  • Fix: Describe a bug fix included in this release.
  • New: Describe a new feature in this release.

Release Checklist

  • [ ] This pull request is to the master branch.
  • [ ] Release version follows semantic versioning. Does it include breaking changes?
  • [ ] Update changelog in readme.txt.
  • [ ] Bump version in stream.php.
  • [ ] Bump Stable tag in readme.txt.
  • [ ] Bump version in classes/class-plugin.php.
  • [ ] Draft a release on GitHub.

tomjn avatar Sep 16 '21 16:09 tomjn

@kasparsd I don't believe it's strictly necessary, but it is nice and makes sense that a DB reset would make sure the tables are present and up to date. This is explicit where the other PR is implicit.

tomjn avatar Sep 17 '21 11:09 tomjn

I don't believe it's strictly necessary, but it is nice and makes sense that a DB reset would make sure the tables are present and up to date. This is explicit where the other PR is implicit.

I've been wondering if x+1 plugins with custom tables all do their "TABLE EXISTS" checks, does it have any real performance impact or not.

In the big picture, it does seem kind of redundant to guard against a real far-edge case millions of times / year * # of plugins.

lkraav avatar Sep 17 '21 11:09 lkraav

@lkraav for this PR it'll happen when a user clicks a button, as for WP Admin or CLI it's pretty safe. On the frontend it can add up quickly on a busy site

tomjn avatar Sep 17 '21 13:09 tomjn