migrations/Version20240312135739.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 Version20240312135739 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // NOTE: COLUMN `health_report_submission_files.health_report_submissions_id`
  18.         // WAS LATER CHANGED TO `health_report_submission_id` (NO 's')
  19.         $this->addSql(
  20.             'CREATE TABLE health_report_submission_files (
  21.                 id INT UNSIGNED AUTO_INCREMENT NOT NULL,
  22.                 health_report_submissions_id INT UNSIGNED NOT NULL,
  23.                 file_name VARCHAR(128) NOT NULL,
  24.                 original_name VARCHAR(128) NOT NULL,
  25.                 INDEX IDX_8371AB18825015F (health_report_submissions_id),
  26.                 PRIMARY KEY(id))
  27.                 DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'
  28.         );
  29.         $this->addSql(
  30.             'CREATE TABLE health_report_submissions (
  31.                 id INT UNSIGNED AUTO_INCREMENT NOT NULL,
  32.                 cardio_metabolic_profile_id INT UNSIGNED DEFAULT NULL,
  33.                 user_id INT UNSIGNED NOT NULL,
  34.                 created_at DATETIME NOT NULL,
  35.                 status ENUM(\'PENDING_OCR\', \'EDITABLE\', \'FINAL\')
  36.                     DEFAULT \'PENDING_OCR\' NOT NULL
  37.                     COMMENT \'(DC2Type:health_submission_status_enum_type)\',
  38.                 INDEX IDX_B9DD585D7E454BA8 (cardio_metabolic_profile_id),
  39.                 INDEX IDX_B9DD585DA76ED395 (user_id),
  40.                 PRIMARY KEY(id))
  41.                 DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'
  42.         );
  43.         $this->addSql(
  44.             'ALTER TABLE health_report_submission_files
  45.             ADD CONSTRAINT FK_8371AB18825015F
  46.             FOREIGN KEY (health_report_submissions_id)
  47.             REFERENCES health_report_submissions (id)
  48.             ON DELETE CASCADE'
  49.         );
  50.         $this->addSql(
  51.             'ALTER TABLE health_report_submissions
  52.             ADD CONSTRAINT FK_B9DD585D7E454BA8
  53.             FOREIGN KEY (cardio_metabolic_profile_id)
  54.             REFERENCES cardiometabolic_profiles (id)
  55.             ON DELETE CASCADE'
  56.         );
  57.         $this->addSql(
  58.             'ALTER TABLE health_report_submissions
  59.             ADD CONSTRAINT FK_B9DD585DA76ED395
  60.             FOREIGN KEY (user_id)
  61.             REFERENCES users (id)
  62.             ON DELETE CASCADE'
  63.         );
  64.     }
  65.     public function down(Schema $schema): void
  66.     {
  67.         // this down() migration is auto-generated, please modify it to your needs
  68.         $this->addSql(
  69.             'ALTER TABLE health_report_submission_files
  70.             DROP FOREIGN KEY FK_8371AB18825015F'
  71.         );
  72.         $this->addSql(
  73.             'ALTER TABLE health_report_submissions
  74.             DROP FOREIGN KEY FK_B9DD585D7E454BA8'
  75.         );
  76.         $this->addSql(
  77.             'ALTER TABLE health_report_submissions
  78.             DROP FOREIGN KEY FK_B9DD585DA76ED395'
  79.         );
  80.         $this->addSql('DROP TABLE health_report_submissions');
  81.         $this->addSql('DROP TABLE health_report_submission_files');
  82.     }
  83. }