migrations/Version20201106122955.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 Version20201106122955 extends AbstractMigration
  10. {
  11.     public function getDescription() : string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema) : void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  19.         $this->addSql('CREATE TABLE resource_transaction (id INT AUTO_INCREMENT NOT NULL, booking_id INT NOT NULL, created_by INT DEFAULT NULL, updated_by INT DEFAULT NULL, type INT NOT NULL, state VARCHAR(64) NOT NULL, amount NUMERIC(8, 2) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_768C3B833301C60 (booking_id), INDEX IDX_768C3B83DE12AB56 (created_by), INDEX IDX_768C3B8316FE72E1 (updated_by), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('ALTER TABLE resource_transaction ADD CONSTRAINT FK_768C3B833301C60 FOREIGN KEY (booking_id) REFERENCES booking (id)');
  21.         $this->addSql('ALTER TABLE resource_transaction ADD CONSTRAINT FK_768C3B83DE12AB56 FOREIGN KEY (created_by) REFERENCES fos_user (id)');
  22.         $this->addSql('ALTER TABLE resource_transaction ADD CONSTRAINT FK_768C3B8316FE72E1 FOREIGN KEY (updated_by) REFERENCES fos_user (id)');
  23.         $this->addSql('ALTER TABLE payment ADD resource_transaction_id INT DEFAULT NULL');
  24.         $this->addSql('update payment set created_at="2020-11-06 12:29:55", updated_at="2020-11-06 12:29:55"');
  25.         $this->addSql('ALTER TABLE payment ADD CONSTRAINT FK_6D28840D5D8E40AC FOREIGN KEY (resource_transaction_id) REFERENCES resource_transaction (id)');
  26.         $this->addSql('CREATE INDEX IDX_6D28840D5D8E40AC ON payment (resource_transaction_id)');
  27.     }
  28.     public function down(Schema $schema) : void
  29.     {
  30.         // this down() migration is auto-generated, please modify it to your needs
  31.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  32.         $this->addSql('ALTER TABLE payment DROP FOREIGN KEY FK_6D28840D5D8E40AC');
  33.         $this->addSql('DROP TABLE resource_transaction');
  34.         $this->addSql('DROP INDEX IDX_6D28840D5D8E40AC ON payment');
  35.         $this->addSql('ALTER TABLE payment DROP resource_transaction_id');
  36.     }
  37. }