1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace DoctrineMigrations; |
6
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Schema\Schema; |
8
|
|
|
use Doctrine\Migrations\AbstractMigration; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Auto-generated Migration: Please modify to your needs! |
12
|
|
|
*/ |
13
|
|
|
final class Version20200928205725 extends AbstractMigration |
14
|
|
|
{ |
15
|
|
|
public function getDescription() : string |
16
|
|
|
{ |
17
|
|
|
return 'Create Schema for BankAccount infos'; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function up(Schema $schema) : void |
21
|
|
|
{ |
22
|
|
|
// this up() migration is auto-generated, please modify it to your needs |
23
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
24
|
|
|
|
25
|
|
|
$this->addSql('CREATE TABLE bank_accounts (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, iban VARCHAR(255) NOT NULL, bic VARCHAR(255) NOT NULL, account_name VARCHAR(255) NOT NULL, last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, creation_date DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); |
26
|
|
|
$this->addSql('ALTER TABLE departments ADD bank_account_id INT DEFAULT NULL'); |
27
|
|
|
$this->addSql('ALTER TABLE departments ADD CONSTRAINT FK_16AEB8D412CB990C FOREIGN KEY (bank_account_id) REFERENCES bank_accounts (id)'); |
28
|
|
|
$this->addSql('CREATE INDEX IDX_16AEB8D412CB990C ON departments (bank_account_id)'); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function down(Schema $schema) : void |
32
|
|
|
{ |
33
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
34
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
35
|
|
|
|
36
|
|
|
$this->addSql('ALTER TABLE departments DROP FOREIGN KEY FK_16AEB8D412CB990C'); |
37
|
|
|
$this->addSql('DROP TABLE bank_accounts'); |
38
|
|
|
$this->addSql('DROP INDEX IDX_16AEB8D412CB990C ON departments'); |
39
|
|
|
$this->addSql('ALTER TABLE departments DROP bank_account_id'); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|