<?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 Version20210609074853 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('ALTER TABLE registrations ENGINE = InnoDB');
$this->addSql('ALTER TABLE students ENGINE = InnoDB');
$this->addSql('CREATE TABLE pck_charges (id INT AUTO_INCREMENT NOT NULL, transaction_id INT NOT NULL, student_id INT NOT NULL, cc_last4 INT NOT NULL, charge_date DATETIME NOT NULL, charge_amount INT NOT NULL, auth_net_trans_id INT DEFAULT NULL, auth_net_result VARCHAR(255) DEFAULT NULL, auth_net_result_code VARCHAR(45) DEFAULT NULL, refund_date DATETIME DEFAULT NULL, refund_amount INT DEFAULT NULL, refund_auth_net_trans_id INT DEFAULT NULL, refund_auth_net_result VARCHAR(255) DEFAULT NULL, refund_auth_net_result_code VARCHAR(45) DEFAULT NULL, reason_code VARCHAR(45) DEFAULT NULL, INDEX IDX_5AC62D1B2FC0CB0F (transaction_id), INDEX IDX_5AC62D1BCB944F1A (student_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE pck_packages (id INT AUTO_INCREMENT NOT NULL, student_id INT NOT NULL, package_types_id INT NOT NULL, active TINYINT(1) NOT NULL, credit_balance INT NOT NULL, INDEX IDX_ECD2D94CCB944F1A (student_id), INDEX IDX_ECD2D94C6A33A739 (package_types_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE pck_packagetypes (id INT AUTO_INCREMENT NOT NULL, displayName VARCHAR(45) NOT NULL, numberOfCredits SMALLINT NOT NULL, purchasePrice NUMERIC(8, 2) NOT NULL, internalComment VARCHAR(45) NULL, to_display TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE pck_transactions (id INT AUTO_INCREMENT NOT NULL, student_id INT NOT NULL, registrations_id INT DEFAULT NULL, transaction_date DATETIME NOT NULL, transaction_type VARCHAR(45) NOT NULL, credit_amount INT NOT NULL, registration_id INT DEFAULT NULL, refund_date DATETIME DEFAULT NULL, credits_voided INT DEFAULT NULL, INDEX IDX_1CFC5D75CB944F1A (student_id), INDEX IDX_1CFC5D758279080 (registrations_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE pck_transactions_packages (pck_transactions_id INT NOT NULL, pck_packages_id INT NOT NULL, INDEX IDX_16A877078F65F2B9 (pck_transactions_id), INDEX IDX_16A8770727E67CD6 (pck_packages_id), PRIMARY KEY(pck_transactions_id, pck_packages_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE pck_charges ADD CONSTRAINT FK_5AC62D1B2FC0CB0F FOREIGN KEY (transaction_id) REFERENCES pck_transactions (id)');
$this->addSql('ALTER TABLE pck_charges ADD CONSTRAINT FK_5AC62D1BCB944F1A FOREIGN KEY (student_id) REFERENCES students (id)');
$this->addSql('ALTER TABLE pck_packages ADD CONSTRAINT FK_ECD2D94CCB944F1A FOREIGN KEY (student_id) REFERENCES students (id)');
$this->addSql('ALTER TABLE pck_packages ADD CONSTRAINT FK_ECD2D94C6A33A739 FOREIGN KEY (package_types_id) REFERENCES pck_packagetypes (id)');
$this->addSql('ALTER TABLE pck_transactions ADD CONSTRAINT FK_1CFC5D75CB944F1A FOREIGN KEY (student_id) REFERENCES students (id)');
$this->addSql('ALTER TABLE pck_transactions ADD CONSTRAINT FK_1CFC5D758279080 FOREIGN KEY (registrations_id) REFERENCES registrations (id)');
$this->addSql('ALTER TABLE pck_transactions_packages ADD CONSTRAINT FK_16A877078F65F2B9 FOREIGN KEY (pck_transactions_id) REFERENCES pck_transactions (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE pck_transactions_packages ADD CONSTRAINT FK_16A8770727E67CD6 FOREIGN KEY (pck_packages_id) REFERENCES pck_packages (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 pck_transactions_packages DROP FOREIGN KEY FK_16A8770727E67CD6');
$this->addSql('ALTER TABLE pck_packages DROP FOREIGN KEY FK_ECD2D94C6A33A739');
$this->addSql('ALTER TABLE pck_charges DROP FOREIGN KEY FK_5AC62D1B2FC0CB0F');
$this->addSql('ALTER TABLE pck_transactions_packages DROP FOREIGN KEY FK_16A877078F65F2B9');
$this->addSql('DROP TABLE pck_charges');
$this->addSql('DROP TABLE pck_packages');
$this->addSql('DROP TABLE pck_packagetypes');
$this->addSql('DROP TABLE pck_transactions');
$this->addSql('DROP TABLE pck_transactions_packages');
}
}