Files
dmtools/migrations/Version20260906173325.php
T
FrankandClaude Sonnet 5 cb23d5b9ac Show AC on each tracker row
Combatant snapshots armor_class from the enemy when added (like maxHp),
shown as an "AC n" pill next to the name for quick hit checks. Migration
backfills existing combatants from their enemy.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-06 19:34:24 +02:00

32 lines
855 B
PHP

<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20260906173325 extends AbstractMigration
{
public function getDescription(): string
{
return 'Snapshot armor class onto each combatant';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE combatant ADD armor_class SMALLINT DEFAULT 10 NOT NULL');
$this->addSql('UPDATE combatant c JOIN enemy e ON c.enemy_id = e.id SET c.armor_class = e.armor_class');
$this->addSql('ALTER TABLE combatant ALTER armor_class DROP DEFAULT');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE combatant DROP armor_class');
}
}