1. Home
  2. Docs
  3. WooCommerce License Keys
  4. Troubleshooting
  5. Database Schema

Database Schema

Only related to WooCommerce License Keys (extended) premium plugin.

Our plugin database schema is best optimized with at least MySQL 5.6. We do detect and lower the data table syntax creation if the version is lower, although you might still run into troubles if your database settings have very limited index sizing or have any other special configuration.

If you run into this problem, try creating these tables manually in your database. if you get an error remove from the statements any issue that is giving you trouble.

Make sure to replace {prefix} with your WordPress database prefix.

license_keys_log

CREATE TABLE IF NOT EXISTS `{prefix}license_keys_log` (
    `id` bigint(11) UNSIGNED NOT NULL AUTO_INCREMENT,
    `key_code` varchar(128) NOT NULL,
    `activation_id` bigint(11) UNSIGNED NULL,
    `ip` varchar(32) NULL,
    `transaction` int(3) UNSIGNED NOT NULL,
    `is_valid` TINYINT(1) UNSIGNED NOT NULL,
    `time` decimal(11,6) UNSIGNED NULL,
    `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY(`id`),
    INDEX(`key_code`, `activation_id`),
    INDEX(`key_code`, `activation_id`, `transaction`),
    INDEX(`key_code`, `activation_id`, `transaction`, `is_valid`)
)

license_keys_error_log

CREATE TABLE IF NOT EXISTS `{prefix}license_keys_error_log` (
    `id` bigint(11) UNSIGNED NOT NULL AUTO_INCREMENT,
    `log_id` bigint(11) UNSIGNED NOT NULL,
    `errors` text NOT NULL,
    `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY(`id`),
    INDEX(`log_id`)
)

license_keys

CREATE TABLE IF NOT EXISTS `{prefix}license_keys` (
    `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
    `key_code` varchar(128) NOT NULL,
    `type` varchar(10) NOT NULL DEFAULT 'generated',
    `order_item_id` bigint(20) UNSIGNED NULL,
    `order_item_meta_id` bigint(20) UNSIGNED NULL,
    `restricted_post_id` bigint(20) UNSIGNED NULL,
    `uses` int(9) NOT NULL DEFAULT 0,
    `expires_at` datetime NULL,
    `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY(`id`),
    UNIQUE(`key_code`),
    INDEX(`key_code`, `order_item_meta_id`, `type`),
    INDEX(`key_code`, `order_item_meta_id`, `type`, `expires_at`),
    INDEX(`key_code`, `order_item_meta_id`, `expires_at`)
)

Update option

After all schema tables have been created, make sure to update the version tag in the database, simply run the following update:

UPDATE {prefix}options
SET option_value = 'v1.6.0'
WHERE option_name = 'license_keys_schema'

Schema information

Current version: v1.6.0

Was this article helpful to you? Yes No