<?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 Version20220719081713 extends AbstractMigration
{
public function getDescription(): string
{
return 'Initial DB migration';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$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');
$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');
$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');
$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');
$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');
$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');
$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');
$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');
$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');
$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');
$this->addSql('ALTER TABLE account_changes ADD CONSTRAINT FK_E90BAC759B6B5FBA FOREIGN KEY (account_id) REFERENCES accounts (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE accounts ADD CONSTRAINT FK_CAC89EACCB944F1A FOREIGN KEY (student_id) REFERENCES students (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE enrollment_events ADD CONSTRAINT FK_BD089D3DCCFA12B8 FOREIGN KEY (profile_id) REFERENCES profiles (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE enrollment_events ADD CONSTRAINT FK_BD089D3D6D2DFFEE FOREIGN KEY (tuition_modality_id) REFERENCES tuition_modality_templates (id)');
$this->addSql('ALTER TABLE profiles ADD CONSTRAINT FK_8B3085304D993394 FOREIGN KEY (study_programme_id) REFERENCES study_programmes (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE profiles ADD CONSTRAINT FK_8B308530CB944F1A FOREIGN KEY (student_id) REFERENCES students (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE semester_clearances ADD CONSTRAINT FK_63F0ACD2CCFA12B8 FOREIGN KEY (profile_id) REFERENCES profiles (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE tuition_installments ADD CONSTRAINT FK_DEBFC3488F7DB25B FOREIGN KEY (enrollment_id) REFERENCES enrollment_events (id) ON DELETE CASCADE');
$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');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE account_changes DROP FOREIGN KEY FK_E90BAC759B6B5FBA');
$this->addSql('ALTER TABLE tuition_installments DROP FOREIGN KEY FK_DEBFC3488F7DB25B');
$this->addSql('ALTER TABLE enrollment_events DROP FOREIGN KEY FK_BD089D3DCCFA12B8');
$this->addSql('ALTER TABLE semester_clearances DROP FOREIGN KEY FK_63F0ACD2CCFA12B8');
$this->addSql('ALTER TABLE accounts DROP FOREIGN KEY FK_CAC89EACCB944F1A');
$this->addSql('ALTER TABLE profiles DROP FOREIGN KEY FK_8B308530CB944F1A');
$this->addSql('ALTER TABLE profiles DROP FOREIGN KEY FK_8B3085304D993394');
$this->addSql('ALTER TABLE tuition_installments_templates DROP FOREIGN KEY FK_DAB91859B57EBE0A');
$this->addSql('ALTER TABLE enrollment_events DROP FOREIGN KEY FK_BD089D3D6D2DFFEE');
$this->addSql('DROP TABLE account_changes');
$this->addSql('DROP TABLE accounts');
$this->addSql('DROP TABLE enrollment_events');
$this->addSql('DROP TABLE profiles');
$this->addSql('DROP TABLE semester_clearances');
$this->addSql('DROP TABLE students');
$this->addSql('DROP TABLE study_programmes');
$this->addSql('DROP TABLE tuition_installments');
$this->addSql('DROP TABLE tuition_installments_templates');
$this->addSql('DROP TABLE tuition_modality_templates');
}
}