8c047f5b28
Each prayer in the library has an optional default_bead_type (small/large/ crucifix). Standard prayers get sensible defaults: Our Father=large, Hail Mary=small, Sign of Cross=crucifix, Divine Mercy beads accordingly. In the sequence, each step card shows a bead selector (—/○/●/✝) so users can override the default per step. Adding a prayer pre-fills its default. Bead library icon hints (○●✝) appear on prayer cards in the library. Modal now includes a Bead selector for creating/editing prayers. Remove the separate Bead Markers library section — beads live on prayers. build_slides: prayer steps with bead_type now get a real bead_index so the ring advances correctly during presentation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
75 lines
2.4 KiB
PHP
75 lines
2.4 KiB
PHP
<?php
|
|
/**
|
|
* migrate_v6.php — Adds default_bead_type to custom_prayers.
|
|
* Updates standard seeded prayers with sensible bead defaults.
|
|
* Run once in browser, then delete.
|
|
*/
|
|
require_once __DIR__ . '/config/db.php';
|
|
$pdo = get_pdo();
|
|
$log = [];
|
|
|
|
function mig6_sql(PDO $pdo, string $label, string $sql, array &$log): void {
|
|
try {
|
|
$pdo->exec($sql);
|
|
$log[] = ['ok', $label];
|
|
} catch (PDOException $e) {
|
|
if (in_array($e->errorInfo[1], [1060, 1054], true)) {
|
|
$log[] = ['skip', $label . ' (already exists)'];
|
|
} else {
|
|
$log[] = ['err', $label . ': ' . $e->getMessage()];
|
|
}
|
|
}
|
|
}
|
|
|
|
mig6_sql($pdo, 'Add default_bead_type to custom_prayers', "
|
|
ALTER TABLE custom_prayers
|
|
ADD COLUMN default_bead_type ENUM('small','large','crucifix') NULL AFTER all_text
|
|
", $log);
|
|
|
|
// Set defaults for the seeded standard global prayers
|
|
$defaults = [
|
|
'Sign of the Cross' => 'crucifix',
|
|
'Our Father' => 'large',
|
|
'Hail Mary' => 'small',
|
|
'Eternal Father (Divine Mercy)' => 'large',
|
|
'For the Sake of His Sorrowful Passion' => 'small',
|
|
];
|
|
|
|
$updated = 0;
|
|
$st = $pdo->prepare(
|
|
"UPDATE custom_prayers SET default_bead_type = ? WHERE name = ? AND is_global = 1"
|
|
);
|
|
foreach ($defaults as $name => $bead) {
|
|
$st->execute([$bead, $name]);
|
|
if ($st->rowCount() > 0) $updated++;
|
|
}
|
|
$log[] = ['ok', "Updated default bead types for {$updated} standard prayers"];
|
|
|
|
?><!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Migrate v6</title>
|
|
<style>
|
|
body { font-family: system-ui; max-width: 700px; margin: 40px auto; padding: 0 20px; }
|
|
.ok { color: #15803d; } .skip { color: #b45309; } .err { color: #dc2626; }
|
|
li { margin: 4px 0; font-size: 14px; }
|
|
.done { background: #f0fdf4; border: 1px solid #86efac; padding: 16px; border-radius: 8px; margin-top: 20px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h2>Migrate v6 — Prayer Bead Defaults</h2>
|
|
<ul>
|
|
<?php foreach ($log as [$status, $msg]): ?>
|
|
<li class="<?= $status ?>">
|
|
<?= $status === 'ok' ? '✓' : ($status === 'skip' ? '◌' : '✗') ?>
|
|
<?= htmlspecialchars($msg) ?>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
<?php if (!array_filter($log, fn($l) => $l[0] === 'err')): ?>
|
|
<div class="done"><strong>Migration complete.</strong> Delete this file: <code>migrate_v6.php</code></div>
|
|
<?php endif; ?>
|
|
</body>
|
|
</html>
|