{"table_name":"bksignals_product_stats","full_table_name":"wp_bksignals_product_stats","description":"Stores product records and related data.","detection_method":"static","confidence":"high","create_sql":"CREATE TABLE IF NOT EXISTS wp_bksignals_product_stats ( product_id BIGINT(20) UNSIGNED NOT NULL, views_total BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, views_24h INT(10) UNSIGNED NOT NULL DEFAULT 0, views_7d INT(10) UNSIGNED NOT NULL DEFAULT 0, views_30d INT(10) UNSIGNED NOT NULL DEFAULT 0, cart_total BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, cart_24h INT(10) UNSIGNED NOT NULL DEFAULT 0, cart_7d INT(10) UNSIGNED NOT NULL DEFAULT 0, cart_30d INT(10) UNSIGNED NOT NULL DEFAULT 0, sales_total BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, sales_24h INT(10) UNSIGNED NOT NULL DEFAULT 0, sales_7d INT(10) UNSIGNED NOT NULL DEFAULT 0, sales_30d INT(10) UNSIGNED NOT NULL DEFAULT 0, updated_at DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (product_id) ) $charset;\"; // Recent sales. $sql[] = \"CREATE TABLE IF NOT EXISTS wp_bksignals_recent_sales ( id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, order_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, order_item_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, product_id BIGINT(20) UNSIGNED NOT NULL, customer_city VARCHAR(100) NOT NULL DEFAULT '', customer_name VARCHAR(160) NOT NULL DEFAULT '', created_at DATETIME NOT NULL, PRIMARY KEY (id), KEY order_id (order_id), KEY order_item_id (order_item_id), KEY product_id (product_id), KEY created_at (created_at) ) $charset;\"; // Sales events. $sql[] = \"CREATE TABLE IF NOT EXISTS wp_bksignals_sales_events ( order_item_id BIGINT(20) UNSIGNED NOT NULL, order_id BIGINT(20) UNSIGNED NOT NULL, product_id BIGINT(20) UNSIGNED NOT NULL, quantity INT(10) UNSIGNED NOT NULL DEFAULT 1, status VARCHAR(20) NOT NULL DEFAULT 'active', customer_city VARCHAR(100) NOT NULL DEFAULT '', customer_name VARCHAR(160) NOT NULL DEFAULT '', purchased_at DATETIME NOT NULL, voided_at DATETIME NULL DEFAULT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY (order_item_id), KEY order_id (order_id), KEY product_status (product_id, status), KEY purchased_at (purchased_at) ) $charset;\"; // Live visitors. $sql[] = \"CREATE TABLE IF NOT EXISTS wp_bksignals_live_visitors ( visitor_id VARCHAR(64) NOT NULL, product_id BIGINT(20) UNSIGNED NOT NULL, last_seen DATETIME NOT NULL, PRIMARY KEY (visitor_id, product_id), KEY product_last_seen (product_id, last_seen), KEY last_seen (last_seen) ) $charset;\"; // Active carts. $sql[] = \"CREATE TABLE IF NOT EXISTS wp_bksignals_active_carts ( visitor_id VARCHAR(64) NOT NULL, product_id BIGINT(20) UNSIGNED NOT NULL, quantity INT(10) UNSIGNED NOT NULL DEFAULT 1, updated_at DATETIME NOT NULL, PRIMARY KEY (visitor_id, product_id), KEY product_updated (product_id, updated_at), KEY updated_at (updated_at) ) $charset;\"; // Daily stats. $sql[] = \"CREATE TABLE IF NOT EXISTS wp_bksignals_daily_stats ( date DATE NOT NULL, product_id BIGINT(20) UNSIGNED NOT NULL, views INT(10) UNSIGNED NOT NULL DEFAULT 0, add_to_cart INT(10) UNSIGNED NOT NULL DEFAULT 0, sales INT(10) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (date, product_id), KEY product_date (product_id, date) ) $charset;\"; // View queue. $sql[] = \"CREATE TABLE IF NOT EXISTS wp_bksignals_view_queue ( id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, product_id BIGINT(20) UNSIGNED NOT NULL, visitor_key VARCHAR(64) NOT NULL, viewed_at DATETIME NOT NULL, PRIMARY KEY (id), KEY product_id (product_id), KEY viewed_at (viewed_at) ) $charset;\"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; foreach ( $sql as $query ) { dbDelta( $query );","columns":[{"name":"product_id","type":"BIGINT(20) UNSIGNED","nullable":false,"primary_key":false},{"name":"views_total","type":"BIGINT(20) UNSIGNED","nullable":false,"primary_key":false},{"name":"views_24h","type":"INT(10) UNSIGNED","nullable":false,"primary_key":false},{"name":"views_7d","type":"INT(10) UNSIGNED","nullable":false,"primary_key":false},{"name":"views_30d","type":"INT(10) UNSIGNED","nullable":false,"primary_key":false},{"name":"cart_total","type":"BIGINT(20) UNSIGNED","nullable":false,"primary_key":false},{"name":"cart_24h","type":"INT(10) UNSIGNED","nullable":false,"primary_key":false},{"name":"cart_7d","type":"INT(10) UNSIGNED","nullable":false,"primary_key":false},{"name":"cart_30d","type":"INT(10) UNSIGNED","nullable":false,"primary_key":false},{"name":"sales_total","type":"BIGINT(20) UNSIGNED","nullable":false,"primary_key":false},{"name":"sales_24h","type":"INT(10) UNSIGNED","nullable":false,"primary_key":false},{"name":"sales_7d","type":"INT(10) UNSIGNED","nullable":false,"primary_key":false},{"name":"sales_30d","type":"INT(10) UNSIGNED","nullable":false,"primary_key":false},{"name":"updated_at","type":"DATETIME","nullable":false,"primary_key":false},{"name":"order_id","type":"BIGINT(20) UNSIGNED","nullable":false,"primary_key":false},{"name":"order_item_id","type":"BIGINT(20) UNSIGNED","nullable":false,"primary_key":false},{"name":"product_id","type":"BIGINT(20) UNSIGNED","nullable":false,"primary_key":false},{"name":"customer_city","type":"VARCHAR(100)","nullable":false,"primary_key":false},{"name":"customer_name","type":"VARCHAR(160)","nullable":false,"primary_key":false},{"name":"created_at","type":"DATETIME","nullable":false,"primary_key":false},{"name":"order_id","type":"BIGINT(20) UNSIGNED","nullable":false,"primary_key":false},{"name":"product_id","type":"BIGINT(20) UNSIGNED","nullable":false,"primary_key":false},{"name":"quantity","type":"INT(10) UNSIGNED","nullable":false,"primary_key":false},{"name":"status","type":"VARCHAR(20)","nullable":false,"primary_key":false},{"name":"customer_city","type":"VARCHAR(100)","nullable":false,"primary_key":false},{"name":"customer_name","type":"VARCHAR(160)","nullable":false,"primary_key":false},{"name":"purchased_at","type":"DATETIME","nullable":false,"primary_key":false},{"name":"voided_at","type":"DATETIME","nullable":true,"primary_key":false},{"name":"updated_at","type":"DATETIME","nullable":false,"primary_key":false},{"name":"product_id","type":"BIGINT(20) UNSIGNED","nullable":false,"primary_key":false},{"name":"last_seen","type":"DATETIME","nullable":false,"primary_key":false},{"name":"product_id","type":"BIGINT(20) UNSIGNED","nullable":false,"primary_key":false},{"name":"quantity","type":"INT(10) UNSIGNED","nullable":false,"primary_key":false},{"name":"updated_at","type":"DATETIME","nullable":false,"primary_key":false},{"name":"product_id","type":"BIGINT(20) UNSIGNED","nullable":false,"primary_key":false},{"name":"views","type":"INT(10) UNSIGNED","nullable":false,"primary_key":false},{"name":"add_to_cart","type":"INT(10) UNSIGNED","nullable":false,"primary_key":false},{"name":"sales","type":"INT(10) UNSIGNED","nullable":false,"primary_key":false},{"name":"product_id","type":"BIGINT(20) UNSIGNED","nullable":false,"primary_key":false},{"name":"visitor_key","type":"VARCHAR(64)","nullable":false,"primary_key":false},{"name":"viewed_at","type":"DATETIME","nullable":false,"primary_key":false}],"plugin":{"slug":"bk-signals-for-woocommerce","name":"BK Signals for WooCommerce","active_installs":0,"version":"1.0.0","wp_org_url":"https://wordpress.org/plugins/bk-signals-for-woocommerce/"}}