migrations/Version20250226102021.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. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20250226102021 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Add payment card transfer log and save cards from tenant strategies';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('CREATE TABLE payment_card_transfer_log (id INT AUTO_INCREMENT NOT NULL, from_user_id VARCHAR(36) NOT NULL, token_id VARCHAR(64) NOT NULL, payment_card_id VARCHAR(36) NOT NULL, card_mask VARCHAR(36) NOT NULL, card_expiry_date VARCHAR(10) NOT NULL, to_user_id VARCHAR(36) NOT NULL, extra_info JSON DEFAULT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, INDEX payment_card_transfer_log_created_at_idx (created_at), INDEX payment_card_transfer_log_from_user_id_idx (from_user_id), INDEX payment_card_transfer_log_to_user_id_idx (to_user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE save_cards_from_tenant_strategies (id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', created_at DATETIME DEFAULT CURRENT_TIMESTAMP, discriminator VARCHAR(100) NOT NULL, tenant_public_key LONGTEXT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('ALTER TABLE clients ADD save_card_strategy_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
  21.         $this->addSql('ALTER TABLE clients ADD CONSTRAINT FK_C82E74ECA7F7C5 FOREIGN KEY (save_card_strategy_id) REFERENCES save_cards_from_tenant_strategies (id) ON DELETE SET NULL');
  22.         $this->addSql('CREATE UNIQUE INDEX UNIQ_C82E74ECA7F7C5 ON clients (save_card_strategy_id)');
  23.     }
  24.     public function down(Schema $schema): void
  25.     {
  26.         // this down() migration is auto-generated, please modify it to your needs
  27.         $this->addSql('ALTER TABLE clients DROP FOREIGN KEY FK_C82E74ECA7F7C5');
  28.         $this->addSql('DROP TABLE payment_card_transfer_log');
  29.         $this->addSql('DROP TABLE save_cards_from_tenant_strategies');
  30.         $this->addSql('DROP INDEX UNIQ_C82E74ECA7F7C5 ON clients');
  31.         $this->addSql('ALTER TABLE clients DROP save_card_strategy_id');
  32.     }
  33. }