migrations/Version20220719081713.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 Version20220719081713 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Initial DB migration';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('CREATE TABLE account_changes (id INT AUTO_INCREMENT NOT NULL, account_id INT NOT NULL, amount DOUBLE PRECISION NOT NULL, metadata JSON NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', payed_on DATE NOT NULL, created_by VARCHAR(255) NOT NULL, INDEX IDX_E90BAC759B6B5FBA (account_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE accounts (id INT AUTO_INCREMENT NOT NULL, student_id INT NOT NULL, balance DOUBLE PRECISION NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', UNIQUE INDEX UNIQ_CAC89EACCB944F1A (student_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE enrollment_events (id INT AUTO_INCREMENT NOT NULL, profile_id INT NOT NULL, tuition_modality_id INT DEFAULT NULL, academic_year VARCHAR(10) NOT NULL, INDEX IDX_BD089D3DCCFA12B8 (profile_id), INDEX IDX_BD089D3D6D2DFFEE (tuition_modality_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('CREATE TABLE profiles (id INT AUTO_INCREMENT NOT NULL, study_programme_id INT NOT NULL, student_id INT NOT NULL, index_no VARCHAR(45) NOT NULL, source_id INT NOT NULL, INDEX IDX_8B3085304D993394 (study_programme_id), INDEX IDX_8B308530CB944F1A (student_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  22.         $this->addSql('CREATE TABLE semester_clearances (id INT AUTO_INCREMENT NOT NULL, profile_id INT NOT NULL, semester SMALLINT NOT NULL, suspended TINYINT(1) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_63F0ACD2CCFA12B8 (profile_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  23.         $this->addSql('CREATE TABLE students (id INT AUTO_INCREMENT NOT NULL, first_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL, umsn VARCHAR(20) NOT NULL, excellence_award VARCHAR(10) DEFAULT NULL, child_from_family SMALLINT NOT NULL, source_id INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  24.         $this->addSql('CREATE TABLE study_programmes (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(100) NOT NULL, level_name VARCHAR(100) NOT NULL, source_id INT NOT NULL, faculty VARCHAR(20) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  25.         $this->addSql('CREATE TABLE tuition_installments (id INT AUTO_INCREMENT NOT NULL, enrollment_id INT NOT NULL, title VARCHAR(255) NOT NULL, amount DOUBLE PRECISION NOT NULL, payed_on DATE DEFAULT NULL COMMENT \'(DC2Type:date_immutable)\', due_date DATE NOT NULL COMMENT \'(DC2Type:date_immutable)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_DEBFC3488F7DB25B (enrollment_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  26.         $this->addSql('CREATE TABLE tuition_installments_templates (id INT AUTO_INCREMENT NOT NULL, tuition_modality_template_id INT NOT NULL, title VARCHAR(50) NOT NULL, amount DOUBLE PRECISION NOT NULL, due_date DATE NOT NULL COMMENT \'(DC2Type:date_immutable)\', covered TINYINT(1) NOT NULL, INDEX IDX_DAB91859B57EBE0A (tuition_modality_template_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  27.         $this->addSql('CREATE TABLE tuition_modality_templates (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, total_amount DOUBLE PRECISION NOT NULL, priority SMALLINT NOT NULL, matching_expression VARCHAR(255) DEFAULT NULL, internal TINYINT(1) NOT NULL, covered TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  28.         $this->addSql('ALTER TABLE account_changes ADD CONSTRAINT FK_E90BAC759B6B5FBA FOREIGN KEY (account_id) REFERENCES accounts (id) ON DELETE CASCADE');
  29.         $this->addSql('ALTER TABLE accounts ADD CONSTRAINT FK_CAC89EACCB944F1A FOREIGN KEY (student_id) REFERENCES students (id) ON DELETE CASCADE');
  30.         $this->addSql('ALTER TABLE enrollment_events ADD CONSTRAINT FK_BD089D3DCCFA12B8 FOREIGN KEY (profile_id) REFERENCES profiles (id) ON DELETE CASCADE');
  31.         $this->addSql('ALTER TABLE enrollment_events ADD CONSTRAINT FK_BD089D3D6D2DFFEE FOREIGN KEY (tuition_modality_id) REFERENCES tuition_modality_templates (id)');
  32.         $this->addSql('ALTER TABLE profiles ADD CONSTRAINT FK_8B3085304D993394 FOREIGN KEY (study_programme_id) REFERENCES study_programmes (id) ON DELETE CASCADE');
  33.         $this->addSql('ALTER TABLE profiles ADD CONSTRAINT FK_8B308530CB944F1A FOREIGN KEY (student_id) REFERENCES students (id) ON DELETE CASCADE');
  34.         $this->addSql('ALTER TABLE semester_clearances ADD CONSTRAINT FK_63F0ACD2CCFA12B8 FOREIGN KEY (profile_id) REFERENCES profiles (id) ON DELETE CASCADE');
  35.         $this->addSql('ALTER TABLE tuition_installments ADD CONSTRAINT FK_DEBFC3488F7DB25B FOREIGN KEY (enrollment_id) REFERENCES enrollment_events (id) ON DELETE CASCADE');
  36.         $this->addSql('ALTER TABLE tuition_installments_templates ADD CONSTRAINT FK_DAB91859B57EBE0A FOREIGN KEY (tuition_modality_template_id) REFERENCES tuition_installments_templates (id) ON DELETE CASCADE');
  37.     }
  38.     public function down(Schema $schema): void
  39.     {
  40.         // this down() migration is auto-generated, please modify it to your needs
  41.         $this->addSql('ALTER TABLE account_changes DROP FOREIGN KEY FK_E90BAC759B6B5FBA');
  42.         $this->addSql('ALTER TABLE tuition_installments DROP FOREIGN KEY FK_DEBFC3488F7DB25B');
  43.         $this->addSql('ALTER TABLE enrollment_events DROP FOREIGN KEY FK_BD089D3DCCFA12B8');
  44.         $this->addSql('ALTER TABLE semester_clearances DROP FOREIGN KEY FK_63F0ACD2CCFA12B8');
  45.         $this->addSql('ALTER TABLE accounts DROP FOREIGN KEY FK_CAC89EACCB944F1A');
  46.         $this->addSql('ALTER TABLE profiles DROP FOREIGN KEY FK_8B308530CB944F1A');
  47.         $this->addSql('ALTER TABLE profiles DROP FOREIGN KEY FK_8B3085304D993394');
  48.         $this->addSql('ALTER TABLE tuition_installments_templates DROP FOREIGN KEY FK_DAB91859B57EBE0A');
  49.         $this->addSql('ALTER TABLE enrollment_events DROP FOREIGN KEY FK_BD089D3D6D2DFFEE');
  50.         $this->addSql('DROP TABLE account_changes');
  51.         $this->addSql('DROP TABLE accounts');
  52.         $this->addSql('DROP TABLE enrollment_events');
  53.         $this->addSql('DROP TABLE profiles');
  54.         $this->addSql('DROP TABLE semester_clearances');
  55.         $this->addSql('DROP TABLE students');
  56.         $this->addSql('DROP TABLE study_programmes');
  57.         $this->addSql('DROP TABLE tuition_installments');
  58.         $this->addSql('DROP TABLE tuition_installments_templates');
  59.         $this->addSql('DROP TABLE tuition_modality_templates');
  60.     }
  61. }