<?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 Version20240425205313 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add refund transactions table';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE refund_transactions (id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', payment_intent_id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', amount NUMERIC(20, 3) NOT NULL, error_message VARCHAR(255) DEFAULT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, status VARCHAR(50) NOT NULL, INDEX IDX_21162AD58BC036E4 (payment_intent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE refund_transactions ADD CONSTRAINT FK_21162AD58BC036E4 FOREIGN KEY (payment_intent_id) REFERENCES payment_intents (id) ON DELETE RESTRICT');
$this->addSql('CREATE INDEX payment_intent_status_idx ON payment_intents (status)');
$this->addSql('ALTER TABLE transactions ADD captured_amount NUMERIC(20, 3) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE refund_transactions DROP FOREIGN KEY FK_21162AD58BC036E4');
$this->addSql('DROP TABLE refund_transactions');
$this->addSql('DROP INDEX payment_intent_status_idx ON payment_intents');
$this->addSql('ALTER TABLE transactions DROP captured_amount');
}
}