|
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 Version20240528174453 extends AbstractMigration |
|
14
|
|
|
{ |
|
15
|
|
|
public function getDescription(): string |
|
16
|
|
|
{ |
|
17
|
|
|
return ''; |
|
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->addSql('CREATE TABLE account (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, journal_line_item_id INTEGER DEFAULT NULL, account_number VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, description VARCHAR(255) DEFAULT NULL, CONSTRAINT FK_7D3656A474076076 FOREIGN KEY (journal_line_item_id) REFERENCES journal_line_item (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); |
|
24
|
|
|
$this->addSql('CREATE INDEX IDX_7D3656A474076076 ON account (journal_line_item_id)'); |
|
25
|
|
|
$this->addSql('CREATE TABLE journal (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, first_day DATE NOT NULL, last_day DATE NOT NULL, chart_of_account VARCHAR(255) DEFAULT NULL)'); |
|
26
|
|
|
$this->addSql('CREATE TABLE journal_entry (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, journal_id INTEGER NOT NULL, journal_line_item_id INTEGER DEFAULT NULL, title VARCHAR(255) NOT NULL, amount DOUBLE PRECISION DEFAULT NULL, CONSTRAINT FK_C8FAAE5A478E8802 FOREIGN KEY (journal_id) REFERENCES journal (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_C8FAAE5A74076076 FOREIGN KEY (journal_line_item_id) REFERENCES journal_line_item (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); |
|
27
|
|
|
$this->addSql('CREATE INDEX IDX_C8FAAE5A478E8802 ON journal_entry (journal_id)'); |
|
28
|
|
|
$this->addSql('CREATE INDEX IDX_C8FAAE5A74076076 ON journal_entry (journal_line_item_id)'); |
|
29
|
|
|
$this->addSql('CREATE TABLE journal_line_item (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, debit_amount DOUBLE PRECISION NOT NULL, credit_amount DOUBLE PRECISION NOT NULL)'); |
|
30
|
|
|
$this->addSql('CREATE TABLE organization (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name VARCHAR(255) NOT NULL)'); |
|
31
|
|
|
$this->addSql('CREATE TABLE organization_user (organization_id INTEGER NOT NULL, user_id INTEGER NOT NULL, PRIMARY KEY(organization_id, user_id), CONSTRAINT FK_B49AE8D432C8A3DE FOREIGN KEY (organization_id) REFERENCES organization (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_B49AE8D4A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE)'); |
|
32
|
|
|
$this->addSql('CREATE INDEX IDX_B49AE8D432C8A3DE ON organization_user (organization_id)'); |
|
33
|
|
|
$this->addSql('CREATE INDEX IDX_B49AE8D4A76ED395 ON organization_user (user_id)'); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function down(Schema $schema): void |
|
37
|
|
|
{ |
|
38
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
|
39
|
|
|
$this->addSql('DROP TABLE account'); |
|
40
|
|
|
$this->addSql('DROP TABLE journal'); |
|
41
|
|
|
$this->addSql('DROP TABLE journal_entry'); |
|
42
|
|
|
$this->addSql('DROP TABLE journal_line_item'); |
|
43
|
|
|
$this->addSql('DROP TABLE organization'); |
|
44
|
|
|
$this->addSql('DROP TABLE organization_user'); |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|