You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Version20240608120637.php 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7. * Auto-generated Migration: Please modify to your needs!
  8. */
  9. final class Version20240608120637 extends AbstractMigration
  10. {
  11. public function getDescription(): string
  12. {
  13. return '';
  14. }
  15. public function up(Schema $schema): void
  16. {
  17. // this up() migration is auto-generated, please modify it to your needs
  18. $this->addSql('CREATE TABLE portfolio (id SERIAL NOT NULL, client_agreement VARCHAR(255) NOT NULL, xml_data TEXT NOT NULL, start_date DATE NOT NULL, end_date DATE NOT NULL, PRIMARY KEY(id))');
  19. $this->addSql('COMMENT ON COLUMN portfolio.start_date IS \'(DC2Type:date_immutable)\'');
  20. $this->addSql('COMMENT ON COLUMN portfolio.end_date IS \'(DC2Type:date_immutable)\'');
  21. $this->addSql('CREATE TABLE portfolio_detail (id SERIAL NOT NULL, portfolio_id INT NOT NULL, security VARCHAR(32) NOT NULL, quantity_start INT NOT NULL, quantity_end INT NOT NULL, price_start NUMERIC(10, 3) NOT NULL, price_end NUMERIC(10, 3) NOT NULL, sum_start NUMERIC(10, 3) NOT NULL, sum_end NUMERIC(10, 3) NOT NULL, issuer VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
  22. $this->addSql('CREATE INDEX IDX_28ED92A6B96B5643 ON portfolio_detail (portfolio_id)');
  23. $this->addSql('CREATE TABLE portfolio_movement (id SERIAL NOT NULL, portfolio_id INT NOT NULL, security VARCHAR(255) NOT NULL, period TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, quantity_start INT NOT NULL, quantity_end INT NOT NULL, quantity_income INT NOT NULL, quantity_outcome INT NOT NULL, PRIMARY KEY(id))');
  24. $this->addSql('CREATE INDEX IDX_8857CF6FB96B5643 ON portfolio_movement (portfolio_id)');
  25. $this->addSql('COMMENT ON COLUMN portfolio_movement.period IS \'(DC2Type:datetime_immutable)\'');
  26. $this->addSql('ALTER TABLE portfolio_detail ADD CONSTRAINT FK_28ED92A6B96B5643 FOREIGN KEY (portfolio_id) REFERENCES portfolio (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  27. $this->addSql('ALTER TABLE portfolio_movement ADD CONSTRAINT FK_8857CF6FB96B5643 FOREIGN KEY (portfolio_id) REFERENCES portfolio (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  28. }
  29. public function down(Schema $schema): void
  30. {
  31. // this down() migration is auto-generated, please modify it to your needs
  32. $this->addSql('CREATE SCHEMA public');
  33. $this->addSql('ALTER TABLE portfolio_detail DROP CONSTRAINT FK_28ED92A6B96B5643');
  34. $this->addSql('ALTER TABLE portfolio_movement DROP CONSTRAINT FK_8857CF6FB96B5643');
  35. $this->addSql('DROP TABLE portfolio');
  36. $this->addSql('DROP TABLE portfolio_detail');
  37. $this->addSql('DROP TABLE portfolio_movement');
  38. }
  39. }