<?php
/**
 * File Path: includes/migrations/class-mbs-migration-4-33.php
 *
 * Migration 4.33 -- Session 212: Correct global default section display order.
 *
 * The canonical order in MBS_Section_Helper::get_canonical_keys() was updated
 * to match the client-approved display order. Because migration 4.31 already
 * seeded post_id = 0 rows, seed_default_section_order() (append-only) will not
 * re-sort them. A single save_order( 0, get_canonical_keys() ) call atomically
 * resets sort_order for all existing rows via INSERT...ON DUPLICATE KEY UPDATE.
 *
 * Correct order:
 *   1. About the Book
 *   2. Book Details
 *   3. Endorsements / Blurbs
 *   4. Amazon Reviews
 *   5. Kindle Preview
 *   6. Reader Reviews
 *   7. Awards & Accolades
 *   8. Look Inside
 *   9. Related Books
 *  10. More in This Series
 *  11. More in This Collection
 *  12. More in This Universe
 *  13. More by This Author
 *  14. Audio Sample
 *  15. Book Trailer
 *  16. Book Club Resources
 *
 * @package MyBookShowroom
 * @since   1.5.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class MBS_Migration_4_33 implements MBS_Migration { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- mbs_/MBS_ prefix is correct; scanner not configured with plugin prefix

	/**
	 * Returns the migration version string.
	 *
	 * @return string
	 */
	public function version(): string { return '4.33'; }

	/**
	 * Run the migration.
	 *
	 * Resets the global default section order (post_id = 0) to the canonical
	 * order defined in MBS_Section_Helper::get_canonical_keys().
	 *
	 * @return void
	 */
	public function up(): void {
		if ( class_exists( 'MBS_Section_Order_DAO' ) && class_exists( 'MBS_Section_Helper' ) ) {
			MBS_Section_Order_DAO::save_order( 0, MBS_Section_Helper::get_canonical_keys() );
		}
	}
}
