WC_Install::create_tables PHP Method

create_tables() private static method

Tables: woocommerce_attribute_taxonomies - Table for storing attribute taxonomies - these are user defined woocommerce_termmeta - Term meta table - sadly WordPress does not have termmeta so we need our own woocommerce_downloadable_product_permissions - Table for storing user and guest download permissions. KEY(order_id, product_id, download_id) used for organizing downloads on the My Account page woocommerce_order_items - Order line items are stored in a table to make them easily queryable for reports woocommerce_order_itemmeta - Order line item meta is stored in a table for storing extra data. woocommerce_tax_rates - Tax Rates are stored inside 2 tables making tax queries simple and efficient. woocommerce_tax_rate_locations - Each rate can be applied to more than one postcode/city hence the second table.
private static create_tables ( )
    private static function create_tables()
    {
        global $wpdb;
        $wpdb->hide_errors();
        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
        /**
         * Before updating with DBDELTA, remove any primary keys which could be
         * modified due to schema updates.
         */
        if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}woocommerce_downloadable_product_permissions';")) {
            if (!$wpdb->get_var("SHOW COLUMNS FROM `{$wpdb->prefix}woocommerce_downloadable_product_permissions` LIKE 'permission_id';")) {
                $wpdb->query("ALTER TABLE {$wpdb->prefix}woocommerce_downloadable_product_permissions DROP PRIMARY KEY, ADD `permission_id` bigint(20) NOT NULL PRIMARY KEY AUTO_INCREMENT;");
            }
        }
        dbDelta(self::get_schema());
        $index_exists = $wpdb->get_row("SHOW INDEX FROM {$wpdb->comments} WHERE Column_name = 'comment_type' and Key_name = 'comment_type'");
        if (is_null($index_exists)) {
            // Add an index to the field comment_type to improve the response time of the query
            // used by WC_Comments::wp_count_comments() to get the number of comments by type.
            $wpdb->query("ALTER TABLE {$wpdb->comments} ADD INDEX woo_idx_comment_type (comment_type)");
        }
    }