get_charset_collate(); $tbl = $wpdb->prefix . 'aieo_price_history'; $wpdb->query("CREATE TABLE IF NOT EXISTS {$tbl} ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, `product_id` bigint unsigned NOT NULL, `parent_id` bigint unsigned NULL DEFAULT NULL, `price` decimal(12,4) NOT NULL, `regular_price` decimal(12,4) NULL DEFAULT NULL, `on_sale` tinyint(1) NOT NULL DEFAULT 0, `currency` char(3) NOT NULL DEFAULT 'EUR', `observed_at` datetime NOT NULL, `source` varchar(20) NOT NULL DEFAULT 'price_change_hook', PRIMARY KEY (`id`), KEY `idx_product_time` (`product_id`, `observed_at`), KEY `idx_currency` (`currency`) ) {$charset_collate};"); }