migrations/Version20260319120500.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. final class Version20260319120500 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Add token_balance to user for chatbot token accounting';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         if (!$schema->hasTable('user')) {
  15.             return;
  16.         }
  17.         $table $schema->getTable('user');
  18.         if (!$table->hasColumn('token_balance')) {
  19.             $this->addSql('ALTER TABLE user ADD token_balance INT NOT NULL DEFAULT 0');
  20.         }
  21.     }
  22.     public function down(Schema $schema): void
  23.     {
  24.         if (!$schema->hasTable('user')) {
  25.             return;
  26.         }
  27.         $table $schema->getTable('user');
  28.         if ($table->hasColumn('token_balance')) {
  29.             $this->addSql('ALTER TABLE user DROP token_balance');
  30.         }
  31.     }
  32. }