prefix . 'wpaw_cost_tracking'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE IF NOT EXISTS $table_name ( id bigint(20) NOT NULL AUTO_INCREMENT, post_id bigint(20) NOT NULL, model varchar(255) NOT NULL, action varchar(50) NOT NULL, input_tokens int(11) NOT NULL, output_tokens int(11) NOT NULL, cost decimal(10,6) NOT NULL, created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY (id), KEY post_id (post_id), KEY created_at (created_at) ) $charset_collate;"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); // Check if table was created $table_exists = $wpdb->get_var("SHOW TABLES LIKE '$table_name'"); if ($table_exists) { echo "✅ Table '$table_name' created successfully!\n"; // Show table structure $columns = $wpdb->get_results("DESCRIBE $table_name"); echo "\nTable structure:\n"; foreach ($columns as $column) { echo " - {$column->Field} ({$column->Type})\n"; } } else { echo "❌ Failed to create table '$table_name'\n"; echo "Error: " . $wpdb->last_error . "\n"; }