<?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 Version20260320204209 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE orders (id INT AUTO_INCREMENT NOT NULL, prestataire_id INT NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', checkout_session_id VARCHAR(255) NOT NULL, checkout_expires_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', status VARCHAR(20) DEFAULT \'pending\' NOT NULL, stripe_event_id VARCHAR(255) DEFAULT NULL, order_type VARCHAR(20) DEFAULT \'pack\' NOT NULL, credits INT DEFAULT NULL, price INT DEFAULT 0 NOT NULL, return_token_hash VARCHAR(64) DEFAULT NULL, demande_ids JSON NOT NULL, UNIQUE INDEX UNIQ_E52FFDEEDA6D31C4 (checkout_session_id), UNIQUE INDEX UNIQ_E52FFDEE2CB034B8 (stripe_event_id), INDEX IDX_E52FFDEEBE3DB2B7 (prestataire_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE orders ADD CONSTRAINT FK_E52FFDEEBE3DB2B7 FOREIGN KEY (prestataire_id) REFERENCES Prestataire (id)');
$this->addSql('ALTER TABLE Payment DROP FOREIGN KEY FK_A295BD912FC0CB0F');
// $this->addSql('DROP TABLE Payment');
$this->addSql('ALTER TABLE Transaction ADD order_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE Transaction ADD CONSTRAINT FK_F4AB8A068D9F6D38 FOREIGN KEY (order_id) REFERENCES orders (id) ON DELETE SET NULL');
$this->addSql('CREATE UNIQUE INDEX UNIQ_F4AB8A068D9F6D38 ON Transaction (order_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE Transaction DROP FOREIGN KEY FK_F4AB8A068D9F6D38');
// $this->addSql('CREATE TABLE Payment (id INT AUTO_INCREMENT NOT NULL, transaction_id INT DEFAULT NULL, resource_id INT NOT NULL, UNIQUE INDEX UNIQ_A295BD912FC0CB0F (transaction_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('ALTER TABLE Payment ADD CONSTRAINT FK_A295BD912FC0CB0F FOREIGN KEY (transaction_id) REFERENCES Transaction (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
$this->addSql('ALTER TABLE orders DROP FOREIGN KEY FK_E52FFDEEBE3DB2B7');
$this->addSql('DROP TABLE orders');
$this->addSql('DROP INDEX UNIQ_F4AB8A068D9F6D38 ON Transaction');
$this->addSql('ALTER TABLE Transaction DROP order_id');
}
}