This commit is contained in:
2026-10-06 18:51:23 -06:00
parent 8424dacd03
commit e2c26b7f21
4223 changed files with 737986 additions and 53 deletions
@@ -0,0 +1,28 @@
<?php
declare (strict_types=1);
namespace JooosiFon\Migrations;
use JooosiFon\Database\FontTable;
use JooosiFon\Database\Migration\AbstractMigration;
/**
* Create the Jooosi Fon font library table.
*/
final class Version20221121114557 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create the Jooosi Fon fonts table.';
}
public function up(): void
{
FontTable::create();
}
public function down(): void
{
/** @var wpdb $wpdb */
global $wpdb;
$sql = "DROP TABLE IF EXISTS `{$wpdb->prefix}jooosi_fon_fonts`";
$wpdb->query($sql);
}
}
@@ -0,0 +1,42 @@
<?php
declare (strict_types=1);
namespace JooosiFon\Migrations;
use JooosiFon\Database\FontTable;
use JooosiFon\Database\Migration\AbstractMigration;
use wpdb;
/**
* Rename the font library table for the Jooosi Fon rebrand.
*
* @todo Remove this legacy rebrand migration completely in Jooosi Fon 3.0.0.
*/
final class Version20260817000000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Rename the legacy fonts table to Jooosi Fon.';
}
public function up(): void
{
FontTable::migrateLegacy();
}
public function down(): void
{
/** @var wpdb $wpdb */
global $wpdb;
$legacyTable = $wpdb->prefix . 'yabe_webfont_fonts';
$table = $wpdb->prefix . 'jooosi_fon_fonts';
if ($this->table_exists($table) && !$this->table_exists($legacyTable)) {
if ($wpdb->query("RENAME TABLE `{$table}` TO `{$legacyTable}`") === \false) {
throw new \RuntimeException($wpdb->last_error ?: 'Unable to restore the legacy Jooosi Fon fonts table.');
}
}
}
private function table_exists(string $table): bool
{
/** @var wpdb $wpdb */
global $wpdb;
return $wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $wpdb->esc_like($table))) === $table;
}
}
@@ -0,0 +1,53 @@
<?php
declare (strict_types=1);
namespace JooosiFon\Migrations;
use JooosiFon\Database\FontTable;
use JooosiFon\Database\Migration\AbstractMigration;
/**
* Make font payload storage and the API's common filters scale safely.
*/
final class Version20260818000000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Expand font payload columns and add API query indexes.';
}
public function up(): void
{
global $wpdb;
// Repair an incomplete rebrand before altering or querying the table.
FontTable::migrateLegacy();
$table = $wpdb->prefix . 'jooosi_fon_fonts';
$statements = ["ALTER TABLE `{$table}` MODIFY `metadata` MEDIUMTEXT NULL, MODIFY `font_faces` MEDIUMTEXT NULL"];
$indexes = ['jooosi_fon_deleted_status' => '`deleted_at`, `status`', 'jooosi_fon_type_deleted' => '`type`, `deleted_at`', 'jooosi_fon_slug' => '`slug`(191)'];
foreach ($indexes as $index => $columns) {
if (!$this->indexExists($table, $index)) {
$statements[] = "ALTER TABLE `{$table}` ADD INDEX `{$index}` ({$columns})";
}
}
foreach ($statements as $statement) {
if ($wpdb->query($statement) === \false) {
throw new \RuntimeException($wpdb->last_error ?: 'Unable to optimize the Jooosi Fon fonts table.');
}
}
}
public function down(): void
{
global $wpdb;
$table = $wpdb->prefix . 'jooosi_fon_fonts';
foreach (['jooosi_fon_deleted_status', 'jooosi_fon_type_deleted', 'jooosi_fon_slug'] as $index) {
if ($this->indexExists($table, $index)) {
$wpdb->query("ALTER TABLE `{$table}` DROP INDEX `{$index}`");
}
}
}
private function indexExists(string $table, string $index): bool
{
global $wpdb;
return (bool) $wpdb->get_var($wpdb->prepare('SELECT 1 FROM information_schema.statistics
WHERE table_schema = DATABASE() AND table_name = %s AND index_name = %s
LIMIT 1', $table, $index));
}
}
@@ -0,0 +1,23 @@
<?php
declare (strict_types=1);
namespace JooosiFon\Migrations;
use JooosiFon\Database\Migration\AbstractMigration;
/**
* Repair installations where the rebrand migration history was recorded but
* the Jooosi Fon font table was never created or restored.
*/
final class Version20260902000000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Repair a missing Jooosi Fon fonts table after the rebrand.';
}
public function up(): void
{
// Reapply the idempotent schema optimization when an earlier history
// row says it ran even though the table itself was lost.
(new \JooosiFon\Migrations\Version20260818000000())->up();
}
}