|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace DoctrineMigrations; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Schema\Schema; |
|
6
|
|
|
use Doctrine\Migrations\AbstractMigration; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Auto-generated Migration: Please modify to your needs! |
|
10
|
|
|
*/ |
|
11
|
|
|
final class Version20180508210325 extends AbstractMigration |
|
12
|
|
|
{ |
|
13
|
|
|
public function up(Schema $schema) : void |
|
14
|
|
|
{ |
|
15
|
|
|
// this up() migration is auto-generated, please modify it to your needs |
|
16
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
|
17
|
|
|
|
|
18
|
|
|
$this->addSql('CREATE TABLE fee (id INT AUTO_INCREMENT NOT NULL, transaction_id INT NOT NULL, fee_id VARCHAR(25) NOT NULL, label VARCHAR(255) DEFAULT NULL, balance NUMERIC(7, 2) NOT NULL, INDEX IDX_964964B52FC0CB0F (transaction_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB'); |
|
19
|
|
|
$this->addSql('CREATE TABLE transaction (id INT AUTO_INCREMENT NOT NULL, date DATETIME NOT NULL, status VARCHAR(255) NOT NULL, invoice_number VARCHAR(25) NOT NULL, user_id VARCHAR(25) NOT NULL, total_balance NUMERIC(7, 2) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB'); |
|
20
|
|
|
$this->addSql('ALTER TABLE fee ADD CONSTRAINT FK_964964B52FC0CB0F FOREIGN KEY (transaction_id) REFERENCES transaction (id)'); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function down(Schema $schema) : void |
|
24
|
|
|
{ |
|
25
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
|
26
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
|
27
|
|
|
|
|
28
|
|
|
$this->addSql('ALTER TABLE fee DROP FOREIGN KEY FK_964964B52FC0CB0F'); |
|
29
|
|
|
$this->addSql('DROP TABLE fee'); |
|
30
|
|
|
$this->addSql('DROP TABLE transaction'); |
|
31
|
|
|
} |
|
32
|
|
|
} |
|
33
|
|
|
|