<?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 Version20250226102021 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add payment card transfer log and save cards from tenant strategies';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$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');
$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');
$this->addSql('ALTER TABLE clients ADD save_card_strategy_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
$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');
$this->addSql('CREATE UNIQUE INDEX UNIQ_C82E74ECA7F7C5 ON clients (save_card_strategy_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE clients DROP FOREIGN KEY FK_C82E74ECA7F7C5');
$this->addSql('DROP TABLE payment_card_transfer_log');
$this->addSql('DROP TABLE save_cards_from_tenant_strategies');
$this->addSql('DROP INDEX UNIQ_C82E74ECA7F7C5 ON clients');
$this->addSql('ALTER TABLE clients DROP save_card_strategy_id');
}
}