Add bead separator support to Rosary Builder
- Bead Markers section in library panel with Small, Large, Crucifix cards - Bead steps render as amber-tinted cards in the sequence (no attribution) - migrate_v5.php: adds step_type/bead_type columns, makes prayer_id nullable - Bead steps produce slides with proper bead+bead_index so the ring advances during presentation — allows participants to follow along on physical beads - Prayer steps between beads still show bead_index=null (ring stays on last bead) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* migrate_v5.php — Adds step_type and bead_type columns to builder_steps
|
||||
* for bead separator support. Makes prayer_id nullable.
|
||||
* Run once in browser, then delete.
|
||||
*/
|
||||
require_once __DIR__ . '/config/db.php';
|
||||
$pdo = get_pdo();
|
||||
$log = [];
|
||||
|
||||
function mig5_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, 1061, 1054], true)) {
|
||||
$log[] = ['skip', $label . ' (already exists)'];
|
||||
} else {
|
||||
$log[] = ['err', $label . ': ' . $e->getMessage()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mig5_sql($pdo, 'Add step_type column', "
|
||||
ALTER TABLE builder_steps
|
||||
ADD COLUMN step_type ENUM('prayer','bead') NOT NULL DEFAULT 'prayer' AFTER session_id
|
||||
", $log);
|
||||
|
||||
mig5_sql($pdo, 'Add bead_type column', "
|
||||
ALTER TABLE builder_steps
|
||||
ADD COLUMN bead_type ENUM('small','large','crucifix') NULL AFTER step_type
|
||||
", $log);
|
||||
|
||||
mig5_sql($pdo, 'Make prayer_id nullable', "
|
||||
ALTER TABLE builder_steps
|
||||
MODIFY COLUMN prayer_id INT NULL
|
||||
", $log);
|
||||
|
||||
?><!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Migrate v5</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 v5 — Bead Separator Support</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_v5.php</code>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user