Before embarking on the plugin migration process in WordPress, it’s crucial to ensure that certain prerequisites are in place to guarantee a smooth and successful transition.
- Database Access: Confirm you have access to your WordPress database, as this is where most of the migration work will occur.
- Read/Write Permissions: Verify that your user account has the necessary read and write permissions for the database to make changes without restrictions.
- Database Backup: Always back up your database before making any changes. This step is vital for restoring your site in case of any unforeseen issues during the migration.
- Technical Knowledge: Basic understanding of database management and familiarity with tools like PHPMyAdmin or similar database interfaces. This knowledge is essential for executing SQL queries and managing database tables.
- Migration Tools/Plugins: If you’re using specific tools or plugins for the migration, ensure they are installed, updated, and compatible with your WordPress version.
By meeting these prerequisites, you set a strong foundation for a smooth migration process, minimizing risks and potential disruptions to your website.
YASRs database table structure
The main table, typically named
<prefix> reflects your WordPress configuration), is designed to update with each user rating. This table includes five key columns:
post_id (the ID of the rated post),
user_id (the ID of the user rating the post, with 0 for anonymous users and 1 for the admin),
vote (the actual rating score, such as 5.0 or 4.0),
date (the date the rating was made), and
ip (the IP address of the user who made the rating).
In comparison, the GD Star Rating system uses a table named
<prefix>_gdsr_votes_log, which is more extensive and contains several crucial columns, including
voted (the date of the vote),
vote_type (the kind of vote cast). This structure is integral to managing and interpreting user ratings within the plugin.
How to copy the ratings from GD star rating to YASR
Database Backup: Always start by backing up your database. Although the focus is solely on the YASR table, it’s a best practice to have a backup to avoid any unexpected issues. Ensure you have a complete backup before proceeding; if not, do not move forward with the process.
Here’s the SQL statement to migrate / import existing ratings from the GD star rating plugin to YASR:
INSERT INTO wordpress_yasr_log (post_id, vote, date, user_id, ip) SELECT id, vote, voted, user_id, ip FROM wordpress_gdsr_votes_log WHERE vote_type='article';
What to do if you previously had 10 stars and YASR only supports 5?
Adapting Ratings for YASR: For those using a 10-star system in GD Star Rating, you’ll need to adjust the ratings to fit YASR’s format. For instance, a 9 or 10 rating in GD Star will correspond to a 5-star rating in YASR. Below is a sample SQL query for this transformation, adaptable as needed. The YASR wordpress ratings plugin table in this example is named
wordpress_yasr_log, and the GD Star table is
INSERT INTO wordpress_yasr_log (post_id, vote, date, user_id, ip) SELECT id, CASE WHEN vote BETWEEN '9' AND '10' THEN 5.0 WHEN vote BETWEEN '7' AND '8' THEN 4.0 WHEN vote BETWEEN '5' AND '6' THEN 3.0 WHEN vote BETWEEN '3' AND '4' THEN 2.0 WHEN vote BETWEEN '1' AND '2' THEN 1.0 END AS vote, voted, user_id, ip FROM wordpress_gdsr_votes_log WHERE vote_type='article';