migrations/Version20221124220117.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use App\Util\StringGenerator;
  5. use Doctrine\DBAL\Schema\Schema;
  6. use Doctrine\Migrations\AbstractMigration;
  7. /**
  8.  * Auto-generated Migration: Please modify to your needs!
  9.  */
  10. final class Version20221124220117 extends AbstractMigration
  11. {
  12.     public function getDescription(): string
  13.     {
  14.         return '';
  15.     }
  16.     public function up(Schema $schema): void
  17.     {
  18.         // this up() migration is auto-generated, please modify it to your needs
  19.         $this->addSql('ALTER TABLE freeswitch.click_to_call ADD token VARCHAR(255) DEFAULT NULL');
  20.         foreach ($this->connection->fetchAllAssociative('SELECT id FROM freeswitch.click_to_call') as $clickToCall) {
  21.             $this->addSql('UPDATE freeswitch.click_to_call SET token = :token WHERE id = :id', ['token' => StringGenerator::random(32), 'id' => $clickToCall['id']]);
  22.         }
  23.         $this->addSql('ALTER TABLE freeswitch.click_to_call ALTER token SET NOT NULL');
  24.     }
  25.     public function down(Schema $schema): void
  26.     {
  27.         // this down() migration is auto-generated, please modify it to your needs
  28.         $this->addSql('CREATE SCHEMA public');
  29.         $this->addSql('ALTER TABLE freeswitch.click_to_call DROP token');
  30.     }
  31. }